Solving IVP with ODE45: a=0.00001, b=0.25 & a=0.0002, b=0.10

  • MATLAB
  • Thread starter mooberrymarz
  • Start date
  • Tags
    Ivp Ode45
In summary, to solve an IVP using ODE45, the differential equation and initial conditions must be defined. Then, the ODE45 function can be used to numerically solve the equation. The values of a and b in the given IVP represent coefficients and determine the behavior of the solution. ODE45 uses a Runge-Kutta method to break down the problem and iteratively calculate the solution. However, it may not be suitable for all types of IVPs and other methods may be more effective for certain cases.
  • #1
mooberrymarz
53
0
Hi! I have :eek: hand in an assigment in like four hours and part of it involves solving a IVP. We have to use the built in function ODE45. the system of equations are as follows.

x'(t)=-axy
y'(t)=axy-by
z'(t)=by

Use step length 1 and solve the ivp numerically for the following values of a,b
a=0.00001, b=0.25
a=0.0002, b=0.10

I know its easy but i can't get it to work. Please help me. :redface:
 
Physics news on Phys.org
  • #2
Can you post your code so far, please?
 
  • #3


Hi there,

First of all, don't worry, solving IVPs with ODE45 is a common task and with a little bit of practice, you'll be able to do it easily. Let's break down the steps to solve this problem.

Step 1: Define the ODE function

To use ODE45, we need to define the system of equations in a function. Let's call it "systemODE" and define it as follows:

function dydt = systemODE(t,y,a,b)
dydt = [a*y(1)*y(2), a*y(1)*y(2)-b*y(2), b*y(2)];

Step 2: Define the initial conditions

Next, we need to define the initial conditions for x, y, and z. Let's call them x0, y0, and z0 respectively.

x0 = 1;
y0 = 1;
z0 = 1;

Step 3: Set the time span and solve the IVP

Now, we need to set the time span and use ODE45 to solve the IVP. For a step length of 1, we can define the time span as follows:

tspan = [0, 1];

And then use ODE45 to solve the IVP for the given values of a and b as follows:

[t,y] = ode45(@(t,y) systemODE(t,y,a,b), tspan, [x0,y0,z0]);

Note: The @(t,y) in the above code is called an anonymous function and allows us to pass the values of t and y to the systemODE function.

Step 4: Plot the results

Finally, we can plot the results for x, y, and z using the following code:

plot(t,y(:,1),'r',t,y(:,2),'b',t,y(:,3),'g')
legend('x','y','z')
xlabel('t')
ylabel('x, y, z')

Now, let's plug in the values of a=0.00001, b=0.25 and a=0.0002, b=0.10 in the above code and see what we get. Here are the plots for both cases:

a=0.00001, b=0.25:
![image](https://user-images.githubusercontent.com/84361783/136834602-3f7eb2f8-4
 

1. How do you solve an IVP (initial value problem) using ODE45?

To solve an IVP using ODE45, you first need to define the differential equation and initial conditions. Then, you can use the ODE45 function in MATLAB or other software to numerically solve the differential equation and obtain a solution for the given initial conditions.

2. What are the values of a and b in the given IVP?

The values of a and b in the given IVP (a=0.00001, b=0.25 & a=0.0002, b=0.10) represent the coefficients of the differential equation. A represents the rate of change of the dependent variable, while b represents the constant term.

3. What is the significance of the values of a and b in the IVP?

The values of a and b in the IVP determine the behavior of the solution to the differential equation. A larger value of a signifies a faster rate of change, while a larger value of b indicates a stronger effect of the constant term on the solution.

4. How does ODE45 work in solving IVPs?

ODE45 uses a Runge-Kutta method to numerically solve the differential equation, starting from the given initial conditions. It breaks down the problem into smaller steps and iteratively calculates the solution at each step until a final solution is obtained.

5. Can ODE45 be used for all types of IVPs?

No, ODE45 is specifically designed for solving first-order ordinary differential equations. It may not be suitable for higher-order differential equations or systems of differential equations. Other methods, such as ODE23 or ODE113, may be more effective for certain types of IVPs.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
765
  • Introductory Physics Homework Help
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
0
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Introductory Physics Homework Help
Replies
2
Views
665
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
10K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
32K
  • Introductory Physics Homework Help
Replies
3
Views
589
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
7K
Back
Top