Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168733
Image: ubuntu2004

We want to solve the initial value problem

y+y=ecosty'+y=e^{\cos t}

y(t0)=y0y(t_0)=y_0

Using the method of integrating factors we can find μ(t)=et\mu(t)=e^t

ety+ety=et+coste^ty'+e^ty=e^{t+\cos t}

which gives

[ety]=et+cost[e^ty]'=e^{t+\cos t}

and

ety=et+cost dt+Ce^ty=\int e^{t+\cos t}\ dt + C

Finally

y=etet+cost dt+Cety=e^{-t}\int e^{t+\cos t}\ dt + Ce^{-t}

So all we need is the integral et+cost dt\int e^{t+\cos t}\ dt and we are done

var('t') integral(e^(t+cos(t)),t)
\newcommand{\Bold}[1]{\mathbf{#1}}\int e^{\left(t + \cos\left(t\right)\right)}\,{d t}

But the above tells us sage doesn't know how to find the integral abstractly. Which means it's a fairly sure bet we can't find it either. So instead of worrying we will use a numerical integral to find (and graph) solutions.

y(t)=ett0tex+cosx dx+Cety(t)=e^{-t}\int_{t_0}^t e^{x+\cos x}\ dx + Ce^{-t}

Note that

y0=y(t0)=et0t0t0ex+cosx dx+Cet0=Cet0y_0=y(t_0)=e^{-t_0}\int_{t_0}^{t_0} e^{x+\cos x}\ dx + Ce^{-t_0}=Ce^{-t_0}

Solving for CC gives us C=et0y0C=e^{t_0}y_0

Let's suppose that t0=0t_0=0 and plot some integral curves for yy

var('t,u,x,y') C=0 def f(t): return N(exp(-t)*(numerical_integral(exp(u+cos(u)),0,t)[0]+C)) p1=plot(f,(t,-10,10),ymin=-10,ymax=10) C=7 p2=plot(f,(t,-10,10),ymin=-10,ymax=10,color='red') C=-5 p3=plot(f,(t,-10,10),ymin=-10,ymax=10,color='green') p=plot_slope_field(exp(cos(t))-y,(t,-10,10),(y,-10,10)) show(p+p1+p2+p3)