From 64b5b78e5cd9dd66c7ccb932823093f153578cff Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Fri, 17 Apr 2020 21:22:46 -0400 Subject: added multiple curves, demonstrating fundamental error --- graph.py | 81 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) (limited to 'graph.py') diff --git a/graph.py b/graph.py index 8b66af7..5c1bbb5 100644 --- a/graph.py +++ b/graph.py @@ -4,47 +4,46 @@ import matplotlib.pyplot as plt import tkinter from math import sin,cos,e -w = 100 # May vary -c1 = 2.5*10**(-6) -c2 = 1*10**(-6) -r1 = 200 -rload = 1000 - -a = 1 -b = c1*r1*rload + r1*c2*rload + (rload**2)*c2 -c = rload - -det = (b**2-4*a*c)**(1/2) -r1 = (-b-det)/(2*a) -r2 = (-b+det)/(2*a) - -A = c1*c2*rload**2*w*(rload-w**2)/(b**2*w**2 + rload**2 - 2*rload*w**2 + w**4) -B = b*c1*c2*rload**2*w**3/(b**2*w**2 + rload**2 - 2*rload*w**2 + w**4) -C = - c1*c2*rload**2*w*(rload-w**2)/(b**2*w**2 + rload**2 - 2*rload*w**2 + w**4) -D = - b*c1*c2*rload**3*w/(b**2*w**2 + rload**2 - 2*rload*w**2 + w**4) # from https://www.wolframalpha.com/input/?i=solve+for+x1%2Cx2%2Cx3%2Cx4+in+%7B%7B1%2C0%2C1%2C0%7D%2C+%7Bb%2C1%2C0%2C1%7D%2C+%7BR%2C+b%2C+w%5E2%2C+0%7D%2C+%7B0%2C+R%2C+0%2C+w%5E2%7D%7D*%7Bx1%2Cx2%2Cx3%2Cx4%7D+%3D+%7B0%2C0%2Cw*c_1*c_2*R%5E2%2C0%7D and an insane partial fraction decomposition -E = (D-C*r1)/(r2-r1) -F = C - E # Another PFD of Cs-D/(as^2+bs+c) -G = B/w - -# Final solution should be -# Gsin(theta) + Bcos(theta) + Ee^(r1 t) + Fe^(r2 t) -# But E, F, r1, and r2 are complex. Luckily, conjugates make it that -# = 2e^(Re(r1) t) ( Re(E)cos(Im(r1)t) - Im(E)sin(Im(r1)t) ) -rer1 = r2.real -reE = F.real -imr1 = r2.imag -imE = F.imag # switched because positive ones were needed - -print("%.2E * sin(t) + %.2E * cos(t) + 2e^(%.2f t) (%.2E cos(%.2f t) - %.2E sin(%.2f t))" % (G, B, rer1, reE, imr1, imE, imr1)) - def f(x): return G*sin(x) + B*cos(x) + 2*e**(rer1 * x) * (reE * cos(imr1 * x) - imE * sin(imr1 * x)) - -x = [] -y = [] -for i in range(0, 1000): - x.append(i/100) - y.append(f(i/100)) - -plt.plot(x,y) +for w in range(100,10000,100): + c1 = 2.5*10**(-6) + c2 = 1*10**(-6) + r1 = 200 + rload = 1000 + + a = 1 + b = c1*r1*rload + r1*c2*rload + (rload**2)*c2 + c = rload + + det = (b**2-4*a*c)**(1/2) + r1 = (-b-det)/(2*a) + r2 = (-b+det)/(2*a) + + A = c1*c2*rload**2*w*(rload-w**2)/(b**2*w**2 + rload**2 - 2*rload*w**2 + w**4) + B = b*c1*c2*rload**2*w**3/(b**2*w**2 + rload**2 - 2*rload*w**2 + w**4) + C = - c1*c2*rload**2*w*(rload-w**2)/(b**2*w**2 + rload**2 - 2*rload*w**2 + w**4) + D = - b*c1*c2*rload**3*w/(b**2*w**2 + rload**2 - 2*rload*w**2 + w**4) # from https://www.wolframalpha.com/input/?i=solve+for+x1%2Cx2%2Cx3%2Cx4+in+%7B%7B1%2C0%2C1%2C0%7D%2C+%7Bb%2C1%2C0%2C1%7D%2C+%7BR%2C+b%2C+w%5E2%2C+0%7D%2C+%7B0%2C+R%2C+0%2C+w%5E2%7D%7D*%7Bx1%2Cx2%2Cx3%2Cx4%7D+%3D+%7B0%2C0%2Cw*c_1*c_2*R%5E2%2C0%7D and an insane partial fraction decomposition + E = (D-C*r1)/(r2-r1) + F = C - E # Another PFD of Cs-D/(as^2+bs+c) + G = B/w + + # Final solution should be + # Gsin(theta) + Bcos(theta) + Ee^(r1 t) + Fe^(r2 t) + # But E, F, r1, and r2 are complex. Luckily, conjugates make it that + # = 2e^(Re(r1) t) ( Re(E)cos(Im(r1)t) - Im(E)sin(Im(r1)t) ) + rer1 = r2.real + reE = F.real + imr1 = r2.imag + imE = F.imag # switched because positive ones were needed + + print("%.2E * sin(t) + %.2E * cos(t) + 2e^(%.2f t) (%.2E cos(%.2f t) - %.2E sin(%.2f t))" % (G, B, rer1, reE, imr1, imE, imr1)) + + x = [] + y = [] + for i in range(1000): + x.append(i/100) + y.append(f(i/100)) + + plt.plot(x,y) plt.show() -- cgit