Mathematica tool box 2

This is a short hands..on  introduction to Mathematica, part 2.

Graphics and plots

Plot[Sin[x],{x,-Pi,3.1415}]

Plot[Evaluate[Table[BesselJ[n,x],{n,5}]],{x,0,5}]

Arrayg[g,6]

Do[Plot[Sin[i x],{x,-Pi/2,Pi/2}],{i,2,6}]

If you click on all previus cells you can make a movie using a pull down mmenu: Cell-->Animate selected grapnics

Do[Arrayg[i]=Plot[Sin[i x],{x,-Pi/2,Pi/2}],{i,2,6}]

Show[Arrayg[2],Arrayg[4],Arrayg[3],Frame->True]

Show[GraphicsArray[{{Arrayg[2],Arrayg[3]},{Arrayg[4],Arrayg[5]}}]]

f[x_]:= 3* Sin[2 x]*Exp[-3 x]

Plot[f[x],{x,1,4}]

Plot3D[Sin[x*2y],{x,0,3},{y,0,3}]

Plotting data

datas={1,2,3,4,5,6,7,8,9}

ListPlot[datas]

ListPlot[datas, PlotJoined->True]

Plot pairs of ponts x,y

ListPlot[{{1,2},{3,4},{5,6}}]

IF you bring additinal package, Graphics you can do more..........

<<Graphics`Graphics`

ErrorListPlot[{{1,2,0.1},{3,4,0.1},{5,6,0.1}}]

BarChart[{1, -3, 4, 5, 2, 3}, {3, 6, 4, 3}]

some random data:

datar=Table[{n/15,(n/15)^2+2+Random[Real,{-.3,.3}]},{n,15}];

you can simply fit the data to a polynom, 2nd order

fit=Fit[datar,{1,x,x^2},x]

or alternative function:  a + x^3

altfit=Fit[datar,{1,x^3},x]

and display your two trials and data on the same chart

DisplayTogether[
  Plot[altfit, {x,0,1},
        PlotStyle -> Hue[.6]],
  ListPlot[datar,
    PlotStyle -> {Hue[0],
        PointSize[.03]}],
  Plot[fit, {x,0,1},
    PlotStyle -> {GrayLevel[0],
        Dashing[{.03}]}]
]

more experimental data and error

expdata=Table[{x,.92 10^(.94 x)+Random[Real,{-1.0,1.0}]},{x,0.2,1.2,.1}]

Yoy can add the error (say 0.8) to your data expdata

erexpdata = Map[Append[#, 1.0]&, expdata]

There is an error in this one, but it should work

errorp= ErrorListPlot[erexpdata]