Fundamental Commands
To define a constant, use a single equals sign:
You can include text by using Command 7
Once defined, you can use the constant anywhere you want:
To avoid problems, erase from memory the assigned value to a
When defining a function, you need to remember two important things:
Use an underscore character after each argument name on the left-hand side (but not on the right-hand side)
Use a := in the middle
To check your definition use the question mark before the name of a function
Once defined, you can use the function
?f
|
You need to be carefull with User define functions.
For example we want to change the function
f[x_]:= x^2
?f
|
Notice that the function was subtituted by the new definition. But now you change your mind and redefine the function
f[y_Integer] := y^3
?f
|
Notice the two different definitions saved by MATHEMATICA. One for real numbers and one for integers
{f[2],f[2.]}
Again, you change the definition of "f"
f[x_] := Sqrt[x]
?f
|
f[4]
In order to avoid problems use Clear
Clear[f]
f[x_] := Sqrt[x]
?f
|
The square root of 10
We need to tell MATHEMATICA that we need a numerical value. We can use a decimal point
or we can use the N function and ask for 50 digits:
N[ Sqrt[10], 50 ]
3^100
N[%]
The command % refers to the previous output
In the following expression I stand for
(3 + 4 I) ^10
Created by Mathematica (September 7, 2006) | ![]() |