Message Boards Message Boards

Get C Code of InverseFunction and Eliptical Integral of First Kind?

Posted 5 years ago

Hello;

I have the below output for a nonlinear differential equation. I want to c-code the answer (in PIC-C). But I dont understand what the answer is mathematically. Can you help?

Here is the code:

DSolve[{-x^2 + (0.231486 - 0.2290576*cos[y[x]]) Derivative[1][y][
      x]^2 == 0, y[0] == Q1, y'[0] == 0}, y[x], x]

Nonlinear Differential Equation

POSTED BY: Caner Beykont
7 Replies

Numerical ODE solving is a whole topic on its own. It is covered in many books. Take a look e.g. at Numerical Recipes, which has a very gentle introduction, if I recall correctly.

POSTED BY: Szabolcs Horvát

You will be better off solving this ODE numerically in C. I believe InverseFunction will also use numerical methods to compute results.

POSTED BY: Szabolcs Horvát
Posted 5 years ago

Can you give me an example? Which numerical method would be the best alternative for coding in C?

POSTED BY: Caner Beykont

If you want something quick and clear, I highly recommend you to checkout Dr. Shen's videos on

Pick the control points from Mathematica's InterpolationFunction (assign x to some values and evaluate them) and use the formulae presented in the videos above.

POSTED BY: Shenghui Yang
Posted 5 years ago

Hello Shengui;

Thanks for this suggestion. In the output it gives me an interpolating function but i dont see what the function is? What are the coefficients and degree etc? Interpolating functions seem embedded inside mathematica so its not possible to see what the function is. Therefore i cannot code it in c environment. Anyother suggestions?

POSTED BY: Caner Beykont

Try

sol = NDSolve[{-x^2 + (0.231486 - 0.2290576*Cos[y[x]]) Derivative[1][y][x]^2 == 0, y'[0] == 0}, y, {x, 0, 2}]

sol

POSTED BY: Shenghui Yang
Posted 5 years ago

Hello Shengui;

Thanks for this suggestion. In the output it gives me an interpolating function but i dont see what the function is? What are the coefficients and degree etc? Interpolating functions seem embedded inside mathematica so its not possible to see what the function is. Therefore i cannot code it in c environment. Anyother suggestions?

POSTED BY: Caner Beykont
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract