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

Click For Summary

Homework Help Overview

The original poster is attempting to solve and plot the differential equation x'(t) = 1 + t*sin(t*x) with the initial condition x(0) = 0 and a final time of t_final = 1. The goal is to compare the exact solution with approximations obtained through Euler's and Improved Euler's methods.

Discussion Character

  • Exploratory, Assumption checking, Mixed

Approaches and Questions Raised

  • Participants discuss the challenges of solving the equation algebraically, noting that both Wolfram Alpha and MATLAB indicate a lack of an algebraic solution. There is mention of using numerical solvers, with one participant expressing uncertainty about which solver to use and another suggesting a specific solver based on familiarity.

Discussion Status

The discussion is ongoing, with participants exploring numerical methods as a viable approach to the problem. Guidance has been provided regarding the use of a specific numerical solver, though there is no consensus on the best method or a complete solution yet.

Contextual Notes

Participants are navigating the limitations of algebraic solutions and the appropriateness of numerical methods for this particular problem. There is an acknowledgment of the varying techniques available for solving differential equations in MATLAB.

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
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K