Question 1
In[ ]:= f[x_] = (x - 2)2 ;
g[x_] = (x - 2)3 ;
h[x_] = (2 - x)3 ;
Plot[{f[x], g[x], h[x]}, {x, - 5, 10},
PlotStyle {Red, Green, Blue}, PlotLegends "Expressions"]
Plot[{f[x], g[x], h[x]}, {x, - 5, 10},
PlotStyle {GrayLevel[.35], GrayLevel[.65], GrayLevel[.5]}, PlotLegends "Expressions"]
Plot[{f[x], g[x], h[x]}, {x, - 5, 10},
PlotStyle {Dashing[.01], Dashing[.03], Dashing[.05]}, PlotLegends "Expressions"]
Plot[{f[x], g[x], h[x]}, {x, - 5, 10},
PlotStyle {Thickness[.009], Thickness[.005], Thickness[.01]},
PlotLegends "Expressions"]
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[ ]:= f[x_] := x3 - 3 x2 + 2 x + 3
list = Table[{PaddedForm[x, {4, 2}], PaddedForm[f[x], {4, 2}]}, {x, - 3, 3, 0.5}];
TableForm[list, TableAlignments Center,
TableDirections Column, TableHeadings {None, {"x", "f[x]"}}]
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
In[ ]:= ListPlot[list, Joined True, PlotMarkers {Automatic, Medium}]
10
-3 -2 -1 1 2 3
-10
-20
Out[ ]=
-30
-40
-50
-60
In[ ]:= ListPlot[list1, Joined True, PlotMarkers {Automatic, Medium}]
10
-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
In[ ]:= Plot[{f[x], f[x]}, {x, - 15, 15},
PlotStyle {{Red, Thickness[0.02]}, {Yellow, Thickness[0.007]}}]
3000
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
f3[x_] := 2-x + x - 3 + 0.5
f4[x_] := 10 - 17 x + 8 x2 - x3
g1 = Plot[f1[x], {x, - 5, 5}, PlotLabel "f1(x)"];
g2 = Plot[f2[x], {x, - 10, 10}, PlotLabel "f2(x)"];
g3 = Plot[f3[x], {x, - 3, 8}, PlotLabel "f3(x)"];
g4 = Plot[f4[x], {x, - 30, 20}, PlotLabel "f4(x)"];
GraphicsGrid[{{g1, g2}, {g3, g4}}]
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 4 6 8 -30 -20 -10 10 20
Comment on the graphs:
Domain of f1(x) = , Range of f1(x) =
Domain of f2(x) = \{±3} Range of f2(x ) = + \{0}
Domain of f3(x) = ∅ Range of f3(x) = ∅
Domain of f4(x) = x ⩽ 1 || 2 ≤ x ≤ 5 Range of f4(x) = +
f3 can be drawn separately with its real and imaginary parts.
6 Mathematica Assignment No. 2 B200302063.nb
In[ ]:= Plot[{Real[f3[x]], Im[f3[x]]}, {x, - 2, 5}]
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
In[ ]:= Reduce[f[x] h[x], x]
Reduce: This system cannot be solved with the methods available to Reduce.
Out[ ]= Reducex 2x Sin[6 x], x
Question 5
( a) x n
8 Mathematica Assignment No. 2 B200302063.nb
In[ ]:= g1 = Plotx1 , {x, - 10, 10}, PlotLabel "xn (n=1)";
g2 = Plotx2 , {x, - 10, 10}, PlotLabel "xn (n=2)";
g3 = Plotx3 , {x, - 10, 10}, PlotLabel "xn (n=3)";
g4 = Plotx4 , {x, - 10, 10}, PlotLabel "xn (n=4)";
GraphicsGrid[{{g1, g2}, {g3, g4}}]
x n (n = 1 ) x n (n = 2 )
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
In[ ]:= g5 = PolarPlot[Cos[1 * θ], {θ, 0, 2 π}, PlotLabel "n=1"];
g6 = PolarPlot[Cos[2 * θ], {θ, 0, 2 π}, PlotLabel "n=2"];
g7 = PolarPlot[Cos[3 * θ], {θ, 0, 2 π}, PlotLabel "n=3"];
g8 = PolarPlot[Cos[4 * θ], {θ, 0, 2 π}, PlotLabel "n=4"];
GraphicsGrid[{{g5, g6, g7, g8}}]
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}}]
2(1+Cosθ) 2(1-Cosθ) 2(1+Sinθ) 2(1-Sinθ)
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
f (g(x)) g(f (x))
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
In[ ]:= f[2]
Out[ ]= 1
(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
In[ ]:= cone = RevolutionPlot3D[3 r, {r, 0, 3}, BoxRatios 1];
hemisphere = RevolutionPlot3D9 + 9 - r2 , {r, 0, 3};
Show[cone, hemisphere, PlotRange All, BoxRatios {1, 1, 2}]
Out[ ]=