Quick guide to Mathematica

To get help, place the cursor on the function and press F1
To run all commands in one cell, place the cursor there and press Shift + Enter or Enter on the numerical keyboard.
Output of many commands is suppressed by ; at the end of the command. If you want to see the output, delete ;
Argument of functions must be in square brackets [...], braces {...} are for arrays, ranges etc., use double brackets [[...]] to access elements of arrays
expr /. {x -> a} means substitute a for x in expr, expr // function means apply function to expr, i.e. it is equivalent to function[expr].
D[f[x],x] = derivative of f[x] with respect to x.
To define a function of x one can use f[x_] := 1+(x^2), notice the underscore and the colon, or # and & like in f := 1+((#)^2) &
N[expr] evaluates expr with machine precision, if you use the decimal point in the expression it will be also evaluated with machine precision
Special characters can be inserted by pressing Esc ... Esc, e.g. Esc p Esc gives π
Clear[...] is used to unset any variables which could have been assigned previously.
Some other useful commands: Simplify, Expand, Factor; Integrate, Series, Sum

Clear all symbols from previous evaluations to avoid problems

Clear["Global`*"]

Interpolation on equidistant grid - exact data

Comparison of a built-in Mathematica function and a function based on Aitken-Neville algorithm (it must be the same polynomial)

func=1;
a=-π; b=-a;
add=0;
n=6;
xEqui=Range[a,b,(b-a)/n];
Switch[func,
1,f[x_]=Sin[x],
2,f[x_]=Exp[-x^2/5],
3,f[x_]=1/(1+x^2);
];
data=Table[{xEqui[[i]],f[xEqui[[i]]]},{i,1,n+1}]
L[x_]=InterpolatingPolynomial[data,x]//Simplify
LAN[x_]=MyAitkenNevilleInterpolation[xEqui,data[[All, 2]],x]//Simplify
y1=-1.1;y2=-y1;
Plot[{f[z],L[z],LAN[z]+1/100},{z,a-add,b+add},PlotStyle->{Blue,Green,Red},PlotRange->{y1,y2}]

func=1;
a=-5; b=-a;
add=0;
n=10;
xEqui=N[Range[a,b,(b-a)/n]];
Switch[func,
1,f[x_]=Sin[x],
2,f[x_]=Exp[-x^2/5],
3,f[x_]=1/(1+x^2);
];
data=Table[{xEqui[[i]],f[xEqui[[i]]]},{i,1,n+1}]
L[x_]=InterpolatingPolynomial[data,x]//Simplify;
der[x_]=D[f[x],{x,n+1}];
ω[x_]=Product[x-xEqui[[i]],{i,1,n+1}]/(n+1)!;
err[x_]=f[x]-L[x];

y1=-1.1;y2=-y1;
gfL=Show[Plot[{f[z],L[z]},{z,a-add,b+add},
PlotStyle->{Blue,Green},PlotRange->{y1,y2}],ListPlot[data,PlotStyle->{Red}],PlotLabel->"f[x] and L[x]"];
gder=Show[Plot[{der[z]},{z,a-add,b+add},PlotStyle->{Brown},PlotRange->All],PlotLabel->"D[f[x],{x,n+1}]"];
gω=Show[Plot[{ω[z]},{z,a-add,b+add},PlotStyle->{Black},PlotRange->All],PlotLabel->"ω[x]/(n+1)!"];
gerr=Show[Plot[{err[z]},{z,a-add,b+add},PlotStyle->{Red},PlotRange->All],PlotLabel->"Error[x] = f[x] - L[x]"];
GraphicsGrid[{{gfL,gder,gω,gerr}},ImageSize->Full]

Interpolation on equidistant grid - data with noise

