Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting Sympy Result to Particular Solution of Differential Equation

So far I have managed to find the particular solution to this equation for any given mass and drag coefficient. I have not however found a way to plot the solution or even evaluate the solution for a specific point. I really want to find a way to plot the solution.

from sympy import *

m = float(raw_input('Mass:\n> '))
g = 9.8
k = float(raw_input('Drag Coefficient:\n> '))
f = Function('f')
f1 = g * m
t = Symbol('t')
v = Function('v')
equation = dsolve(f1 - k * v(t) - m * Derivative(v(t)), 0)
C1 = Symbol('C1')
C1_ic = solve(equation.rhs.subs({t:0}),C1)[0]
equation = equation.subs({C1:C1_ic})
like image 876
Kklj8 Avatar asked Aug 16 '16 01:08

Kklj8


1 Answers

For completeness, you may also use Sympy's plot, which is probably more convenient if you want a "quick and dirty" plot.

plot(equation.rhs,(t,0,10))

enter image description here

like image 87
Stelios Avatar answered Oct 12 '22 23:10

Stelios