>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
Notice that functionality has been attached to automatically.
>
|
|
| (3) |
>
|
|
| (4) |
In a model where is a constant, the above, with, is undesired. You would like to be able to define in the simple way it has been done, and then have return a result with , not . This situation is addressed by the Parameters command. For example:
>
|
|
| (5) |
In this way, instead of the undesired result , you now have the constant defined as a parameter, with no functionality attached.
>
|
|
| (6) |
>
|
|
| (7) |
A typical use for the Parameters command is when computing equations of motion departing from a Lagrangian or a Hamiltonian (the Energy). Consider a harmonic oscillator of mass , and is a constant parametrizing the restoring force. The Energy (Hamiltonian) in terms of the momentum and position is given by:
>
|
|
| (8) |
>
|
|
| (9) |
where in the above, and represent functions of time, while and represent constant parameters. Because and have been set by the Parameters command, no functionality is attached to them.
>
|
|
| (10) |
Now you can compute the Hamilton equations directly.
>
|
|
| (11) |
>
|
|
| (12) |
It is now easy to see that the Energy of this oscillator is a constant; that is, it does not depend on : differentiate the Energy (the Hamiltonian ), and introduce the equations of motion that were previously derived.
>
|
|
| (13) |
>
|
|
| (14) |
The same computation can be performed without using Parameters. Define as a mapping, then you must use more complicated syntax to specify the parameters. See the last example in the help page for D for a demonstration of this method.
To query about the objects defined as parameters at any moment, enter the Parameters command with no arguments.
>
|
|
| (15) |
To unset the symbol as a parameter, it suffices to unassign it.
>
|
|
| (16) |
Now is not in the list of parameters, and it depends on in the function .
>
|
|
| (17) |
>
|
|
| (18) |
>
|
|