Solve 3 Coupled ODEs with NDSolve - Error Fix & Alternatives

In summary, the conversation discusses the use of NDSolve to solve 3 coupled first order ODE's. The code used encounters an error of "Infinite expression 1/0.^2 encountered" and alternative methods of solving the ODE's are discussed. The code is for Mathematica and the speaker used a different program to solve the equations.
  • #1
bayan
203
0
Hi, I need to solve 3 coupled first order ODE's using NDSolve (numerical solution).

This is the code I have used ;

NDSolve[{u'[t] == ((1 - (u[t]/t^2))/(-3 - (u[t]/t^2) - (v[t]/t^2))),
v'[t] == (((u[t]/t^2) - (v[t]/t^2))/(-3 - (u[t]/t^2) - (v[t]/t^2))),
w'[t] == (v[t])/(-3 t^2 - (u[t]) - (v[t])),
u[0] == 0., v[0] == 0., w[0] == 0.}, {u, v, w}, {t, 0.1, 1}]

where u,v and w are functions of t and at t=0, u=v=w=0. However I am getting the following error "Infinite expression 1/0.^2 encountered", but I can't see where the division by zero occurs. Originally t was from 0 to 1, but I tried making it from 0.1 to 1 to ensure no division by zero's were taking place.

Any ideas on how to fix the code? or an alternative way of solving these ode?

Regards
 
Physics news on Phys.org
  • #2
I don't see anything wrong, sorry. Even tried to solve:
Code:
u as realvariable (initial, 0)  ;
v as realvariable (initial, 0)  ;
w as realvariable (initial, 0)  ;

eps as realparameter (1e-5)  ;
t as realvariable (eps)  ;

t = time + eps  ;
 
$u = ((1 - (u/t^2))/(-3 - (u/t^2) - (v/t^2)))  ;
$v = (((u/t^2) - (v/t^2))/(-3 - (u/t^2) - (v/t^2)))  ;
$w = (v)/(-3*t^2 - (u) - (v))  ;
(the $ stands for a time derivative in this simulator)
and that worked:
uvw.jpg
 
  • #3
thanks for your reply.

Did NDSolve with the options given work for you? or do you recommend the use of another software to solve those odes?

btw is that code for mathematica?

Regards
 
  • #4
I don't know where NDSolve lives ? Ah, I googlesee: in MatLab. Don't have that at my disposition.

I abused a chemical flowsheeting program as equation solver, just to see if I would get the same problem as you. Apparently not.
 

Related to Solve 3 Coupled ODEs with NDSolve - Error Fix & Alternatives

1. What is NDSolve and how does it work?

NDSolve is a Mathematica function that is used to numerically solve systems of ordinary differential equations (ODEs). It uses a variety of numerical methods, such as Runge-Kutta and finite difference methods, to approximate the solution to the ODEs. NDSolve also allows for the inclusion of boundary conditions, initial conditions, and other specifications to customize the solution.

2. How can I fix errors when using NDSolve to solve coupled ODEs?

One way to fix errors when using NDSolve is to carefully check your syntax and make sure all input variables and functions are properly defined. You can also try changing the numerical method or increasing the precision of the solution. Additionally, check if your system of ODEs is well-posed and has a unique solution.

3. Are there any alternatives to using NDSolve for solving coupled ODEs?

Yes, there are several alternatives to NDSolve for solving coupled ODEs. Some common alternatives include using other numerical software, such as MATLAB or Python, or implementing your own numerical methods. You can also try using different software packages within Mathematica, such as DSolve or ParametricNDSolve.

4. What is the difference between a coupled ODE and a single ODE?

A single ODE is an equation that describes the time evolution of a single variable, while a coupled ODE is a set of equations that describe the interactions and time evolution of multiple variables. Coupled ODEs can be more complex and require different numerical methods to solve compared to single ODEs.

5. Can NDSolve be used for solving systems of partial differential equations (PDEs)?

No, NDSolve is designed specifically for solving systems of ordinary differential equations (ODEs). For solving PDEs, you can use other Mathematica functions such as NDSolveValue or FiniteElementMethod, or use other software packages that specialize in solving PDEs.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
158
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
885
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
282
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
41
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
947
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Back
Top