func=1;
a=-5; b=-a;
add=0;
n=10;
noise = 1/100;
xEqui=N[Range[a,b,(b-a)/n]];
Switch[func,
1,f[x_]=Sin[x],
2,f[x_]=Exp[-x^2],
3,f[x_]=1/(1+x^2);
];
data=Table[{xEqui[[i]],f[xEqui[[i]]]+noise*(RandomReal[]-0.5)},{i,1,n+1}]
L[x_]=InterpolatingPolynomial[data,x]//Simplify;
der[x_]=D[f[x],{x,n+1}];
ω[x_]=Product[x-xEqui[[i]],{i,1,n+1}]/(n+1)!;
err[x_]=f[x]-L[x];

y1=-1.1;y2=-y1;
gfL=Show[Plot[{f[z],L[z]},{z,a-add,b+add},
PlotStyle->{Blue,Green},PlotRange->{y1,y2}],ListPlot[data,PlotStyle->{Red}],PlotLabel->"f[x] and L[x]"];
gder=Show[Plot[{der[z]},{z,a-add,b+add},PlotStyle->{Brown},PlotRange->All],PlotLabel->"D[f[x],{x,n+1}]"];
gω=Show[Plot[{ω[z]},{z,a-add,b+add},PlotStyle->{Black},PlotRange->All],PlotLabel->"ω[x]/(n+1)!"];
gerr=Show[Plot[{err[z]},{z,a-add,b+add},PlotStyle->{Red},PlotRange->All],PlotLabel->"Error[x] = f[x] - L[x]"];
GraphicsGrid[{{gfL,gder,gω,gerr}},ImageSize->Full]

Chebyshev grid

func=3;
a=-5; b=-a;
add=2;
n=15;
xEqui=N[Range[a,b,(b-a)/n]]
xCheb=Table[N[(a+b+(b-a) Cos[π (2i+1)/(n+1)/2])/2],{i,n,0,-1}]
Switch[func,
1,f[x_]=Sin[x],
2,f[x_]=Exp[-x^2],
3,f[x_]=1/(1+x^2)
]
data=Table[{xEqui[[i]],f[xEqui[[i]]]},{i,1,n+1}];
L[x_]=InterpolatingPolynomial[data,x]//Simplify;
dataCheb=Table[{xCheb[[i]],N[f[xCheb[[i]]]]},{i,1,n+1}];
LCheb[x_]=InterpolatingPolynomial[dataCheb,x]//Simplify;

y1=-1.1;y2=-y1;
Show[Plot[{f[z],L[z],LCheb[z]},{z,a-add,b+add},PlotStyle->{Blue,Green,Red},PlotRange->{y1,y2}],ListPlot[{data,dataCheb},PlotStyle->{Green,Red}]]

ymax=10^(-6);
ω[x_]=Product[x-xEqui[[i]],{i,1,n+1}]/(n+1)!;
ωCheb[x_]=Product[x-xCheb[[i]],{i,1,n+1}]/(n+1)!;
Plot[{ω[z],ωCheb[z]},{z,a-add,b+add},PlotRange->{-ymax,ymax}]

Splines

func=3;
a=-5; b=-a;
add=0;
n=6;
xEqui=N[Range[a,b,(b-a)/n]]
xCheb=Table[N[(a+b+(b-a) Cos[π (2i+1)/(n+1)/2])/2],{i,n,0,-1}]
Switch[func,
1,f[x_]=Sin[x],
2,f[x_]=Exp[-x^2],
3,f[x_]=1/(1+x^2)
]
data=Table[{xEqui[[i]],f[xEqui[[i]]]},{i,1,n+1}];
L[x_]=InterpolatingPolynomial[data,x]//Simplify;dataCheb=Table[{xCheb[[i]],N[f[xCheb[[i]]]]},{i,1,n+1}];
LCheb[x_]=InterpolatingPolynomial[dataCheb,x]//Simplify;
LMath=Interpolation[data];
Spline=Interpolation[data,Method->"Spline"];
y1=-1.1;y2=-y1;
Show[Plot[{f[z],L[z],LCheb[z],LMath[z],Spline[z]},{z,a-add,b+add},PlotStyle->{Blue,Green,Yellow,Red,Orange},PlotRange->{y1,y2}],ListPlot[{data,dataCheb},PlotStyle->{Green,Yellow}]]