Matlab code for solving and plotting function x'(t) = 1 + t*sin(t*x)

bdoherty1994
Messages
4
Reaction score
0

Homework Statement



I am trying to solve and plot the function, x'(t) = 1 + t*sin(t*x) where x(0) = 0 and t_final = 1, in order to compare this exact solution to the approximations of Euler's and Improved Euler's Method. Can anyone help me with the code in order to solve this problem, and then plot it, using Matlab?

Homework Equations



x'(t) = 1 + t*sin(t*x) where x(0) = 0 and t_final = 1

The Attempt at a Solution



I have tried to use dsolve() only to come up with an error.
 
Physics news on Phys.org
wolfram alpha can't solve it and MATLAB tells me it can't find a solution either so I'm guessing you can't solve it algebraically. If you use a numerical solver on MATLAB the solution you get will be so close to the correct solution that if you knew the solution you wouldn't be able to tell the difference, so I'd just use that
 
Thank you for your help! Which numerical solver would you recommend?
 
I don't really understand the differences between them (they are designed to solve much harder problems than this one using varying techniques). I typically use this one
http://www.mathworks.com/help/matlab/ref/ode15s.html

but only because it's the one that I have seen used in examples and thus is the one I remember when I have to do something like this. Someone else could better explain what the advantages/disadvantages of each are perhaps, but it doesn't matter to this problem
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top