Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Solving Simultaneous Equations: How to Exclude Imaginary Numbers?

Hello all,

I am working on a Calculus problem where you have to find the critical points of a function f(x,y,z) subject to a constraint function c(x,y,z) = constant. I managed to use Sagemath to output the answers, but it is including answers that have complex numbers. How can I exclude the answers with complex numbers?

Here's the code I have written:

Blockquote var('x y z u p', domain='real') f = x^6 + y^6 + z^6 c = x^2 + y^2 + z^2 c1 = c == 6 fx = f.diff(x) fy = f.diff(y) fz = f.diff(z) cx = uc.diff(x) cy = uc.diff(y) cz = u*c.diff(z) eq1 = fx - cx == 0 eq2 = fy - cy == 0 eq3 = fz - cz == 0 answers = solve([eq1,eq2,eq3,c1],x,y,z,u)