More complicated calculations

f[x_] := x^6 - 3 x^5 - 41 x^4 + 87 x^3 + 400 x^2 - 444 x - 720

Notice the equal ":=" sign that implies a delay calculation, and the underscore "_" sign that implies the independent variable.

Plot a function

Plot[f[x], {x, -10, 10}] ;

[Graphics:../HTMLFiles/MATH5_TUT1_64.gif]

Make sure that you do not mix the "( ), { } and [ ]" brackets.  MATHEMATICA gets confused and it will send you an error message.

Find the zeros

NSolve[f[x] == 0, x]

{{x→ -5.}, {x→ -3.}, {x→ -1.}, {x→2.}, {x→4.}, {x→6.}}

Notices "==" logical sign that determines equality.

We can take the derivative of the function:

∂_x f[x]

-444 + 800 x + 261 x^2 - 164 x^3 - 15 x^4 + 6 x^5

or

D[f[x], x]

-444 + 800 x + 261 x^2 - 164 x^3 - 15 x^4 + 6 x^5

Derivative calculated at a particular value

Derivative[1][f][A]

-444 + 800 A + 261 A^2 - 164 A^3 - 15 A^4 + 6 A^5

We have to tell MATHEMATICA to erase from memory defined constants or functions

Clear[a]

f1[x_] := x^12Exp[-a x^2]

d5 = D[f1[x], {x, 5}]

Simplify[d5]

-8 ^(-a x^2) x^7 (-11880 + 18150 a x^2 - 8670 a^2 x^4 + 1695 a^3 x^6 - 140 a^4 x^8 + 4 a^5 x^10)

or

d5//Simplify

-8 ^(-a x^2) x^7 (-11880 + 18150 a x^2 - 8670 a^2 x^4 + 1695 a^3 x^6 - 140 a^4 x^8 + 4 a^5 x^10)

Integration

in1=NIntegrate [ Sin [Sin[x]], {x, 0, Pi} ]

1.78649

or

iinte2 = ∫_0^πSin[Sin[x]] x

π StruveH[0, 1]

N[iinte2]

1.78649

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.

i0 = ∫_0^a (Sin[(n  π x)/a])^2x

1/4 a (2 - Sin[2 n π]/(n π))

i1 = ∫_0^ax (Sin[(n π x)/a])^2x

-(a^2 (-1 - 2 n^2 π^2 + Cos[2 n π] + 2 n π Sin[2 n π]))/(8 n^2 π^2)

i2 = ∫_0^ax^2 (Sin[(n π x)/a])^2x//Simplify

(a^3 (4 n^3 π^3 - 6 n π Cos[2 n π] + (3 - 6 n^2 π^2) Sin[2 n π]))/(24 n^3 π^3)

We need to consider some substitutions using the "/." command

{i0, i1, i2}/.{ Sin[2 n π] ->0, Cos[2 n π] ->1}//Simplify

{a/2, a^2/4, 1/12 a^3 (2 - 3/(n^2 π^2))}

or we can include the conditions  in the Simplify command

Simplify[{i0,i1,i2},{n} ∈ Integers]

{a/2, a^2/4, 1/12 a^3 (2 - 3/(n^2 π^2))}

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:

i10 = ∫_0^ax^10 (Sin[(n π x)/a])^2x

One way of simplify is by using conditions

Simplify[i10,{n} ∈ Integers]

1/(88 n^10 π^10) (a^11 (-155925 + 103950 n^2 π^2 - 20790 n^4 π^4 + 1980 n^6 π^6 - 110 n^8 π^8 + 4 n^10 π^10))

or  a direct substitution

 i10/.{ Sin[2 n π] ->0, Cos[2 n π] ->1}//Simplify

(a^11 (8 n^11 π^11 - 110 n π (2835 - 1890 n^2 π^2 + 378 n^4 π^4 - 36 n^6 π^6 + 2 n^8 π^8)))/(176 n^11 π^11)

A relevant application in Quantum Mechanics

Consider the Quantum Mechanical  p^4operator and the n10 wave function of the Harmonic Oscillator (HO) .

First , p^2is given by :  - h^2/(4π^2) d^2/dx^2operator

 therefore p^4is equal to - h^4/(4^2π^4) d^4/dx^4 .

The HO wave function for any n is given by : If we use ψ_n (x) = 1/(2^nn !)^(1/2) α/π^(1/4) H_n (α^(1/2) x) e^(-αx^2/2)

We start by defining the wave function .

psiH10 = 1/(2^1010 !)^(1/2) α/π^(1/4) HermiteH[10, α^(1/2) x] Exp[-α x^2/2] ;

First we consider the integral of the square of the wave function

norm10 = Integrate[psiH10  psiH10, {x, -Infinity, Infinity}]//Timing

Since α is a positive real number the integral is equal to unity.  Thus we say that psiH10 is normalized.

Simplify[norm10[[2]],α > 0]

1

Now we take the  derivative of the wave function

del210 = D[psiH10, {x, 2}]//Simplify

The average <p^2> is proportional by the following integral:
Notice that we can include Assumptions in the Integrate command

avrp210 = Integrate[psiH10 del210, {x, -Infinity, Infinity}, Assumptions→ α > 0]//Timing

{0.537321 Second, -(21 α)/2}


Created by Mathematica  (September 7, 2006) Valid XHTML 1.1!