(*arithmetic*)
1+1

(10+5)*3

(3/2)^10

N[%,8]

po=1.5^10

N[po,40]

SetPrecision[po,40]

(3/2)^100

N[%,40]

1.5^100

N[%,40]

(*functions*)
f[x_]:=x+Cos[x]

f[1]

f[1.]

Plot[f[x],{x,0,10},AxesLabel->{x,"f(x)"}]

plo=Plot[f[x],{x,0,10},Frame->True,
	FrameLabel->{x,"f"," f= x+Cos[x]"," "}]

(*import/export graphics*)
SetDirectory["~/courses/cp09"](*change to  c:/[whatever directory you want] between "  " *)

Print[FileNames[]]

Export["f1.EPS",plo,"EPS",ImageSize->500,
ImageOffset->{30,30}];

Export["f2.JPEG",plo,"JPEG",ImageSize->500,
ImageOffset->{30,30}];

ima=Import["f2.JPEG"]

Show[ima]

Export["f3.EPS",ima]

(*parameters*)
aa=1;bb=2;
g[x_]:=aa+bb*x;
g[y]

aa=3;bb=4;
g[y]

aa=1;bb=2;
h[x_]=aa+bb*x;
h[y]

aa=3;bb=4;
h[y]

(*Loops*)
x[0]=0

Do[x[n+1]=x[n]+1,{n,0,10}]

x[1]

x[2]

taa=Table[x[n],{n,0,10}]

ListPlot[taa]

ListPlot[taa,Joined->True]

ListPlot[taa,PlotStyle->{PointSize[0.04]}]

(*look for options*)
?ListPlot

ParametricPlot[{Cos[5*x],Sin[3*x]},{x,0,2*Pi}]

ParametricPlot[{Cos[5*x],Sin[3.354678*x]},{x,0,20*Pi}]

(*complex numbers*)
I^2

Re[1+I]

rez=Plot[Re[Zeta[1/3 +I*x]],{x,0,50}]

imz=Plot[Im[Zeta[1/3 +I*x]],{x,0,50},PlotStyle->{RGBColor[1,0,0]}]

Show[rez,imz]

Plot[{0,Abs[Zeta[1/3 +I*x]]},
	{x,0,50},PlotPoints->2000,PlotRange->All]

?Manipulate

Manipulate[Plot[{0,Abs[Zeta[rep+I*x]]},
	{x,0,30},PlotPoints->2000,PlotRange->All],{rep,0,1}]

?Zeta

(*calculus*)
f[y]

D[f[y],y]

D[f[y],{y,2}]

Integrate[f[x],{x,0,y}]

tt=(a+b)*(c+d)

uu=Expand[tt]

Factor[uu]

vv=(a-b)*(a+b)/(a^2-b^2)

Simplify[vv]

?RandomReal

RandomReal[]

RandomReal[{0,3}]

Do[Print[RandomReal[{0,3}]],{nn,1,10}]

?PutAppend

Do[PutAppend[Random[Real,{0,3}],"datafile"],{nn,1,10}]

FilePrint["datafile"]

Do[Put[Random[Real,{0,3}],"datafile"],{nn,1,10}]

FilePrint["datafile"]

Do[PutAppend[Random[Real,{0,3}],"datafile"],{nn,1,10}]

FilePrint["datafile"]

?Import

tabb=Import["datafile","Table"]

tabb=Import["datafile","List"]

(*logical expressions*)
?If

aa

bb

va:=If[aa<bb,xx,yy];va

bb=1;va

?&&

aa

bb

aa<2

aa<1

(aa<2)&& (aa>1)

ff[x_]:=If[x<-1,0,If[x<1,1,0]];Plot[ff[x],{x,-2,2}]

(*series*)

seri=Series[Cos[x],{x,0,8}]

seri^2

(*lists*)
ta=Table[{n,n^2},{n,1,5}]

ta[[2]]

ta[[2,2]]

(*equations*)
sol1=
Solve[x^2+3*x+1==0,x]

sol1[[1]]

x/.{x->qqq}

x/.sol1

x/.sol1[[1]]

Solve[x^6+4*x^5+x^2+3*x+1==0,x]

NSolve[x^6+4*x^5+x^2+3*x+1==0,x]

Solve[39*x^4+258x^3+x^2+3*x+1==0,x]

(*integrals*)
Integrate[Exp[-a*t]*t^b,{t,0,Infinity}]

Integrate[Exp[-a*t]*t^b,{t,0,Infinity},Assumptions->{a>0,b>0}]

NIntegrate[Exp[-(1/2)*x^2]*x^(40),{x,15.,Infinity}]

Integrate[Exp[-(1/2)*x^2]*x^(40),{x,15.,Infinity}]

NIntegrate[Exp[-(1/2)*x^2]*x^(40),{x,15,Infinity},AccuracyGoal->30,WorkingPrecision->80]

Plot[Exp[-(1/2)*x^2]*x^(40),{x,1,20}]

Plot[Exp[-(1/2)*x^2]*x^(40),{x,1,20},PlotRange->All]

Plot[Exp[-(1/2)*x^2]*x^(40),{x,15,20},PlotRange->All]

f[x_]:=x^2;

minIm=-0.01;maxIm=0.01;
minRe=-0.01;maxRe=0.02;
Show[ReC=ContourPlot[Re[f[x+I*y]],{x,minRe,maxRe},{y,minIm,maxIm},ContourShading->None,ContourStyle->{RGBColor[1,0,0]}],ImC=ContourPlot[Im[f[x+I*y]],{x,minRe,maxRe},{y,minIm,maxIm},ContourShading->None]]

f[x_]:=((-1+2 x-(Sqrt[1+4 (x^2)]))/(2 x));
minIm=-0.01;maxIm=0.01;
minRe=-0.01;maxRe=0.02;
Show[ReC=ContourPlot[Re[f[x+I*y]],{x,minRe,maxRe},{y,minIm,maxIm},ContourShading->None,ContourStyle->{RGBColor[1,0,0]}],ImC=ContourPlot[Im[f[x+I*y]],{x,minRe,maxRe},{y,minIm,maxIm},ContourShading->None]]