Ask Your Question

neomax's profile - activity

2021-02-03 20:58:36 +0100 received badge  Student (source)
2015-10-06 17:00:27 +0100 asked a question Simplify Algebra Fraction

How should I make SageMath gives the desired simplification of the following number:

1/2*sqrt(29)*sqrt(3)*sqrt(62/87)

Doing either of the following command only gives me 1/174*sqrt(87)*sqrt(62)*sqrt(29)*sqrt(3) instead of 1/2*sqrt(62)

(1/2*sqrt(29)*sqrt(3)*sqrt(62/87)).simplify_rational()
simplify(1/2*sqrt(29)*sqrt(3)*sqrt(62/87))
2015-10-04 16:39:15 +0100 commented answer simplify_rational gives different results

Thank you. However I did further tests. These following two expressions give different results.

((tt*n).norm()).simplify_rational()
(tt*(n.norm())).simplify_rational()

Mathematically and programmtically the expressions in the parenthesis should be the same. They are both scalar and "sage.symbolic.expression.Expression".

What's the real difference?

2015-10-04 14:05:58 +0100 asked a question simplify_rational gives different results

I am doing basic vector algebra calculation.

var('x0 y0 z0 a b c d')
B=vector([x0, y0, z0])
n=vector([a,b,c])
A=vector([0,0,d/c])
ab=B-A
proj=ab.dot_product(n)/n.norm()^2*n

However simplifying proj does not give me the expected results

proj.norm().simplify_rational()

Gives me:

sqrt((a^2*x0^2 + b^2*y0^2 + c^2*z0^2 - 2*a*d*x0 + d^2 + 2*(a*b*x0 -
b*d)*y0 + 2*(a*c*x0 + b*c*y0 - c*d)*z0)/(a^2 + b^2 + c^2))

However if I use the following addtional steps

tt=ab.dot_product(n)/n.norm()^2
(tt*n.norm()).simplify_rational()

The result is satisfactory:

(a*x0 + b*y0 + c*z0 - d)/sqrt(a^2 + b^2 + c^2)

In addition, if I ommit parenthesis the results become different again:

tt*n.norm().simplify_rational()

Results in

sqrt(a^2 + b^2 + c^2)*(a*x0 + b*y0 + c*(z0 - d/c))/(a*conjugate(a) +
b*conjugate(b) + c*conjugate(c))

And (tt*n).norm().simplify_rational() Results in

sqrt((a^2*x0^2 + b^2*y0^2 + c^2*z0^2 - 2*a*d*x0 + d^2 + 2*(a*b*x0 -
b*d)*y0 + 2*(a*c*x0 + b*c*y0 - c*d)*z0)/(a^2 + b^2 + c^2))

What are the exact difference? How do I ensure getting the desired outcome?