Thomas
2014-04-14
I am trying to use linsolve to solve the simultaneous equations for a circuit.
The wxMaxima code I used is:
= = =
vd: i1R3 - iT(R3 + R4);
eq1: vT - iTR4 -(iT - i1)(R3 + R2) = 0;
eq2: -(i1 - i2)Ro - Aovd -(i1 - iT)(R2 + R3) = 0;
eq3: -i2R1 + Aovd -(i2 - i1)*Ro = 0;
linsolve([eq1, eq2, eq3], [iT, i1, i2]);
Rth: vT/%o5[1];
Ao: 1E5;
R1: 4.7E3;
Ro: 100;
R2: 10E3;
R3: 1E5;
R4: 1E5;
ev(Rth);
= = =
You can see that linsolve has a solution for iT which includes iT. Further, when I as for Rth in the following step, both vT and iT are in the solution for the ratio of vT/iT.
I then specify values for the constants and ask for a numerical evaluation of Rth which again specifies the ratio of vT/iT in terms of both vT and iT.
Is there something I am doing wrong?
= = =
P.S. Is it not possible to load a .wxm file here?
Ago77
2014-04-14
I am not sure about the parsing, but if this is your system
(vd: i1 times R3 - iT times (R3 + R4),
eq1: vT - iT times R4 -(iT - i1) times (R3 + R2),
eq2: -(i1 - i2) times Ro - Ao times vd -(i1 - iT) times (R2 + R3),
eq3: -i2 times R1 + Ao times vd -(i2 - i1) times Ro)$
("times" replace the multiplication sign, which makes a mess of the text, and "=0" can be omitted), I seem to get a clean solution. In any case, if the variable appears both on the lhs and on the rhs, then the algorithm has failed. Try "solve" or "to_poly_solve" if that happens.
Thomas
2014-04-14
Ago77,
Is there some wxMaxima setting you have which allows you to get a clean solution using linsolve? You have the equations listed correctly. I used
linsolve([eq1, eq2, eq3], [iT, i1, i2]). Did you do something differently?
I have attached my original .wxm file, which I could not do before, for some reason.
Ago77
2014-04-14
This works just fine on my computer, with wxMaxima 13.04.2 for Windows - I still use "times" instead of the multiplication sign here:
(vd: i1 times R3 - iT times (R3 + R4),
eq1: vT - iT times R4 -(iT - i1) times (R3 + R2),
eq2: -(i1 - i2) times Ro - Ao times vd -(i1 - iT) times (R2 + R3),
eq3: -i2 times R1 + Ao times vd -(i2 - i1) times Ro,
linsolve([eq1, eq2, eq3], [iT, i1, i2]));
For the record, it also works with "solve" and "to_poly_solve".
Thomas
2014-04-15
Ago77,
Since I am using the same version of wxMaxima for Windows as you, the difference seems to be that you solved my equations in one statement (ending with ';'), whereas I had them in 5 separate statements. When I do as you apparently did I get a 'clean' solution as well.
Have you any idea why that would make a difference?
Thanks for your time.
Ago77
2014-04-16
I do not see anything obviously wrong with the syntax, but I am wondering if the problem has to do with the way in which you recover the expressions for the variables. Try to store the solution in a new variable:
(vd: i1 times R3 - iT times (R3 + R4),
eq1: vT - iT times R4 -(iT - i1) times (R3 + R2),
eq2: -(i1 - i2) times Ro - Ao times vd -(i1 - iT) times (R2 + R3),
eq3: -i2 times R1 + Ao times vd -(i2 - i1) times Ro,
sol: linsolve([eq1, eq2, eq3], [iT, i1, i2]));
Then for example to define the expression corresponding to iT in the solution you can use any of these
iT_sol: rhs(sol[1]);
define(iT_sol(Ao, R0, R1, R2, R3, R4, vT), rhs(sol[1]));
iT_sol(Ao, R0, R1, R2, R3, R4, vT):=subst(sol[1], iT);
Thomas
2014-04-16
Ago77,
I tried all your suggestions and none of them worked. The only one that seems to have worked is your original, insightful technique of putting all the operative equations into a single statement. In fact, I replicated that single statement technique and it did not work. I then examined your entry more closely and where I had put a comma and carriage return after each statement, you had just the comma.
Perhaps wxMaxima is parsing this is some odd way.