Having a problem with solving a second order ODE equation using Matlab

In summary, the conversation discusses a complex second-order ODE equation that cannot be solved analytically and is being attempted to be solved using the finite difference method in Matlab.
  • #1
kubekas
10
0
I am having a problem coding a Matlab code that solves a second ODE equation which I give below:

x^3*(1-2*x*M)d^2J(x)/dx^2+2*(2*x^2+i*nu*x-7*x^3*M)*dJ(x)/dx
-2*(2*x+8*M*x^2+i*nu)*J(x)=0.

where

M = 1 (Mass of a black hole),
nu = 0.74734+0.17792*i,
J is a function of x,
i represents a complex number.

This equation is very complex to solve. Fistly I tried the Matlab shooting
method and it did not work because this equation is singular at the boundries i.e
0 and 1. Now I am trying to solve it using Matlab Finite Difference Method. I must point out that this problem has no analytic solution and we hope that it can be solved numerically.

Can anyone out there help me with this problem.
Thanks
Amos
 
Physics news on Phys.org
  • #2
The finite difference method is most likely the best option for solving this equation. To use the finite difference method, you need to discretize the equation by replacing the derivatives with finite differences. This is done by approximating the derivatives using values of the function at nearby points. The finite difference weights will depend on the number of points used and the spacing between the points. Once the equation is discretized, it can be solved using linear algebra methods such as a matrix inversion. For more information on how to implement the finite difference method, please refer to the documentation provided by Matlab.
 
  • #3


Hello Amos,

Thank you for reaching out for help with your problem. Solving second order ODE equations using Matlab can be tricky, especially when they involve complex numbers and have no analytical solution. However, there are a few steps you can follow to help you code a successful solution using Matlab.

Firstly, make sure you have a good understanding of the problem and the equation you are trying to solve. This will help you in choosing the appropriate method and approach for solving it. In this case, it seems like the Finite Difference Method would be a good approach to use.

Next, try breaking down the equation into smaller parts and solving them separately. This will make the coding process easier and more manageable. You can also try using symbolic variables in Matlab to represent the complex parts of the equation.

Another helpful tip is to use built-in Matlab functions and tools, such as the "ode45" function or the "dsolve" command, to help solve the equation. These functions are specifically designed for solving ODE equations and can save you a lot of time and effort.

Lastly, don't be afraid to reach out to online forums or communities for help. There are many experienced Matlab users who are willing to assist and provide guidance on coding solutions for complex equations.

I hope these tips will help you in successfully solving your equation using Matlab. Good luck!
 

1. How do I define the second order ODE equation in Matlab?

In Matlab, you can define the second order ODE equation using the odefun function. This function takes in the independent variable, the dependent variable, and the second derivative of the dependent variable as inputs. You can also specify any additional parameters or variables needed for the equation.

2. Why am I getting an error when trying to solve my second order ODE equation in Matlab?

There could be several reasons for this error. Some common reasons include not properly defining the equation, not specifying initial conditions, or using incorrect syntax. Make sure to go through your code carefully and check for any mistakes. You can also refer to the Matlab documentation for troubleshooting tips.

3. How do I specify initial conditions for my second order ODE equation in Matlab?

In Matlab, you can specify initial conditions for your second order ODE equation using the initials function. This function takes in the initial value of the dependent variable and its first derivative at the starting point of the solution. You can also specify additional initial conditions if needed.

4. Can I plot the solution to my second order ODE equation in Matlab?

Yes, you can plot the solution to your second order ODE equation in Matlab using the ode45 function. This function returns the solution as a vector, which you can then plot using the plot function. You can also customize the plot by adding labels, titles, and adjusting the axes.

5. How do I check the accuracy of my solution to a second order ODE equation in Matlab?

To check the accuracy of your solution, you can compare it to a known analytical solution or use the odeget function in Matlab. This function returns the error estimate for each point in the solution, which you can then analyze to determine the accuracy of your solution. It is also a good practice to vary the step size and see how it affects the accuracy of the solution.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
485
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Replies
3
Views
1K
  • Differential Equations
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • Differential Equations
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top