A question about Manipulate command in Mathematica

  • Thread starter Thread starter kindlychung
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion revolves around the behavior of the Manipulate command in Mathematica when using variable definitions. It highlights that defining a function with a variable, such as f[x_] := E^(n*x), does not allow Manipulate to recognize the variable n correctly, leading to errors. In contrast, using Subscript[f, n_][x_] allows Manipulate to function properly because it treats n as a local variable. The issue arises because the n in the function definition is not the same as the n in Manipulate, which creates a conflict. To resolve this, users should ensure that the variable is passed correctly to the function, such as by defining it as fn[x] or f[n, x].
kindlychung
Messages
10
Reaction score
0
This works:
Code:
Manipulate[Plot[E^(n*x), {x, -10, 10}], {n, 1, 10}]

This doesn't:
Code:
f[x_] := E^(n*x);
Manipulate[Plot[f[x], {x, 1, 10}], {n, 1, 10}]

Why?
(I used Mathematica 7.0)
 
Mathematics news on Phys.org
Then again, this does:
Code:
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
Code:
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.
 
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Back
Top