Maxima: How can I get a variable as the sum of the function of other variables from a system of equations?

194 Views Asked by At

The problem is this; I have a system of equations, which describes the workings of a system. (In this case, an electronic system.) The system has inner variables, as well as input and output variables. What I would want, is to get the output variables in terms of the input variables such that the output variable is described as a sum of the functions of the input variables + a constant. (Of course, only if this is at all mathematically possible, in the particular case.)

Preferably I would like to use the Maxima Computer Algebra System, but I am also interested in ways to do it in Matlab.

Let me give 2 examples; I hope you get the idea. O denotes output variable, I denotes input variable, x denotes inner variable, p denotes parameter.

1:

e1: O = x_1 * p_1 + x_2 * p_2;

e2: x_1 = x_2 + I_1 * p_3;

e3: x_2 = I_2 * p_4 + p_5;

solution #1: O = p_1 * p_3 * I_1 + p_4 * (p_1 + p_2) * I_2 + p_5 * (p_1 + p_4)

2:

e1: O = x_1 * p_1 + x_2 * p_2;

e2: x_1 = sqrt(I_1) * p_3;

e3: x_2 = tan(I_2 * p_4);

solution #2: O = p_1 * p_3 * sqrt(I_1) + p_2 * tan(p_4 * I_2)

1

There are 1 best solutions below

0
On

Maxima has some ability to solve systems of equations symbolically, although it is not too strong in that respect. Be that as it may, I see Maxima can solve at least the examples given.

(%i2) e1:O = x_1*p_1+x_2*p_2
(%o2)                        O = p_2 x_2 + p_1 x_1
(%i3) e2:x_1 = x_2+I_1*p_3
(%o3)                         x_1 = x_2 + I_1 p_3
(%i4) e3:x_2 = I_2*p_4+p_5
(%o4)                         x_2 = p_5 + I_2 p_4
(%i5) eliminate([e1,e2,e3],[x_1,x_2])
(%o5)      [(p_2 + p_1) p_5 + I_2 (p_2 + p_1) p_4 + I_1 p_1 p_3 - O]
(%i6) solve(%,O)
(%o6)    [O = (p_2 + p_1) p_5 + (I_2 p_2 + I_2 p_1) p_4 + I_1 p_1 p_3]
(%i7) e1:O = x_1*p_1+x_2*p_2
(%o7)                        O = p_2 x_2 + p_1 x_1
(%i8) e2:x_1 = sqrt(I_1)*p_3
(%o8)                         x_1 = sqrt(I_1) p_3
(%i9) e3:x_2 = tan(I_2*p_4)
(%o9)                         x_2 = tan(I_2 p_4)
(%i10) eliminate([e1,e2,e3],[x_1,x_2])
(%o10)            [p_2 tan(I_2 p_4) + sqrt(I_1) p_1 p_3 - O]
(%i11) solve(%,O)
(%o11)            [O = p_2 tan(I_2 p_4) + sqrt(I_1) p_1 p_3]

Note that I've called eliminate to eliminate the incidental variables x_1 and x_2 from the equations before solving for O; after eliminating the incidental variables, O is expressed in terms of the inputs and parameters only.

If you try working with more complex equations, you might run into limitations of Maxima. It might be possible to make more progress by using other functions such as to_poly_solve which can solve some equations involving radicals. You might consider posting a message to the Maxima mailing list if you run into trouble. See: https://sourceforge.net/projects/maxima/lists/maxima-discuss