- #1

- 2,008

- 111

I used NDSolve to find the solution to a differential equation. I then plotted the solution in mathematica. However, I would like to be able to plot this in LaTex, specifically in TikZ. Can anyone help me here?

Thanks so much!

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Mathematica
- Thread starter joshmccraney
- Start date

- #1

- 2,008

- 111

I used NDSolve to find the solution to a differential equation. I then plotted the solution in mathematica. However, I would like to be able to plot this in LaTex, specifically in TikZ. Can anyone help me here?

Thanks so much!

- #2

Simon Bridge

Science Advisor

Homework Helper

- 17,874

- 1,655

- #3

- 31,851

- 8,712

The output of NDSolve is an InterpolatingFunction object. If the InterpolatingFunction object is named "f" then "f[[2]]" will produce a table containing the interpolation points.

I used NDSolve to find the solution to a differential equation. I then plotted the solution in mathematica. However, I would like to be able to plot this in LaTex, specifically in TikZ. Can anyone help me here?

Thanks so much!

- #4

- 2,008

- 111

Hi Dale!The output of NDSolve is an InterpolatingFunction object. If the InterpolatingFunction object is named "f" then "f[[2]]" will produce a table containing the interpolation points.

I have the following code

Code:

```
a=0;
s = NDSolve[{y[x] y''[x] + 2 (y'[x])^2 + x y'[x] - 2 a/(1 + a) y[x] ==
0, y[1] == .0000000000001, y'[1] == -1/2}, y, {x, 0, 3/2}];
s[[2]]
```

Thanks so much for your help!

- #5

- 954

- 117

Code:

`Table[{x, Evaluate[y[x] /. s][[1]]}, {x, 0, 3/2, stepsize}]`

Code:

`Table[{x, s[[1, 1, 2]][x]}, {x, 0, 3/2, stepsize}]`

The interpolating function itself is nested within [[1,1,2]] of the NDSolve output.

- #6

- 2,008

- 111

- #7

- 2,008

- 111

- #8

- 31,851

- 8,712

I like Fightfish's approach better. It turns out that my approach is not as simple as I has remembered.then I receive the response "Part 2 of..." followed by a long error message. Am I doing something wrong?

Thanks so much for your help!

Share: