Enter A = B B = C A Result BIn the above example the symbol A evaluates to B and then stops. B is not converted to C. However, the eval function can be used to do another evaluation.
Enter eval(A) Result CHere A evaluates to B then the eval function evaluates B and returns C.
Although it is rarely needed, the eval function can be applied multiple times.
Enter C = D eval(eval(A)) Result DHere is a more practical example of when to use eval. Suppose a general electromagnetic field tensor is defined.
Enter F = ((0,EX,EY,EZ),(EX,0,BZ,-BY),(EY,-BZ,0,BX),(EZ,BY,-BX,0))Next, the components of the tensor are defined.
Enter EX = sin(z - t) EY = 0 EZ = 0 BX = 0 BY = sin(z - t) BZ = 0Although the components have been defined, the symbol F has not changed.
Enter F Result 0 EX EY EZ EX 0 BZ -BY EY -BZ 0 BX EZ BY -BX 0The components of F can be updated by using eval.
Enter F = eval(F) F Result 0 -sin(t - z) 0 0 -sin(t - z) 0 0 sin(t - z) 0 0 0 0 0 -sin(t - z) 0 0So, a general rule of thumb is to use eval when the definition of a symbol changes.