## Simultaneous trigonometric equations

Anonymous
2010-03-19
2012-09-10
• Anonymous - 2010-03-19

Hello,

Does Maxima (or indeed any software) allow one to

convert from say, this:

x = cos(theta) * r

y = sin(theta) * r

...to this:

r = sqrt(xx + yy)

theta = atan2(y,x)

In other words, it will automatically extract the variables

(theta and r), and then have only those to the left of the equals sign.

Here's another more complicated example:

FROM:

r = sqrt (xx + yy + z*z )

theta = atan2(sqrt(xx + yy),z )

phi = atan2(y,x)

...TO:

x = r * sin(theta)*cos(phi);

y = r * sin(theta)*sin(phi);

z = r * cos(theta)

Once again, the variables x, y and z are extracted from the

first simultaneous equation.

I tried this:

solve(,)

However, it returns just "". If I replace, x and y with actual numbers, it
seems to work okay, but I need the answer expressed with the variable names
intact.

The final thing I need would be for this to work through the

CLI, because I use a programming language, so would like to

feed a text file to the program, and for the program to output

a text file with the solution/s.

• Aleksas Domarkas - 2010-03-20

example 1:

(%i1) L1:x = cos(theta)*r\$

L2:y = sin(theta)*r\$

(%i3) L:,trigreduce;

(%o3)

(%i4) sol1:solve(L,r);

(%o4) r=sqrt(y^2+x^2)

(%i5) sol2:solve(L,theta);

solve: using arc-trig functions to get a solution.

Some solutions will be lost.

(%o5) theta=atan(y/x)

(%i6) sol:;

(%o6)

example 2

(%i7) L1:r = sqrt (xx + yy + z*z )\$

L2:theta = atan2(sqrt(xx + yy),z )\$

L3:phi = atan2(y,x)\$

(%i8)

(%i9)

(%i10) L:;

(%o10)

(%i11) sol:solve(,),trigreduce\$

(%i12) sol:trigsimp(%);

(%o12)

• Anonymous - 2010-03-23

Many thanks for your reply - it is appreciated.

I think I've bitten off more than I can chew here, mathematically and
wxmaxima-wise. From your answer, it seems as though there isn't a simple way
from getting from A to B without establishing other criteria (such as the
L:,trigreduce; which I would want to avoid really). I was hoping for a simple
conversion (even if there are multiple answers), but it seems only something
obscure like genetic programming may be fully capable of that?

In other words, I'm probably being naive wanting something like this to work:

solve(, theta)

(for starters, I'd have to somehow specify that the r variable can't be used
when trying to find theta etc.).

While I think about this some more, I have some much simpler requests which
will help me to use wxmaxima more effectively:

This...

solve(x:r+s, s)

...correctly returns s=-r

However this:

x:r+s \$

solve(s);

...should be the same, but in fact returns just . Any idea why?

One more puzzling thing. This works:

solve(x:r+s, s)

But not this:

solve(x:r*s, s)

I would expect: s=x/r but instead Maxima returns . Again, any
ideas?

• Anonymous - 2010-03-23

The end of my reply was messed up. I'll post it again here:

...should be the same, but in fact returns just s=0. Any idea why?

One more puzzling thing. This works:

solve(x:r+s, s)

But not this:

solve(x:r*s, s)

I would expect: s=x/r but instead Maxima returns s=0. Again, any ideas?

• Andrej Vodopivec - 2010-03-23

For equations use = instead of :

(%i1) solve(x=r+s, s);

(%o1)

(%i2) solve(x=r*s, s);

(%o2)