Lezione Introduttiva al Programma Mathematica  

1. Calcolatrice (Basic Math Assistant)

7 9

3+ 4

3 4

N[7 / 3]

((2.3333333333333335`)/2)

N[(Sqrt[797])]

N[(539^(1/3))]

9  A /. A->223

(((3 I  + 5))^2)

16+30 I

4^5

(4^5)

Ceiling[4.01]

Round[4.01]

Floor[4.01]

N[π,30000]

(∂_x)Tan[x]

D[Cot[x],x]

(∂_x)Cosh[x]

(∂_x)Cot[x]

(∑_(n=1)^∞)(1/(n^3))

(∑_(n=1)^∞)(1/(n^2))

∫Tan[x]\[DifferentialD]x

∫(1/((E^x)-1)) (x^2) \[DifferentialD]x

(∫_lower^upper)expr\[DifferentialD]var

N[(∫_0^∞)(1/((E^x)-1)) (x^2) \[DifferentialD]x]

(∫_\[Placeholder]^\[Placeholder])(1/(Tan[x] + 1))\[DifferentialD]x

∫(1/(Tan[x] + 1))\[DifferentialD]x

(∑_(n=1)^∞)(1/(n^3))

(∑_(m=0)^N)m

(∑_(n=2)^∞)(1/((n^2)-1))

2. Defining functions

F[x_,a_]:= x^2 + (x^3)  + a^8

?F

Integrate[F[x,a],a]

3. Built-in functions

HermiteH[5,x]

HermiteH[2,x]

?SphericalBesselJ

?SphericalBesselY

4. Plot

Plot[Sin[x]^6,{x,-15,15}]

Plot[((Sin[x])/x),{x,-10,10}]

Plot[{((Sin[x])/x),((Cos[x])/x),Tan [x], (Sqrt[1+(x^2)])} ,{x,0,20}]

Clear[F]

F[x_,A_]:=(Sqrt[(A^(2 ))- (x^2)])

Plot[{x Tan[x],-x Cot[x],F[x,5]},{x, 0, 10}, AspectRatio->1, 
PlotRange->{0,10}]

5. FindRoot

FindRoot[x Tan[x]-F[x,5]==0,{x,1}]

FindRoot[-x Cot[x]-F[x,9]==0,{x,5.5}]

FindRoot[x Tan[x]-F[x,21]==0,{x,3}]

6. Solve

NSolve[(x^3)- x -3 ==0, x]

Solve[x^3 - x -3 ==0,x]

ω=5;

a[0]=1;

RSolve[a[1+k]==(((1+4 k -ω) a[k])/((1+2 k) (2+2 k))),a[k],k]

((2 )/((-1+m) m Pochhammer[(5/2),-2+m]))/.m->6

Pochhammer[x,5]

7. Equazione differenziale

DSolve[f''[x]==- f[x],f[x],x]

DSolve[f''[x]==-k^2 f[x],f[x],x]

DSolve[f''[x]==-k^2 f[x] + x f[x],f[x],x]

DSolve[f''[x]+f'[x]==f[x],f[x],x]

DSolve[{y'[x]+y[x]==2 Sin[x],y[0]==0},y[x],x]

AiryAi function appare come soluzione dell’eq di Schroedinger 1D per una particella carica
in un campo elettrico costante, E = -1, V(x) = x

Potenzial[x_]= x ;

Plot[{Potenzial[x+4],4},{x,-4,4}]

Plot[AiryAi[x],{x,-20,5}]

Plot[AiryBi[x],{x,-7,5}]

7.1 Oscillatore armonico

ϵ=  2  E

ϵ=0.98

s=NDSolve[{y''[x]+ ϵ  y[x]== (x^2)  y[x],y[-5]==0.00001,y'[-5]==0.00001},y,{x,-5,5}]

Plot[Evaluate[y[x]/.s],{x,-5,5},PlotRange->{-1,3}]

ϵ=3.1; s=NDSolve[{y''[x]+ ϵ  y[x]== (x^2)  y[x],y[-5]==0.00001,y'[-5]==0.00001},y,{x,-5,5}];Plot[Evaluate[y[x]/.s],{x,-5,5},PlotRange->{-1,1}]

7.2   Teorema di oscillazione/ Metodo di shooting

7.2 (i)  buca infinita

λ＝２ E  = 2 (k^2);    k= π n,  n=1,2,...;  ψ[π]=0.

δ[λ_]:= ψ[π]/.(NDSolve[{ψ''[x]==- λ ψ[x],ψ[0]== 0,ψ'[0]==1},ψ,{x,0,π}])

NDSolve[{ψ''[x]== -λ ψ[x],ψ[0]== 0,ψ'[0]==1},ψ,{x,0,π}]

δ[λ_]:= ψ[π]/.(NDSolve[{ψ''[x]== -λ ψ[x],ψ[0]== 0,ψ'[0]==1},ψ,{x,0,π}])

Plot[δ[λ],{λ,0,10}]

7.2 (ii) Oscillatore armonico

δ[ϵ_]:= y[10]/.NDSolve[{y''[x]+ ϵ  y[x]== (x^2)  y[x],y[-5]==0.00001,y'[-5]==0.00001},y,{x,-5,10}]

Plot[δ[ϵ],{ϵ,2.9, 3.1}]

7.2 (iii)  Oscillatore anarmonico

V(x)= (x^2)/2 + (x^4)/4

ϵ=1.22

t=NDSolve[{z''[x]+ ϵ  z[x]== (x^2)  z[x]+0.5  (x^4)z[x],z[-5]==0.0000001,z'[-5]==0.000001},z,{x,-5,10}];
Plot[Evaluate[z[x]/.t],{x,-5,5},PlotRange->{-2,100000000}]

κ[ϵ_]:= z[10]/.NDSolve[{z''[x]+ ϵ  z[x]== (x^2)  z[x]+ 0.5 (x^4)z[x],z[-5]==0.00001,z'[-5]==0.00001},z,{x,-5,10}];

Plot[κ[ϵ],{ϵ,1.21, 1.3}]

ϵ=1.242

8. Matrices (List)

M1={{0,1},{1,0}}; MatrixForm[M1]

?M1

M2={{0,0,-I},{0,2,0},{I,0,0}}

MatrixForm[%]

Eigenvalues[M2]

Eigensystem[M2]

M3={{1,0,0},{0,2,0},{0,0,-3}}; MatrixForm[M3]

Eigensystem[M3]

M2.M3.M3

Inverse[M3]

Transpose
MatrixForm[%]

M2.M3-M3.M2

MatrixForm[%]

M2.M3+M3.M2

MatrixForm[%]

9. Factor

Factor[x^2-6 x+9]

Factor[x^10  -6 x]

Factor[x^2+1]

Solve[1+(x^2)==0,x]

10. Series

f[x_,s_]:=  (E^(   2  s x  - (s^(2  ))))

?f

Series[f[x,s], {s,0,11}]

Coefficient[(2 s x-(s^2))^3, s,3]

11. Oscilatore armonico;
 funzioni d’onda e confronto con Meccanica Classica

12. Oscillatore anarmonico

13. Funny potential