Ask Your Question

Revision history [back]

Your proj is ab.dot_product(n)/n.norm()^2*n so your tt*n.norm() is ab.dot_product(n)/n.norm()^2 * n.norm() which is different from proj.norm() because the norm() in tt*n.norm() only applies to n. You made the same mistake when you equaled (tt*n.norm()).simplify_rational() and tt*n.norm().simplify_rational(). Here in the latter the simplify_rational() only applies to n.norm().

Operator precedence in Sage closely follows the same in Python (but in C++ for example the dot would have behaved the same way.

Your proj is ab.dot_product(n)/n.norm()^2*n so your tt*n.norm() is ab.dot_product(n)/n.norm()^2 * n.norm() which is different from proj.norm() because the norm() in tt*n.norm() only applies to n. You made the same mistake when you equaled (tt*n.norm()).simplify_rational() and tt*n.norm().simplify_rational(). Here in the latter the simplify_rational() only applies to n.norm().

Operator precedence in Sage closely follows the same in Python (but in C++ for example the dot would have behaved the same way.way).