Physics[Parameters] - set symbols to work as constant parameters
Calling Sequence
Parameters( )
Parameters(a, b, ...)
Parameters
a, b, ...
-
names
Description
The Parameters command allows you to define the parameters of a theory in such a way that no functionality can be attached to them. For example, if m is defined as a parameter through Parameters(m), then m⁡t returns m, without any functionality.
To know which names are defined as parameters at some point in a session, call Parameters() without any arguments; the result is a set with the required information.
The cancellation of a parameter definition can be done by unassigning the variable. The unassignment is automatically taken into account in all subsequent calculations, as well as in any Parameters() requests for information.
Examples
with⁡Physics:
Setup⁡mathematicalnotation=true
mathematicalnotation=true
F≔k⁢x
Notice that functionality has been attached to k automatically.
F⁡t
k⁡t⁢x⁡t
diff⁡,t
k.⁡t⁢x⁡t+k⁡t⁢x.⁡t
In a model where k is a constant, the above, withⅆkⅆt, is undesired. You would like to be able to define F in the simple way it has been done, and then have F⁡t return a result with k, not k⁡t. This situation is addressed by the Parameters command. For example:
Parameters⁡k
k
In this way, instead of the undesired result k⁡t, you now have the constant k defined as a parameter, with no functionality attached.
k⁢x⁡t
k⁢x.⁡t
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 m, and k is a constant parametrizing the restoring force. The Energy (Hamiltonian) in terms of the momentum p and position q is given by:
Parameters⁡m,k
k,m
H≔p22⁢m+12⁢k⁢q2
H≔p22⁢m+k⁢q22
where in the above, p and q represent functions of time, while m and k represent constant parameters. Because m and k have been set by the Parameters command, no functionality is attached to them.
H⁡t
p⁡t22⁢m+k⁢q⁡t22
Now you can compute the Hamilton equations directly.
eq1≔diff⁡q⁡t,t=diff⁡H⁡t,p⁡t
eq1≔q.⁡t=p⁡tm
eq2≔diff⁡p⁡t,t=−diff⁡H⁡t,q⁡t
eq2≔p.⁡t=−k⁢q⁡t
It is now easy to see that the Energy of this oscillator is a constant; that is, it does not depend on t: differentiate the Energy (the Hamiltonian H), and introduce the equations of motion that were previously derived.
diff⁡H⁡t,t
p⁡t⁢p.⁡tm+k⁢q⁡t⁢q.⁡t
eval⁡,eq1,eq2
0
The same computation can be performed without using Parameters. Define H 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.
Parameters⁡
To unset the symbol k as a parameter, it suffices to unassign it.
k≔k
Now k is not in the list of parameters, and it depends on t in the function H.
m
p⁡t22⁢m+k⁡t⁢q⁡t22
See Also
Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists, Physics[*], Physics[diff]
Download Help Document