To define a constant, use a single equals sign:
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
Once defined, you can use the function
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
More complicated functions
Notice the equal ":=" sign that implies a delay calculation, and the underscore "_" sign that implies the independent variable.
Plot a function
Make sure that you do not mix the "( ), { } and [ ]" brackets. MATHEMATICA gets confused and it will send you an error message.
Find the zeros
Notices "==" logical sign that determines equality.
We can take the derivative of the function:
or
We have to tell MATHEMATICA to erase from memory defined constants or functions
or
Integration
in1=NIntegrate [ Sin [Sin[x]], {x, 0, Pi} ]
or
Relevant integrals in the case of the particle in the box. Here we use regular integration and also we considered a useful mathematical technique to find integrals.
We need to consider some substitutions using the "/." command
Notice that "/. tells MATHEMATICA to substitute and that the actual substitution is given by the arrow command ->"and multiple substitution are enclosed by a curly bracket and separated by commas.
Finally consider the following integral:
A relevant application in Quantum Mechanics
First we consider the integral of the square of the wave function
Since α is a positive real number the integral is equal to unity. Thus we say that psiH10 is normalized.
Now we take the derivative of the wave function
The average <> is proportional by the following integral:
Problem 1. - Find the value of <> .