Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Polar to Cartesian most Elegan way ?

Hi

##  polar to Cartesian
forget()
# trying to get (b * x  + sqrt(x^2 + y^2)) -1= 0  from r==1/(1+b*cos(t))
# first by hand:
# sqrt(x^2 + y^2) = 1 / (b * x / sqrt(x^2 + y^2) + 1)
# sqrt(x^2 + y^2) = sqrt(x^2 + y^2) / (b * x / sqrt(x^2 + y^2) + sqrt(x^2 + y^2))
# sqrt(x^2 + y^2) = sqrt(x^2 + y^2) / (b * x  + sqrt(x^2 + y^2))
# 1 = 1 / (b * x  + sqrt(x^2 + y^2))
# (b * x  + sqrt(x^2 + y^2)) -1= 0 

# second with SageMath:

## Sagemath polar to Cartesian
forget()
t,x,y,b,r = var('t x y b r')
assume(t,'real')
#b=0.5
eq0=r==1/(1+b*cos(t))
eq1=x==r*cos(t)
eq2=y==r*sin(t)
eq3=r==sqrt(x^2 + y^2)
S=solve(eq1,cos(t))
show(S)
eq4=eq0.substitute(S[0])
eq5=eq4.substitute(eq3)
show(eq5)
eq6=(eq5.simplify_full())
eq6=(eq6/eq6.rhs().numerator())
show(eq6)
eq7=1/eq6
eqFinal=eq7-1
show(eqFinal)

is there an much elegant way to get the cartesian (b * x + sqrt(x^2 + y^2)) -1= 0 from polar r==1/(1+b*cos(t)) with sagemath (I find my Sagemath way laborious !) ?

Polar to Cartesian most Elegan way ?

Hi

##  polar to Cartesian
forget()
# trying to get (b * x  + sqrt(x^2 + y^2)) -1= 0  from r==1/(1+b*cos(t))
# first by hand:
# sqrt(x^2 + y^2) = 1 / (b * x / sqrt(x^2 + y^2) + 1)
# sqrt(x^2 + y^2) = sqrt(x^2 + y^2) / (b * x / sqrt(x^2 + y^2) + sqrt(x^2 + y^2))
# sqrt(x^2 + y^2) = sqrt(x^2 + y^2) / (b * x  + sqrt(x^2 + y^2))
# 1 = 1 / (b * x  + sqrt(x^2 + y^2))
# (b * x  + sqrt(x^2 + y^2)) -1= 0 

# second with SageMath:

## Sagemath polar to Cartesian
forget()
t,x,y,b,r = var('t x y b r')
assume(t,'real')
#b=0.5
eq0=r==1/(1+b*cos(t))
eq1=x==r*cos(t)
eq2=y==r*sin(t)
eq3=r==sqrt(x^2 + y^2)
S=solve(eq1,cos(t))
show(S)
eq4=eq0.substitute(S[0])
eq5=eq4.substitute(eq3)
show(eq5)
eq6=(eq5.simplify_full())
eq6=(eq6/eq6.rhs().numerator())
show(eq6)
eq7=1/eq6
eqFinal=eq7-1
show(eqFinal)

is there an much elegant way to get the cartesian (b * x + sqrt(x^2 + y^2)) -1= 0 from polar r==1/(1+b*cos(t)) with sagemath (I find my Sagemath way laborious !) ?