• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Sage Second Order Differential Issue

utoft May 31st, 2013 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Vout,t = var("Vout,t")
2.
3. #The known variables
4. L = 1e-3
5. C = 1e-9
6. Vin = 5
7. R = 1e3
8.
9. Vout = function("Vout",t)
10. equation = L*C*diff(Vout,t,2) + R*C*diff(Vout,t) + Vout == Vin
11. generalSolution = desolve(equation,Vout,ivar=t)
12. print "General Solution :", generalSolution
13. show(generalSolution)
14. specificSolution = desolve(equation,Vout,ivar=t,ics=[0,0,0])
15. print "Specific Solution :", specificSolution
16. show(specificSolution)
17.
18. #Plotting
19. plotMax = 2e-5
20. plot1 = plot(specificSolution,[t,0,plotMax],rgbcolor=[0,0,0]) #Differential equation
21. plot1 += plot(Vin*0.1,[t,0,plotMax],rgbcolor=[0,0,1]) #10% line
22. plot1 += plot(Vin*0.9,[t,0,plotMax],rgbcolor=[0,0,1]) #90% line
23. show(plot1)
24.
25. #Find the local maximum
26. findMax = find_local_maximum(specificSolution,1e-6,5e-6)
27. print "Local max =", findMax
28.
29. print "### First Issue ###"
30. ### FIRST ISSUE ###
31. ### Normally i would take the differential and set it to zero
32. findMax2 = solve(diff(specificSolution,t) == 0,t)
33. print "Local max2", findMax2 ## Result is obviously wrong. It should match findMax
34.
35. print "### Second Issue ###"
36. ### SECOND ISSUE ###
37. #First as i usually would do
38. print "\t 10% = ",solve(specificSolution==Vin*0.1,t)
39. print "\t 90% = ",solve(specificSolution==Vin*0.9,t)
40.
41. ## i found this somewhere, but it didn't help
42. func(t) = specificSolution
43. print "\t 10% = ",solve(func(x)==Vin*0.1,x)
44. print "\t 90% = ",solve(func(x)==Vin*0.9,x)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?