MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

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[291]:=
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[294]:=
V[\[Phi][t]]
Derivative[1][V][\[Phi][t]]
\[Rho][\[Phi][t]]
H[\[Phi][t]]
Out[294]=
(1/2)*m^2*\[Phi][t]^2
Out[295]=
m^2*\[Phi][t]
Out[296]=
(1/2)*m^2*\[Phi][t]^2 +
  (1/2)*Derivative[1][\[Phi]][t]^
    2
Out[297]=
2*Sqrt[(2*Pi)/3]*
  Sqrt[G*((1/2)*m^2*
      \[Phi][t]^2 + (1/2)*
      Derivative[1][\[Phi]][t]^
       2)]

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

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

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

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

Then this doesn't work:

In[307]:=
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.

--Adam




  • Prev by Date: Bug in 5.1 FE?
  • Next by Date: Re: Re: shuffling (randomizing) a series
  • Previous by thread: Bug in 5.1 FE?
  • Next by thread: Re: Plotting a function of an interpolated function