Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
279 views
# Solving an ODE ( Analytically - General Solution ) # example y’=tan(y)/(x-1) y = function ('f')(x) # defines the solution as a function de = diff (y,x) == tan(y)/(x-1) # defines the differential equation h = desolve (de , y) # solves analytically ( when possible ) show (h) # shows implicit solution show (solve (h,y)) # shows solution if its a function # This is the general solution as we did not give initial conditions
log(sin(f(x)))=C+log(x1)\displaystyle \log\left(\sin\left(f\left(x\right)\right)\right) = C + \log\left(x - 1\right)
[f(x)=arcsin(xeCeC)\displaystyle f\left(x\right) = \arcsin\left(x e^{C} - e^{C}\right)]
# Solving an IVP ( Analytically - Specific Solution ) # example y’=tan(y)/(x-1) y(0) =-pi/2 y = function ('f')(x) # defines the solution as a function de = diff (y,x) == tan(y)/(x-1) # defines the differential equation h = desolve (de , y, ics =[0,-pi/2]) # solves analytically ( when possible ) show (h) # shows right hand side of solution show (solve (h,y)) # shows solution if its a function # This is the particular solution as we gave initial conditions
log(sin(f(x)))=log(x1)\displaystyle \log\left(\sin\left(f\left(x\right)\right)\right) = \log\left(x - 1\right)
[f(x)=arcsin(x1)\displaystyle f\left(x\right) = \arcsin\left(x - 1\right)]
# Plotting a sequence of solution curves with a direction field for an ODE # example y'+2*y=-x^2*e^(-2*x) which has solutions y=e^(-2*x)*(x^4/4+C) x,y= var('x,y') I=sum( plot (e^(-2*x)*(x^4/4+0.2*c),(x,-0.5,1)) for c in range (-5,10)) #varies the constant c in the general solution y=e^( -2*x)*(x ^4/4+ c) D= plot_slope_field(-2*y+x^2*e^(-2*x),(x,-0.5,1),(y , -4 ,5),headaxislength=3, headlength =3) # plots the direction field (solve for y' and put in right hand side) P= plot (e^(-2*x)*(x^4/4),(x,-0.5,1),color='red', thickness=3) #emphasizes a specific solution in red show (I+D+P)