How to solve ODE for independent function

In summary, your problem is just numerically differentiating the known function i(t)? That can be tricky- just reducing the step size in the "difference quotient" can be unstable. You might want to look at the "five-point stencil" given here:Thanks HallsofIvy!
  • #1
kaushel
2
0
Hello,

I need to solve numerically an equation of the form

v(t) = k1*z(t)*w(t)-k2*i(t)-k3*di(t)/dt

The issue is that rungekutta methods are useful for solving

di(t)/dt = 1/k3 * [ k1*z(t)*w(t)-k2*i(t)-k3*-v(t) ]

but I need to solve for v(t)

What I did was:

v (t) = k1*z(t)*w(t)-k2*i(t)-k3*[i(t)-i(t-1)]/h

But is not a good approximation because the step size h cannot be small enough. I need a more sophisticated method than directly applying the difference quotient as I did.
Thanks a lot!
 
Physics news on Phys.org
  • #2
So your problem is just numerically differentiating the known function i(t)? That can be tricky- just reducing the step size in the "difference quotient" can be unstable. You might want to look at the "five-point stencil" given here:
http://en.wikipedia.org/wiki/Numerical_differentiation
 
  • #3
Thanks HallsofIvy!

I'll give you a little bit more of insight about my problem.
The equations are for an electric generator in stand alone operation, the actual equation is
vd=Lq*iq*wr-Rs*id-Ld*did/dt (I wrote a different one for clarity)
where Lq, Ld, and Rs are constant parameters and vd, iq, wr, and id are functions of time.

My first approach of course was did/dt = (id(t)-id(t-h))/h, then I improved by a higher order approximation of the form did/dt = (3*id(t) - 4*id(t-h) + id(t-2h))/(2*h)
But still I have the same problem that did/dt oscillates too much and get's unstable with h less than 0.002, which is too big for me.
The variables are declare as double in the C code, to have a better precision.

I do my derivative calculation backwards because I can't use future values. I'm using this equation to produce values of vd in a real-time application. So, I obtain say vd(t1) and with that value I calculate id(t2),iq(t2), and w(t2). With the new values I calculate vd(t2). So I can save the history of the system and use it to calculate the derivative, but I don't have future values.

Thanks again for your reply!
 

1. How do I determine the order of an ODE?

The order of an ODE is determined by the highest derivative present in the equation. For example, if the equation contains a second derivative, it is a second-order ODE.

2. What is the general approach to solving an ODE for an independent function?

The general approach is to first classify the ODE as either linear or non-linear, and then use various methods such as separation of variables, substitution, or series solutions to find an exact or approximate solution.

3. Can I use a calculator to solve ODEs for independent functions?

While some calculators may have built-in functions for solving basic ODEs, it is recommended to use specialized software or programming languages such as MATLAB or Python for more complex ODEs.

4. How do I check if my solution to an ODE is correct?

You can check your solution by plugging it back into the original ODE and verifying that it satisfies the equation. In addition, you can plot the solution and compare it to the behavior of the system described by the ODE.

5. Are there any tips for solving ODEs more efficiently?

Some tips for solving ODEs more efficiently include understanding the properties of the ODE (such as linearity or separability), trying different methods if one approach is not working, and practicing with a variety of examples to improve problem-solving skills.

Similar threads

  • Differential Equations
Replies
3
Views
1K
  • Programming and Computer Science
2
Replies
36
Views
3K
  • Differential Equations
Replies
8
Views
2K
  • Differential Equations
Replies
6
Views
1K
Replies
2
Views
3K
  • Calculus and Beyond Homework Help
Replies
12
Views
1K
Replies
5
Views
3K
  • Programming and Computer Science
Replies
15
Views
2K
  • Differential Equations
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
Back
Top