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

1. May 9, 2013

### bdoherty1994

1. The problem statement, all variables and given/known data

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?

2. Relevant equations

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

3. The attempt at a solution

I have tried to use dsolve() only to come up with an error.

2. May 9, 2013

### Office_Shredder

Staff Emeritus
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

3. May 9, 2013

### bdoherty1994

Thank you for your help! Which numerical solver would you recommend?

4. May 10, 2013

### Office_Shredder

Staff Emeritus
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