/* This code is released into the public domain This maxima code works out the critical gain and oscillation frequency of a three stage RC phase shift oscillator where the three RC stages are non-identical */ /*ABCD matrices for the three RC stages*/ ABCD1: matrix([1+1/(R1*C1*s),1/(C1*s)],[1/R1,1])$ ABCD2: matrix([1+1/(R2*C2*s),1/(C2*s)],[1/R2,1])$ ABCD3: matrix([1+1/(R3*C3*s),1/(C3*s)],[1/R3,1])$ assume(R1>0,R2>0,R3>0,C1>0,C2>0,C3>0)$ /*Obtain transfer function of overall RC phase shifter network*/ ABCD: ABCD1.ABCD2.ABCD3$ ABCD: ABCD,s=%i*w$ 1/list_matrix_entries(ABCD)[1]$ H: ratsimp(%)$ /*Calculate oscillation frequency*/ solve(imagpart(H),w)$ map(lambda([eq],rhs(eq)),%)$ sublist(%,lambda([x],is (x>0)))$ w0: %[1]$ f0: w0/(2*%pi)$ /*Calculate critical gain*/ H,w=w0$ G: combine(expand(ratsimp(-1/%)))$ /*Print results*/ display(G,f0);