Mathematica Assignment No. 2
Mathematica Assignment No. 2
200
100
f (x)
Out[ ]= g(x)
-4 -2 2 4 6 8 10
h(x)
-100
-200
200
100
f (x)
Out[ ]= g(x)
-4 -2 2 4 6 8 10
h(x)
-100
-200
2 Mathematica Assignment No. 2 B200302063.nb
200
100
f (x)
Out[ ]= g(x)
-4 -2 2 4 6 8 10
h(x)
-100
-200
200
100
f (x)
Out[ ]= g(x)
-4 -2 2 4 6 8 10
h(x)
-100
-200
Question 2
(a)
In[ ]:= list1 = Table[{PaddedForm[x, {4, 2}], PaddedForm[f[x], {4, 2}]}, {x, - 3, 3, 0.25}];
TableForm[list1, TableAlignments Center,
TableDirections Column, TableHeadings {None, {"x", "f[x]"}}]
(b)
Mathematica Assignment No. 2 B200302063.nb 3
-3 -2 -1 1 2 3
-10
-20
Out[ ]=
-30
-40
-50
-60
-3 -2 -1 1 2 3
-10
-20
Out[ ]=
-30
-40
-50
-60
(c)
In[ ]:= Plot[f[x], {x, - 4, 6}]
100
50
Out[ ]=
-4 -2 2 4 6
-50
-100
(d)
4 Mathematica Assignment No. 2 B200302063.nb
2000
1000
-15 -10 -5 5 10 15
Out[ ]=
-1000
-2000
-3000
-4000
(e)
In[ ]:= Plot[f[x], {x, - 15, 15}, AxesLabel {"X-Axis", "Y-Axis"}]
Y-Axis
3000
2000
1000
X-Axis
Out[ ]= -15 -10 -5 5 10 15
-1000
-2000
-3000
-4000
Mathematica Assignment No. 2 B200302063.nb 5
Question 3
In[ ]:= f1[x_] := x3 - 2 x2 + 4 x - 5
1
f2[x_] :=
Abs9 - x2
f1(x) f2(x)
100 0.5
50 0.4
-4 -2 2 4 0.3
-50
0.2
-100
0.1
-150
-200
-10 -5 5 10
Out[ ]=
f3(x) f4(x)
1.0
0.8 150
0.6
100
0.4
50
0.2
2.2
2.0
1.8
Out[ ]= 1.6
1.4
1.2
-2 -1 1 2 3 4 5
Question 4
(a)
In[ ]:= f[x_] := Ex
g[x_] := E-x
h[x_] := 2x Sin[6 x]
g1 = Plot[f[x], {x, - 5, 5}]
g2 = Plot[g[x], {x, - 5, 5}]
g3 = Plot[h[x], {x, - 2 Pi, 2 Pi}]
GraphicsRow[{g1, g2, g3}]
60 60
50 50 5
40 40
Out[ ]= 30 30 -6 -4 -2 2 4 6
20 20
-5
10 10
-4 -2 2 4 -4 -2 2 4 -10
(b)
Mathematica Assignment No. 2 B200302063.nb 7
In[ ]:= Plot[{f[x], g[x], h[x]}, {x, - 5, 5}, PlotStyle {Red, Green, Blue}]
30
20
10
Out[ ]=
-4 -2 2 4
-10
-20
-30
(c)
In[ ]:= Plot[{f[x], h[x]}, {x, - 7, 2}]
1.5
1.0
0.5
Out[ ]=
-6 -4 -2 2
-0.5
-1.0
Reduce: This system cannot be solved with the methods available to Reduce.
Question 5
( a) x n
8 Mathematica Assignment No. 2 B200302063.nb
10 100
80
5
60
-10 -5 5 10
40
-5
20
-10
-10 -5 5 10
Out[ ]=
n n
x (n = 3 ) x (n = 4 )
1000 10 000
8000
500
6000
-10 -5 5 10
4000
-500
2000
-1000
-10 -5 5 10
(b)
Mathematica Assignment No. 2 B200302063.nb 9
In[ ]:= ContourPloty2 x3 (2 - x), {x, - 2, 4}, {y, - 4, 4}, Axes True, Frame False
4
Out[ ]=
-2 -1 1 2 3 4
-2
-4
(c)
Sin(nθ)
In[ ]:= g1 = PolarPlot[Sin[1 * θ], {θ, 0, 2 π}, PlotLabel "n=1"];
g2 = PolarPlot[Sin[2 * θ], {θ, 0, 2 π}, PlotLabel "n=2"];
g3 = PolarPlot[Sin[3 * θ], {θ, 0, 2 π}, PlotLabel "n=3"];
g4 = PolarPlot[Sin[4 * θ], {θ, 0, 2 π}, PlotLabel "n=4"];
GraphicsGrid[{{g1, g2, g3, g4}}]
n= 1 n= 2 n= 3 n= 4
1.0 0.5
0.8 0.5
0.5
Out[ ]= 0.6 -0.5 0.5
0.4 -0.5 0.5 -0.5 0.5
-0.5
0.2 -0.5
-0.5
-1.0
-0.4 -0.2 0.2 0.4
Cos(nθ)
10 Mathematica Assignment No. 2 B200302063.nb
n= 1 n= 2 n= 3 n= 4
1.0 1.0
0.4
0.5 0.5 0.5
0.2
Out[ ]=
0.2 0.4 0.6 0.8 1.0 -1.0 -0.5 0.5 1.0 -0.5 0.5 1.0 -1.0 -0.5 0.5 1.0
-0.2
-0.5 -0.5 -0.5
-0.4
-1.0 -1.0
(d)
In[ ]:= g1 = PolarPlot[2 (1 + Cos[θ]), {θ, 0, 2 π}, PlotLabel "2(1+Cosθ)"];
g2 = PolarPlot[2 (1 - Cos[θ]), {θ, 0, 2 π}, PlotLabel "2(1-Cosθ)"];
g3 = PolarPlot[2 (1 + Sin[θ]), {θ, 0, 2 π}, PlotLabel "2(1+Sinθ)"];
g4 = PolarPlot[2 (1 - Sin[θ]), {θ, 0, 2 π}, PlotLabel "2(1-Sinθ)"];
GraphicsGrid[{{g1, g2, g3, g4}}]
4
2 2
3 -2 -1 1 2
1 1 -1
Out[ ]=
2
1 2 3 4 -4 -3 -2 -1 -2
-1 -1 1
-3
-2 -2
-2 -1 1 2 -4
Mathematica Assignment No. 2 B200302063.nb 11
Question 6
In[ ]:= f[x_] := x2 - 4
g[x_] := x
g1 = Plot[(f[x] + g[x]), {x, - 5, 5}, PlotStyle {Red}, PlotLabel "(f+g)(x)"];
g2 = Plot[(f[x] - g[x]), {x, - 5, 5}, PlotStyle {Yellow}, PlotLabel "(f-g)(x)"];
g3 = Plot[(f[x] * g[x]), {x, - 5, 5}, PlotStyle {Blue}, PlotLabel "f(x)g(x)"];
f[x] f (x)
g4 = Plot , {x, - 5, 5}, PlotStyle {Orange}, PlotLabel " ";
g[x] g (x)
g5 = Plot[f[g[x]], {x, - 5, 5}, PlotStyle {Green}, PlotLabel "f(g(x))"];
g6 = Plot[g[f[x]], {x, - 5, 5}, PlotStyle {Cyan}, PlotLabel "g(f(x))"];
GraphicsGrid[{{g1, g2}, {g3, g4}, {g5, g6}}]
(f +g)(x) (f -g)(x)
20
20
15
15
10
10
5
5
-4 -2 2 4
-4 -2 2 4
-5 -5
f (x)g(x) f (x )
g (x )
40 10
Out[ ]= 5
30
20 -4 -2 2 4
-5
10 -10
-15
-4 -2 2 4
4
-4 -2 2 4
-2
3
-4
2
-6
1
-8
-4 -2 2 4
12 Mathematica Assignment No. 2 B200302063.nb
Question 7
1 - x3
In[ ]:= f[x_] := /; x < 2
1 + x2
π (x - 1)
f[x_] := Sin /; 1 ≤ x ≤ 2
2
1
f[x_] := /; x ≥ 2
Log[E (x - 1)]
(a)
In[ ]:= f[1]
Out[ ]= 0
(b)
In[ ]:= Plot[f[x], {x, - 2, 5}]
1.5
1.0
Out[ ]=
0.5
-2 -1 1 2 3 4 5
-0.5
(c)
In[ ]:= InverseFunction[f][0.75]
Out[ ]= 0.45541
Question 8
In cylindrical coordinates the cone has the equation z =
3 r and the hemisphere has the equation z = 9 + 9 - r2
Mathematica Assignment No. 2 B200302063.nb 13
Out[ ]=