```python
import sympy as sym
import matplotlib.pyplot as plt

x1,x2,x3,y1,y2,y3,a,b,x,y=sym.symbols('x1,x2,x3,y1,y2,y3,a,b,x,y')
wc1=(a*x1+b-y1)**2
wc2=(a*x2+b-y2)**2
wc3=(a*x3+b-y3)**2

wc = wc1+wc2+wc3
wc= wc.subs(x1,-29).subs(x2,-20).subs(x3,-13)
wc= wc.subs(y1,-9).subs(y2,1).subs(y3,4)
wc







```




$\displaystyle \left(- 29 a + b + 9\right)^{2} + \left(- 20 a + b - 1\right)^{2} + \left(- 13 a + b - 4\right)^{2}$




```python

wc=wc.expand()
wc
wc.collect(a)


```




$\displaystyle 1410 a^{2} + a \left(- 124 b - 378\right) + 3 b^{2} + 8 b + 98$




```python
#b=-(14*a-22)/(2*3)
eq1=sym.Eq(a,-(-124*𝑏-378)/(2*1410))
wc.collect(b)

```




$\displaystyle 1410 a^{2} - 378 a + 3 b^{2} + b \left(8 - 124 a\right) + 98$




```python
eq2=sym.Eq(b,-(8-124*a)/(2*3))
sym.solve([eq1,eq2],[a,b])

```




    {a: 319/386, b: 3039/193}




```python

a=319/386.0
b=3039/193.0

plt.plot(-29,-9,'o')
#plt.text(-29,-20,'x1,y1')

plt.plot(-20,1,'o')
#plt.text(-13,-9,'x2,y3')

plt.plot(-13,4,'o')
#plt.text(1,4,'x2,y3')

plt.plot([-29,-20,-13],[a*-29+b,a*-20+b,a*-13+b],marker='o')

plt.show()
```


```python

```

5018d0accb59ebd5fa6df4db4917d688ad219db7
ipynb
Jupyter Notebook
20210907.ipynb
mlq-star/MaryQJupyter
e7c5ae3200826e3b8fdcd0b2ef1d2d4d679a5506
BSD-3-Clause
20210907.ipynb
mlq-star/MaryQJupyter
e7c5ae3200826e3b8fdcd0b2ef1d2d4d679a5506
BSD-3-Clause
20210907.ipynb
mlq-star/MaryQJupyter
e7c5ae3200826e3b8fdcd0b2ef1d2d4d679a5506
BSD-3-Clause
Qwen/Qwen-72B
1. YES
2. YES