       Plotting a function of an interpolated function

• To: mathgroup at smc.vnet.net
• Subject: [mg52925] Plotting a function of an interpolated function
• From: Adam Getchell <agetchell at physics.ucdavis.edu>
• Date: Fri, 17 Dec 2004 05:18:38 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```I've solved a function using NDSolve, expressed it as a pure function,
and plotted it in the attached notebook. Now I'd like to define other
functions in terms of this pure function and plot them. I haven't seen
this come up in the archives, hence the post here.

If phi is my interpolating function and W is my newly defined function, ie:

In:=
V = Function[x, (1/2)*m^2*
x^2];
\[Rho] = Function[x,
D[x, t]^2/2 + V[x]];
H = Function[x, Sqrt[
((8*Pi*G)/3)*\[Rho][x]]];

In:=
V[\[Phi][t]]
Derivative[V][\[Phi][t]]
\[Rho][\[Phi][t]]
H[\[Phi][t]]
Out=
(1/2)*m^2*\[Phi][t]^2
Out=
m^2*\[Phi][t]
Out=
(1/2)*m^2*\[Phi][t]^2 +
(1/2)*Derivative[\[Phi]][t]^
2
Out=
2*Sqrt[(2*Pi)/3]*
Sqrt[G*((1/2)*m^2*
\[Phi][t]^2 + (1/2)*
Derivative[\[Phi]][t]^
2)]

In:=
Inflaton = Derivative[\[Phi]][
t] + 3*H[\[Phi][t]]*
Derivative[\[Phi]][t] +
Derivative[V][\[Phi][t]]
Out=
\[Phi][t]*m^2 + Derivative[
\[Phi]][t] + 2*Sqrt[6*Pi]*
Derivative[\[Phi]][t]*
Sqrt[G*((1/2)*m^2*
\[Phi][t]^2 + (1/2)*
Derivative[\[Phi]][t]^
2)]

In:=
m = 10^16;
mp = 1.2211*10^19;
G = mp^(-2);

In:=
\[Phi] = \[Phi][t] /. First[
NDSolve[{Inflaton == 0,
Derivative[\[Phi]][
0] == 0, \[Phi] ==
1}, \[Phi][t], {t, 0,
100/m}, MaxSteps ->
10^6]]
Out=
InterpolatingFunction[][t]

In:=
P = Function[x, D[x, t]^2/2 -
V[x]]
\[Rho]
W = Function[x, P[x]/\[Rho][x]]
\[Phi]
Out=
Function[x, (1/2)*D[x, t]^2 -
V[x]]
Out=
Function[x, (1/2)*D[x, t]^2 +
V[x]]
Out=
Function[x, P[x]/\[Rho][x]]
Out=
InterpolatingFunction[][t]

Then this doesn't work:

In:=
TestPlot = Plot[W[\[Phi]],
{t, 0, 100/m}];

I've tried a symbolic solution to avoid the interpolating function, but
my workstation hasn't produced one yet.

I'm reading the Functions notebook from "Essential Mathematica for
Students of Science", but as far as I can tell I should be using pure
functions of the interpolating function.

Any pointers appreciated, as always. Thanks for help in the past,
especially Dr. Bob.