kindlychung
Oct3-09, 02:12 AM
This works:
Manipulate[Plot[E^(n*x), {x, -10, 10}], {n, 1, 10}]
This doesn't:
f[x_] := E^(n*x);
Manipulate[Plot[f[x], {x, 1, 10}], {n, 1, 10}]
Why?
(I used Mathematica 7.0)
CompuChip
Oct3-09, 03:20 AM
Then again, this does:
Subscript[f, n_][x_] := E^(n*x);
Manipulate[Plot[Subscript[f, n][x], {x, 1, 10}], {n, 1, 10}]
Apparently the n in the definition of f[x] is not the same n as that in Manipulate. When you execute
Subscript[f, n_][x_] := E^(n*x);
Manipulate[Plot[Subscript[f, n][x], {x, 1, 10}] // Hold, {n, 1, 10}]
you will see that the running n is a temporary variable (FE`n$$27, or something like that) different from the Global`n that f[x] uses. When you pass n to f[x] as well, by defining fn[x] or f[n, x], it works.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.