solve() need solution pre-chewed

asked 2020-06-21 09:10:20 +0200

ortollj gravatar image

updated 2020-06-22 08:38:49 +0200


why do i have to square the two terms of the equation so that solve gives me the solution?

why it does not alow him to do square both sides ?

x_0Num=-1/3 ;y_0Num=-1/4 ;rNum=1

numL=[x_0==x_0Num ,y_0==y_0Num ,r==rNum]


C_u(x)= sqrt(r^2-x^2)
C_d(x)= -sqrt(r^2-x^2)

delta_0(x)=y_0/x_0*x # radial to circle

delta_p(x)=-x_0/y_0*x + y_0+(x_0^2)/y_0 #perpendicular to circle radial delta_0
# numerical solution
SupNum=solve((C_u(x)==delta_p(x)).substitute(numL), x, to_poly_solve=True)   

# literal solutions which do not work
SupLit1=solve(C_u(x)== delta_p(x), x, to_poly_solve=True) 
SupLit2=solve(C_u(x)== delta_p(x), x,  algorithm='sympy') 

# literal solutions ok
SupLit3=solve(C_u(x)^2== (delta_p(x))^2, x,  algorithm='sympy') 
SupLit4=solve(C_u(x)^2== (delta_p(x))^2, x, to_poly_solve=True) 

show("Sup num : ",SupNum)
show("Sup lit 1 : ", LatexExpr(r" \huge \color{red}  {?? }"),SupLit1)
show("Sup lit 2 : ", LatexExpr(r" \huge \color{red}  {?? }"),SupLit2)
show("Sup lit 3 : ",SupLit3, LatexExpr(r" \huge \color{green}  {OK }"))
show("Sup lit 4 : ",SupLit4, LatexExpr(r" \huge \color{green}  {OK }"))

image description

image description

projection in the other side is easy, but unfortunately the projection matrix is not invertible.

pointInsideCircle=False # projection from outside circle to intside 

# alpha is angle between radial vector([(x_0,y_0),(0,0) ]) and tangente line from x_0,y_0 to circle 
# (the sides  V_R,V_tg,r form a rectangle triangle)
# radial vector from [x_0,y_0] 
# we want it directed to the center of the circle so it is multiplyed by -1
#reduction factor because (||V_R||*cos(alpha)=||V_tg||)
# rotation matrix and shrink to get tangent vector V_tg
# projection Matrix on radial Vector
projectOnRadialVectorM=matrix(SR,[(x_0^2/(x_0^2 + y_0^2), x_0*y_0/(x_0^2 + y_0^2)),
 (x_0*y_0/(x_0^2 + y_0^2), y_0^2/(x_0^2 + y_0^2))])            

# V_tg is the tangent vector

# vector ([[0,0],[x_t,y_t]) from (0,0) to tangent point

# now project the tangent vector on radial Vector


# projected point ProjectPt of [x_0,y_0]= projected vector - radial vector [[x_0,y_0][0,0]  
edit retag flag offensive close merge delete


this is a somewhat strange problem, it is a question of finding the abscissa x_t which corresponds to the point common to the upper semicircle of known radius and has a known line of equation that comes from inside the circle. There is therefore only one point x_t. But to solve the equation we have to square the two sides of the equation and therefore we lose the information that we are looking for the solution in the upper circle and we are left with two solutions. is that probably why the solve () function does not allow itself to be squared?

ortollj gravatar imageortollj ( 2020-06-22 02:04:31 +0200 )edit

oops no! my comment above is stupid, because if my point x_0 y_0 is in the upper part there could be two possible solutions. finally I don't know why solve doesn't know how to solve literally this equation.

ortollj gravatar imageortollj ( 2020-06-22 02:17:37 +0200 )edit

blue vector is on delta_p line.

ortollj gravatar imageortollj ( 2020-06-22 09:13:20 +0200 )edit

Well, I don't know if the function solve () has a problem or not, but I just noticed that my way of proceeding is unnecessarily complicated! It is actually a simple right triangle with a small side sqrt(x_0² + y_0²) and a hypotenuse of length 1 and therefore we deduce the point [x_t, y_t ], where do we take the tangent.

fortunately I have known for a very long time that ridicule does not kill.

ortollj gravatar imageortollj ( 2020-06-22 13:57:19 +0200 )edit