I have found myself needing to solve complex-valued equations for two real-valued variables. In Mathematica, this is achievable using the Assuming
command as follows:
I am interested to see if it is possible to use FOSS tools to achieve the same result. However, in Maxima, I have not found a way to constrain a and b to be purely real. It returns a complex-valued solution with one degree of freedom.
(%i22) solve(%e^(%i*%pi/4) = a*(%i*b 1), [a,b]);
%i 1
(%o22) [[a = ------------------------, b = %r4]]
sqrt(2) %i %r4 sqrt(2)
Even using declare(a, real)
and declare(b, real)
before running solve
, it gives the same result. I have also tried to add constraints within the system of equations, but that doesn't work either:
(%i9) solve([x^3=1, imagpart(x)=0], x);
sqrt(3) %i - 1 sqrt(3) %i 1
(%o9) [[x = 1], [x = --------------], [x = - --------------]]
2 2
Is solving an equation like this possible in Maxima or any other FOSS CAS?
CodePudding user response:
That's an interesting question. I asked Maxima guys using mailing list (yeah, it's still functioning) and they told me that solve
ignores declares and this seems to be the easiest solution:
%e^(%i*%pi/4) = a*(%i*b 1)$
solve([realpart(%),imagpart(%)],[a,b]);