Re: Plot Complex Interpol .Func.
- To: mathgroup at smc.vnet.net
- Subject: [mg9589] Re: [mg9561] Plot Complex Interpol .Func.
- From: jpk at max.mpae.gwdg.de
- Date: Thu, 13 Nov 1997 23:24:01 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Hi Debbie,
You had several errors in the line:
ParametricPlot[f /. soln[[1]], {a, 0.00005, 1}]
a) f /. soln[[1]] will evaluate to an InterpolatingFunction[]
without an argument, so Your [a] is missed. The correct form is
f[a] /. soln[[1]]
b) Attributes[ParametricPlot] has the attribute HoldAll. So You need
Evaluate[f[a] /. soln[[1]]]
c) Your function is complex valued and I don't know what type of plot
You have in mind when You say ParametricPlot[]. A curve in the plane
?
For that type of plot You must say that the x-coordinate in plane
is given by Re[f[a]] and the y-coordinate by Im[f[a]]. So
ParametricPlot[
Evaluate[
{Re[#],Im[#]} & @ (
f[a] /. soln[[1]]
)
],
{a, 0.00005, 0.785348}]
will create that type of graphics.
More common in quantum mechanics is to draw the absolute Value of
the
wavefunction and/or real and imaginary part. This is done by the
Plot[]
function
Plot[
Evaluate[
{Re[#],Im[#],Abs[#]} & @(
f[a] /. soln[[1]]
)
],
{a, 0.00005, 0.785348}
]
Hope that helps
Jens
> From jleddon at cyberramp.net Thu Nov 13 10:50:56 1997
> Date: Thu, 13 Nov 1997 01:40:23 -0500
> From: Jim Leddon <jleddon at cyberramp.net>
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
> Subject: [mg9589] [mg9561] Plot Complex Interpol .Func.
>
> I am trying to solve the schrodinger equation as follows and I want to
> be able to plot the resulting interpolating function (which should
> contain complex values).
>
> In[6]:=Schrodinger[V_,A_] := D[f[a],{a,2}] + (V - A)f[a]]
>
> In[7]:= R[x_,y_] := x + I y
>
> In[8]:= V[R_,a_] :=
> R[1,2](-1/(Cos[a] - Sin[a]) -1/Sin[a] + 1/Cos[a])
>
> In[9]:= eq1 = 0 == Schrodinger[V[R,a],-900] Out[9]= 0==f[a] (900 + (1 +
> 2 I) (-Csc[a] + Sec[a] -
> 1/(Cos[a] - Sin[a])) + f''[a]
>
> In[10]:= soln =NDSolve[{eq1, f[0.00005] ==0, f'[0.00005] ==.5},
> f, {a, 0.00005, 0.785348}][[1]] Out[10]=
> {f->InterpolatingFunction[{{0.00005,0.785348}},"<>"]}
>
> In[11]:= ParametricPlot[f /. soln[[1]], {a, 0.00005, 1}]
>
> The error message I got at this point was:
> function f/. soln[[1]] cannot be compiled; plotting will proceed.. f/.
> soln[[1]] does not evaluate to a real pair of numbers
> at a =0.000050041664...., etc.
>
> What went wrong ? How can I plot the interpolating function?
>
> Thanks in advance for your help!
> Debbie Leddon
> jleddon at cyberramp.net
>
>