Lesson 2 : Mathematica as a Calculator

Basic Arithmatic

2+2

2/6

N[2/6]

2./6

2/0

(3+5)*(2+6)

(3+5) (2+6)

4!

100!

((2^234)+(33^223))((4^412)+(17^433))-10000000000000

More "Calculator" Operations

(2^4)

2^4

Pi

π //N

N[E]

E+π

% //N

Cos[π/2]

Sin[(π/4)]

((Cos[2.32])^2)+(((Sin[2.32]))^2)

Sqrt[2]

Sqrt[2.]

Sqrt[(1000^2)]

Sqrt[-2]

I

?Log

Log[E]

Log[-3]

Log[0]

Log[Infinity]

Log[2,64]

Plot[Log[x],{x,0,10}]

(({{1, 2}, {-2, 3}})).(({{1, 0, 0}, {0, 2, 1}}))

%//MatrixForm

Cos[π{0,(1/3),(1/2),(2/3),1,(4/3),(3/2),(5/3),2}]

Manipulate[
Show[Graphics[
{Circle[{0,0},1],
Line[{{0,0},{Cos[theta],Sin[theta]}}]},
PlotRange->{{-1.1,1.1},{-1.1,1.1}},Axes->True]],
{theta,π{0,(1/3),(1/2),(2/3),1,(4/3),(3/2),(5/3),2}}]

Basic Symbolic Calculations

(a+b)^2

Expand[%]

Expand[(((a+b+c+d))^2)]

%//Simplify

D[(x^4),x]

Integrate[(x^4),x]

Integrate[(1/(Sqrt[2 π]))(E^(-((x^2)/2))),{x,-Infinity,Infinity}]

D[(x^(Sin[(x^(Cos[x]))])),x]

(∑_(i=0)^∞)(3^i)

(∑_(i=0)^∞)((((1/2)))^i)

Sum[(a^i),{i,0,10}]

% //FullSimplify

%68==(((a^(10+1))-1)/(a-1))

% //Simplify

(((a+b))^2)==(a^2)+ab+(b^2)//Simplify

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

Solve[2x+4==8,x]

2x+4 /.x->2

Solve[a (x^2)+b x + c ==0,x]

Solve[{(x^3)+(y^3)==1,(x^2)+(y^2)==1},{x,y}]

Basic File Input Output

{1,2,3,4,5} >> testFile.txt

Directory[]

FileNames[]

<<testFile.txt

Basic Graphics

Plot[(x^2),{x,-3,3}]

Table[(i^2),{i,-3,3,.1}]

tbl=Table[(i^2),{i,-3,3,.1}];

ListPlot[tbl,DataRange->{-3,3}]

?Factorial

n=10;p=0.5;

binTable=Table[((n!)/((n-k)!k!))(p^k)(((1-p))^(n-k)),{k,0,n}];

Total[binTable]

ListPlot[binTable,Filling->Axis,DataRange->{0,n}]

Clear[p];

n=10;
Manipulate[
ListPlot[Table[((n!)/((n-k)!k!))(p^k)(((1-p))^(n-k)),{k,0,n}],PlotRange->{0,0.3},Filling->Axis,DataRange->{0,n}],
{p,0.3,0.7}]

Plot3D[(x^2) (y^2),{x,-10,10},{y,-10,10},PlotRange->All]

ContourPlot[(x^2) (y^2),{x,-10,10},{y,-10,10}]

g=Graphics[{
			Line[{{0,0},{10,10}}],
			PointSize[0.1],
			Point[{10,10}],
			Red,
			Thick,
			Circle[{10,5},2]
},Axes->True]

Show[g,
Axes->False,
Frame->True,
FrameTicks->False,
PlotRange->{{-20,20},{-20,20}}
]