1

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)

Community
  • 1
  • 1
Cerike
  • 354
  • 1
  • 15
  • it is not clear from the question (at least to me) what kind of equation you are expecting and what is known. In the examples you provide can we assume all quantities are known but O? If so, your equations are linear: will it be always the case? Can you rewrite the equation in a linear fashion? Do you want a symbolic solution or a numerical one? Please clarify. Thanks – pacta_sunt_servanda Sep 15 '18 at 17:06
  • We want to have O as a function of I, and we want to see what effect each I has on O. We don't know any values, only how they are related (the system of equations). I need a symbolic solution, like in the examples. If what I am trying to describe is not a linear system then I can't rewrite it to be linear (eg. sqrt(I_1)), but even if it is a linear system and it can be rewritten, that, (rewriting it) is basically the very thing I want Maxima/Matlab to do, to avoid errors. If the system is linear, the result must be the vector I times a vector which contains only p(arameters). – Cerike Sep 15 '18 at 17:26
  • you may want to look into the symbolic equation toolbox. If you want a numerical solution, once the parameters are known, it is another story (or sensitivity analysis fixing some parameters); but if you truly want literal solution you can use solve (and you would need the toolbox). Or you could code your own symbolic solver, but then -I guess- you would much better off solving by hand and trying with examples for testing (or using other software; e.g.: Mathematica) – pacta_sunt_servanda Sep 15 '18 at 17:36
  • OK, I got the toolbox (Symbolic Math Toolbox). Could you give me an example code for the solution of the first example (or the second), so I can get the idea? I don't know what to look up on google, what functions I should use. – Cerike Sep 16 '18 at 12:54

1 Answers1

1

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

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48