Using ./ - having trouble understanding why it isn't more like a 'map' function
- To: mathgroup at smc.vnet.net
- Subject: [mg124854] Using ./ - having trouble understanding why it isn't more like a 'map' function
- From: trayres <trayres at gmail.com>
- Date: Thu, 9 Feb 2012 05:41:51 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hi all-
I'm searching through the help for NDSolve, and I run into the following:
Plot[Evaluate[y[x] /. s], {x, 0, 30}, PlotRange -> All]
Also, in the following tutorial on DSolve Plotting:
http://reference.wolfram.com/mathematica/tutorial/DSolvePlottingTheSolution.html
the following occurs:
Plot[Evaluate[y[x] /. sol /. {C[1] -> 1}], {x, -7, 7},
PlotRange -> All]
The trouble is, in the above tutorial I don't understand why you use
y[x] /. sol at all.
Shouldn't this just be replacing y[x] with sol?
If I run 'sol' directly, I get
{{y -> Function[{x},
E^(-(x^2/2)) C[1] +
1/2 E^(-(x^2/2)) Sqrt[\[Pi]/
10] (Sqrt[1 + 2 I] Erfi[Sqrt[1/2 - I] x] +
Sqrt[1 - 2 I] Erfi[Sqrt[1/2 + I] x])]}}
if I run y[x]/.sol, I get:
{E^(-(x^2/2)) C[1] +
1/2 E^(-(x^2/2)) Sqrt[\[Pi]/
10] (Sqrt[1 + 2 I] Erfi[Sqrt[1/2 - I] x] +
Sqrt[1 - 2 I] Erfi[Sqrt[1/2 + I] x])}
Then later, if I see what y[x] is now equal to, I get the same thing
as y[x]/.sol:
{E^(-(x^2/2)) C[1] +
1/2 E^(-(x^2/2)) Sqrt[\[Pi]/
10] (Sqrt[1 + 2 I] Erfi[Sqrt[1/2 - I] x] +
Sqrt[1 - 2 I] Erfi[Sqrt[1/2 + I] x])}
This means that /. isn't replacing in an instance, it's actually
mapping 'f' (the label for the function) with variable 'x' to the
appropriate results of 'sol'.
I don't get why Map isn't used, and I don't get what this /. is really
doing. If someone could give me a better idea, I'd really appreciate
it.
Thanks,
-Travis Ayres