I first had these problems a couple of weeks ago. They had arisen
when working examples from online sources. I had found, but now
have lost, solutions. Trying to recreate the Google searches to
recreate my path have failed.
These problems arose in the context of creating equations
describing node voltages in a passive LTI network.
1. given an equation of form
(V1 - V2) * G12 +(V1 - V3) * G13 +(V1 - V4 ) * G14 +(V1) *
G10 = 0;
how to collect terms to convert to form
S1V1 + S2V2 + S3V3 + S4V4 = 0
GOAL - write system of equations in matrix representation.
2. when solving a system of equations I get
(%i5) solve([%1,%2,%3,%4], [V1,V2,V3,V4]);
(%o5) []
HOWEVER, if [%1,%2,%3,%4] is replaced by the explicit
equations the solution is displayed as expected. I know my
problem here is syntax. When I originally had the problem, the
"solution" was "obvious" once found.
3. Anyone know of a particularity good tutorial for using Maxima
for solving linear network problems? I'm working EXPLICITLY in
the time domain as I'm attempting to recreate content and
pedagogy of EE courses I took in the 60's.
TIA
Trouble shooting Maxima usage
Started by ●July 7, 2013
Reply by ●July 7, 20132013-07-07
Hi,>> HOWEVER, if [%1,%2,%3,%4] is replaced by the explicit >> equations the solution is displayed as expectedare you using ":" for assignment and "=" for equality? For example, this works for me (%i8) eq10: c1 + 2*c2 = 3; (%o8) 2 c2 + c1 = 3 (%i10) eq11: c1 + 3 * c2 = 2; (%o10) 3 c2 + c1 = 2 (%i11) solve([eq10, eq11], [c1, c2]); (%o11) [[c1 = 5, c2 = - 1]] _____________________________ Posted through www.DSPRelated.com
Reply by ●July 7, 20132013-07-07
Hello again,
here is one example for time domain analysis using Laplace transform.
The circuit is from some paper, a ring of four transconductance stages
driving capacitors.
kill(all);
/* node equations */
eq1:'diff(v1(t), t)*C=gm*v4(t)-(v1(t)-vSrc1(t))/R$
eq2:'diff(v2(t), t)*C=gm*v1(t)-(v2(t)-vSrc2(t))/R$
eq3:'diff(v3(t), t)*C=gm*v2(t)-(v3(t)-vSrc3(t))/R$
eq4:'diff(v4(t), t)*C=gm*v3(t)-(v4(t)-vSrc4(t))/R$
/* to Laplace domain */
eq10:laplace(eq1, t, s)$
eq11:laplace(eq2, t, s)$
eq12:laplace(eq3, t, s)$
eq13:laplace(eq4, t, s)$
/* baseband signal seen by circuit is I / Q / -I / -Q */
eq11:subst(exp(-%i*1*%pi/2)*'laplace(vSrc1(t), t, s), 'laplace(vSrc2(t), t,
s), eq11)$
eq12:subst(exp(-%i*2*%pi/2)*'laplace(vSrc1(t), t, s), 'laplace(vSrc3(t), t,
s), eq12)$
eq13:subst(exp(-%i*3*%pi/2)*'laplace(vSrc1(t), t, s), 'laplace(vSrc4(t), t,
s), eq13)$
/* solve for Laplace transform of voltage, current */
eq20:solve([eq10, eq11, eq12, eq13], [
'laplace(v1(t), t, s),
'laplace(v2(t), t, s),
'laplace(v3(t), t, s),
'laplace(v4(t), t, s)])$
eq30:ev('laplace(v1(t), t, s), eq20)$
eq31:diff(eq30, laplace(vSrc1(t), t, s))$
eq32:factor(rat(eq31, s));
disp("frequency response:")$
H(f)=eq32;
eq40:ev('laplace(v2(t), t, s), eq20)$
eq41:diff(eq40, laplace(vSrc1(t), t, s))$
eq42:factor(rat(eq41, s));
eq50:ev('laplace(v3(t), t, s), eq20)$
eq51:diff(eq50, laplace(vSrc1(t), t, s))$
eq52:factor(rat(eq51, s));
eq60:ev('laplace(v4(t), t, s), eq20)$
eq61:diff(eq60, laplace(vSrc1(t), t, s))$
eq62:factor(rat(eq61, s));
/* 3 dB bandwidth */
eq70:ev(eq32, s = %i*omega)$
eq71:eq70 * conjugate(eq70);
eq72:solve(eq71 = 1/2, omega);
omega[diff] = fullratsimp(eq73:ev(omega, eq72[4]) - ev(omega, eq72[1]));
/* peak frequency */
eq80:fullratsimp(solve(diff(eq71, omega) = 0, omega))[3];
/* stability: time domain response v1(t) */
assume(gm > 0, R > 0, C > 0);
expand(ilt(fullratsimp(ev(eq20, 'laplace(vSrc1(t), t, s) = 0, v2(0)=0,
v3(0)=0, v4(0)=0))[1][1], s, t));
eq90:expand((gm*t)/C-t/(C*R)); /* exponential */
eq91:coeff(eq90, t, 1);
eq92:solve(eq91, gm);
_____________________________
Posted through www.DSPRelated.com
Reply by ●July 8, 20132013-07-08
On Sun, 07 Jul 2013 08:21:16 -0500, Richard Owlett wrote:> 2. when solving a system of equations I get > (%i5) solve([%1,%2,%3,%4], [V1,V2,V3,V4]); > (%o5) [] > HOWEVER, if [%1,%2,%3,%4] is replaced by the explicit > equations the solution is displayed as expected.You forgot the "i" or "o", i.e.: solve([%i1,%i2,%i3,%i4], [V1,V2,V3,V4]); or: solve([%o1,%o2,%o3,%o4], [V1,V2,V3,V4]); Previously-entered expressions are available as %i1, %i2, etc, while their evaluated forms are %o1, %o2, etc.> 3. Anyone know of a particularity good tutorial for using Maxima > for solving linear network problems? I'm working EXPLICITLY in > the time domain as I'm attempting to recreate content and > pedagogy of EE courses I took in the 60's.Not me. But if the system is linear, linsolve() will be faster than solve().
Reply by ●July 8, 20132013-07-08
Nobody wrote:> On Sun, 07 Jul 2013 08:21:16 -0500, Richard Owlett wrote: > >> 2. when solving a system of equations I get >> (%i5) solve([%1,%2,%3,%4], [V1,V2,V3,V4]); >> (%o5) [] >> HOWEVER, if [%1,%2,%3,%4] is replaced by the explicit >> equations the solution is displayed as expected. > > You forgot the "i" or "o", i.e.: > > solve([%i1,%i2,%i3,%i4], [V1,V2,V3,V4]); > or: > solve([%o1,%o2,%o3,%o4], [V1,V2,V3,V4]); > > Previously-entered expressions are available as %i1, %i2, etc, while their > evaluated forms are %o1, %o2, etc.*GROAN!* I "knew" that. Really I did ;/ Correcting that error allowed Maxima demonstrate the set of equations themselves malformed (effectively I had left the input disconnected). Thank you. I may be feeling silly, but at least I'll be productive :}> >> 3. Anyone know of a particularity good tutorial for using Maxima >> for solving linear network problems? I'm working EXPLICITLY in >> the time domain as I'm attempting to recreate content and >> pedagogy of EE courses I took in the 60's. > > Not me. > > But if the system is linear, linsolve() will be faster than solve(). >Speed shouldn't be a significant issue, I'll be using less than a dozen nodes. Any suggestion on simplifying expressions such as (V1 * G12 - V2 * G12) +(V1 * G13 - V3 * G13) +(V1 * G14 - V4 * G14 ) +(V1) * G10 to be of form k1 * V1 + k2 * V2 + k3 * V3 + k4 * V4 Searching Maxima's help system for "simplify" doesn't give relevant hits. Surely it can do it?
Reply by ●July 8, 20132013-07-08
Richard Owlett wrote:> [snip] > > Any suggestion on simplifying expressions such as > (V1 * G12 - V2 * G12) +(V1 * G13 - V3 * G13) +(V1 * G14 - V4 > * G14 ) +(V1) * G10 > to be of form > k1 * V1 + k2 * V2 + k3 * V3 + k4 * V4 > Searching Maxima's help system for "simplify" doesn't give > relevant hits. > Surely it can do it? >Plodding thru Help yielded "distrib" and "expand". Neither displayed in my preconceived display format. HOWEVER it demonstrated that though my expressions were correct, I hadn't stopped to think slowly about what they physically represented.
Reply by ●July 8, 20132013-07-08
Hi, I've given up trying to steer simplification into some direction. Instead, my solution is to write an equation in the desired structure, then solve for the coefficients. Derivatives can be useful to create as many equations as there are unknowns. _____________________________ Posted through www.DSPRelated.com
Reply by ●July 8, 20132013-07-08
On Mon, 08 Jul 2013 06:18:25 -0500, Richard Owlett wrote:> Nobody wrote: >> On Sun, 07 Jul 2013 08:21:16 -0500, Richard Owlett wrote: >> >>> 2. when solving a system of equations I get (%i5) solve([%1,%2,%3,%4], >>> [V1,V2,V3,V4]); >>> (%o5) [] >>> HOWEVER, if [%1,%2,%3,%4] is replaced by the explicit >>> equations the solution is displayed as expected. >> >> You forgot the "i" or "o", i.e.: >> >> solve([%i1,%i2,%i3,%i4], [V1,V2,V3,V4]); >> or: >> solve([%o1,%o2,%o3,%o4], [V1,V2,V3,V4]); >> >> Previously-entered expressions are available as %i1, %i2, etc, while >> their evaluated forms are %o1, %o2, etc. > > *GROAN!* > I "knew" that. Really I did ;/ > Correcting that error allowed Maxima demonstrate the set of equations > themselves malformed (effectively I had left the input disconnected). > Thank you. I may be feeling silly, but at least I'll be productive :} > > >>> 3. Anyone know of a particularity good tutorial for using Maxima for >>> solving linear network problems? I'm working EXPLICITLY in the time >>> domain as I'm attempting to recreate content and pedagogy of EE >>> courses I took in the 60's. >> >> Not me. >> >> But if the system is linear, linsolve() will be faster than solve(). >> >> > Speed shouldn't be a significant issue, I'll be using less than a dozen > nodes. > > Any suggestion on simplifying expressions such as > (V1 * G12 - V2 * G12) +(V1 * G13 - V3 * G13) +(V1 * G14 - V4 > * G14 ) +(V1) * G10 to be of form > k1 * V1 + k2 * V2 + k3 * V3 + k4 * V4 > Searching Maxima's help system for "simplify" doesn't give relevant > hits. > Surely it can do it?You can do a bit of that by specifying your variable of interest. I can't remember the syntax exactly, but it's something like ratsimp(<something complex in t, z, and x>, t) will put everything in terms of <this coefficient>t^2 + <that coefficient>t, etc. It may work with factor and expand, too. I'm like "mnentwig", though: I poke at simplification a bit, then if Maxima doesn't cough up what I like I punt. I do find it very handy to evaluate: ratsimp(<Maxima's mangled form> - <my proposed tidy form>) If it comes up with a big fat 0, then I know I'm correct. You often do need the "ratsimp" (or "trigsimp", or whatever), if the expression is complex. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by ●July 9, 20132013-07-09
On Mon, 08 Jul 2013 06:18:25 -0500, Richard Owlett wrote:> Any suggestion on simplifying expressions such as > (V1 * G12 - V2 * G12) +(V1 * G13 - V3 * G13) +(V1 * G14 - V4 > * G14 ) +(V1) * G10 > to be of form > k1 * V1 + k2 * V2 + k3 * V3 + k4 * V4 > Searching Maxima's help system for "simplify" doesn't give > relevant hits. > Surely it can do it?ratsimp, ratexpand, ratvars.
Reply by ●July 9, 20132013-07-09
Tim Wescott wrote:> [snip] >> >> Any suggestion on simplifying expressions such as >> (V1 * G12 - V2 * G12) +(V1 * G13 - V3 * G13) +(V1 * G14 - V4 >> * G14 ) +(V1) * G10 to be of form >> k1 * V1 + k2 * V2 + k3 * V3 + k4 * V4 >> Searching Maxima's help system for "simplify" doesn't give relevant >> hits. >> Surely it can do it? > > You can do a bit of that by specifying your variable of interest. I > can't remember the syntax exactly, but it's something like > > ratsimp(<something complex in t, z, and x>, t) > > will put everything in terms of > <this coefficient>t^2 + <that coefficient>t, etc.I'll have to look at ratsimp again. I may have read too quickly and thought it was explicitly for polynomials, my use is strictly linear.> > It may work with factor and expand, too. I'm like "mnentwig", though: I > poke at simplification a bit, then if Maxima doesn't cough up what I like > I punt.I had come to a similar conclusion. I had written out equations for node voltages by inspection. Maxima's solution was visually a mess. I assumed operator error so tried to simplify appearances. Attempted to use Maxima to avoid copy errors. Failing that, I used pencil and paper add gave the new equations to Maxima which proceeded to tell my "solve: dependent equations eliminated:". But I couldn't see how my set of equations were overdetermined. I created a test case of 3 equations with 3 unknowns with all constants represented symbolically. Maxima gave the same message :< My test case is: (%i1) + g10 * v1 - g21 * v2 - g31 * v3 = p; - g21 * v1 + g20 * v2 - g23 * v3 = q; - g31 * v1 - g23 * v2 + g30 * v3 = r; solve ([%o1 ,%o2 ,%o2 ], [v1,v2,v3]); (%o1) - g31 v3 - g21 v2 + g10 v1 = p (%i2) (%o2) - g23 v3 + g20 v2 - g21 v1 = q (%i3) (%o3) g30 v3 - g23 v2 - g31 v1 = r (%i4) solve: dependent equations eliminated: (3) g21 (q + %r1 g23) + g20 p + %r1 g20 g31 (%o4) [[v1 = - ---------------------------------------, 2 g21 - g10 g20 g10 (q + %r1 g23) + g21 p + %r1 g21 g31 v2 = - ---------------------------------------, 2 g21 - g10 g20 v3 = %r1]] (%i5) What is %r1 (couldn't find it in Help system)? What am I doing wrong? How silly will I feel ;/> > I do find it very handy to evaluate: > > ratsimp(<Maxima's mangled form> - <my proposed tidy form>) > > If it comes up with a big fat 0, then I know I'm correct. You often do > need the "ratsimp" (or "trigsimp", or whatever), if the expression is > complex. >






