Let $u'=\frac{2}{t+1.3}sin(u+t+5.78)$ with $u(1)=0.278$. Find the maximum of u(t).
My attempt on SCILAB: I tried to use taylor's method and vary the values of t, but I found an absurdly large value, so I'm not confident, follow my code
function $y=f(t,u)$
$y=(2/(t+1.3))*sin(u+t+5.78)$
endfunction
function $y=ft(t,u)$
$y=(2/(t+1.3))*cos(u+t+5.78)$
endfunction
function $[u]=taylor(a,T,N)$
$t(1)=1$
$u(1)=a$
$h=(T-t(1))/N$
for $n=1:N$
$t(n+1)=t(n)+h$;
$F=f(t(n),u(n))$;
$Ft=ft(t(n),u(n))$;
$u(n+1)=u(n)+h*F+(h^2/2)*Ft$
end
ultimo=u(N+1);
plot(t,u,'r.-');xgrid
endfunction
disp(taylor(0.278,100000,10))\
I no longer remember Scilab very well, so I gave this a shot using sympy in python. I'm a python beginner; I'm sure my code isn't the best way to go about this problem. I used Taylor's method to solve the given non-linear ODE.
This part of the code contains two functions. The first one returns a list containing the coefficients (not considering the factorials) of the terms in the Taylor series; the second function takes the list from earlier and returns the actual Taylor series expansion up to $n$ terms.
The function can be called as follows (using n=5):
The result is:
This is $u(t)$. To find the maxima of u(t):
The result is
These are values of $t$ where $u(t)$ is maximum.
My computer struggles with anything above n = 5; this can be attributed to the fact that my code is inefficient which is no surprise.
I hope this helps. Please do let me know in the comments if this is remotely helpful, and whether my results are correct.