Pooja 757
Pooja 757
Clearing a Function:-
After completing all your work major work is to clear the function used. Since once done it is a good
habit to clear the function in mathematica.
In[1]:= ?f
Out[1]=
Symbol
Global`f
In[2]:= f[x_] := x ^ 2 + 2 x - 4
In[3]:= Clear[f]
1.0
0.8
0.6
0.4
0.2
-10 -5 5 10
1.0
0.9
0.8
0.7
0.6
0.5
-10 -5 5 10
3
1.0
0.9
0.8
0.7
0.6
-10 -5 5 10
1.0
0.8
0.6
0.4
0.2
-10 -5 5 10
1000
800
600
400
200
-3 -2 -1 1 2 3
4
In[18]:=
8000
6000
4000
2000
-3 -2 -1 1 2 3
In[12]:=
8000
6000
4000
2000
-3 -2 -1 1 2 3
5
In[30]:=
150
100
50
-3 -2 -1 0 1 2 3
In[31]:=
-3 -2 -1 1 2 3
6
In[32]:=
-3 -2 -1 1 2 3
-1
-2
In[34]:=
10
-3 -2 -1 1 2 3
In[35]:=
10
-3 -2 -1 1 2 3
7
In[36]:=
10
-3 -2 -1 1 2 3
In[37]:=
2.0
1.5
1.0
0.5
-5 5
In[38]:=
10
-3 -2 -1 1 2 3
8
In[39]:=
2.0
1.5
1.0
0.5
-5 5
In[48]:=
Clear[f];
In[50]:=
1.0
0.5
-10 -5 5 10
-0.5
-1.0
In[51]:=
Clear[f];
In[52]:=
f[x_] := x ^ 5 - 4 x ^ 2 + 1 (x - 1 / 2)
9
In[53]:=
80
60
40
20
-3 -2 -1 1 2 3
-20
In[54]:=
10 000
8000
6000
4000
2000
-10 -5 5 10
In[57]:=
10
-5
-10
10
In[58]:=
Clear[f];
In[59]:=
f[x_] := x ^ 2 - 2 x + 4
In[60]:=
-1 1 2 3
In[61]:=
4.2
4.1
4.0
3.9
In[62]:=
2 2 2 2
In[63]:=
Log[1]
Out[63]=
In[64]:=
Clear[f];
In[65]:=
f[x_] := x ^ 2 + 2 x - 4
In[66]:=
f[1]
Out[66]=
-1
In[67]:=
f[Pi]
Out[67]=
-4 + 2 π + π2
In[68]:=
inv[x_] := 1 / x
In[69]:=
inv[45]
Out[69]=
1
45
In[70]:=
g[x_] := N[inv[x]]
g[45]
Out[71]=
0.0222222
ln 12:-
12
In[73]:=
In[74]:=
-5 5
-1
-2
In[75]:=
-5 5
a = 7; b = 6; c = 4;
a, b, c
Out[77]=
{7, 6, 4}
In[78]:=
ClearAll ;
13
In[79]:=
a, b, c
Out[79]=
{7, 6, 4}
Clear["Global`*"]
In[81]:=
a, b, c
Out[81]=
{a, b, c}
x = RandomInteger[100];
In[83]:=
x, x, x
Out[83]=
In[84]:=
x := RandomInteger[100];
In[85]:=
x, x, x
Out[85]=
Directive Command
In[86]:=
3.0
2.5
2.0
1.5
In[87]:=
3.0
2.5
2.0
1.5
In[88]:=
3.0
2.5
2.0
1.5
In[89]:=
Syntax: " = Plot2 (x - 4) ^ 2 + 1, {x, 3, 5}, PlotStyle → Directive[Thick, Purple, Dashing[{0.08, 0.08}]]" is incomplete;
more input is needed.
In[90]:=
3.0
2.5
2.0
1.5
1.0
In[91]:=
3.0
2.5
2.0
1.5
Frame command
In[92]:=
3.0
2.5
2.0
1.5
1.0
In[93]:=
In[94]:=
3.0
2.5
2.0
1.5
1.0
0.8
0.6
0.4
0.2
1 2 3 4 5
19
In[98]:=
20
15
10
-4 -2 2 4
Gridlines
In[99]:=
1.0
0.8
0.6
0.4
0.2
1 2 3 4 5 6
20
In[100]:=
1.0
0.8
0.6
0.4
0.2
1 2 3 4 5 6
In[101]:=
1.0
0.8
0.6
0.4
0.2
1 2 3 4 5 6
21
In[104]:=
1.0
0.8
0.6
0.4
0.2
π 3π
0 π 2π
2 2
In[105]:=
1.0
0.8
0.6
0.4
0.2
π π 3π π 5π 3π 7π 9 π 5 π 11 π 3 π 13 π 7 π 15 π
0 π 2π
8 4 8 2 8 4 8 8 4 8 2 8 4 8
22
In[106]:=
1.0
0.8
0.6
0.4
0.2
π π 3π π 5π 3π 7π 9 π 5 π 11 π 3 π 13 π 7 π 15 π
0 π 2π
8 4 8 2 8 4 8 8 4 8 2 8 4 8
PlotSin[x] ^ 2, x, 0, 2 Pi, Ticks → 0, Pi, 2 Pi, 0, .5, 1,
sin2 (x)
sin2 (x)
0.5
x
π 2π
23
In[108]:=
PlotSin[x] ^ 2, x, 0, 2 Pi, Ticks → 0, Pi, 2 Pi, 0, .5, 1,
y= (sin[x])^2
sin2 (x)
0.5
x
π 2π
In[109]:=
p = PlotSin[x] ^ 2, x, 0, 2 Pi, Ticks → 0, Pi, 2 Pi, 0, .5, 1, AxesLabel → x, y;
0.5
y= [sin(x)]^2
x
π 2π
24
1 2 3 4 5 6 7
-2
-4
In[111]:=
1 2 3 4 5 6 7
-2
-4
25
In[113]:=
π 3π 5π 7π
π 2π 3π 4π
-2 2 2 2 2
-4
-6
Exercise 3.3
1. Use the gridlines and Tricks options,as well as the setting gridlinesStyle-> lighter gray to produce the
following Plot of the sign function.
In[114]:=
PlotSin[x], x, - 2 Pi, 2 Pi, GridLines → Range- 2 Pi, 2 Pi, Pi / 4, Range- 1, 1, 0.2,
GridLinesStyle → Lighter[Gray],
Ticks → 0, Pi, 2 Pi, - Pi, 2 Pi, 0, 0.5, 1, - 0.5, 1
Out[114]=
0.5
-π π 2π
-0.5
2. Use the Axes, Frame ,or the above function to produce a graph mentioned in the book of reference
26
In[128]:=
Cos15 x
Plot , {x, - 3.5, 3.5}, Axes → {True, False},
1 + x2
Frame → {{True, False}, {True, False}}, Filling → Axis, PlotRange → Full,
FrameStyle → Directive[Gray, 9], AspectRatio → Automatic
-2 -1 1 2
27
In[130]:=
In[131]:=
0.05
-0.05
-0.10
28
In[132]:=
ManipulatePlotx Sin[1 / x], x, 0, r, r, 0.4, "Maximum value of x", 10 ^ (- 10), 2
Out[132]=
Maximum value of x
0.8
0.6
0.4
0.2
-0.2
29
In[134]:=
t, .01, "Thickness ", .001, .02, d, 0.02, "dash size", 0, 0.04,
Thickness
dash size
percent blue
-10 -5 5 10
-2
-4
-6
30
In[135]:=
y=a(x-b)^2+c
-4 -2 2 4
-2
-4
31
In[136]:=
PlotLabel → "y=a(x-b)^2+c", a, - 1, 1, {b, - 1}, - 3, 3, c, 2, - 2, 2
Out[136]=
y=a(x-b)^2+c
4
-4 -2 2 4
-2
-4
32
In[137]:=
PlotLabel → "y=a(x-b)^2+c", a, - 1, 1, {b, - 1}, - 3, 3, c, 2, - 2, 2
Out[137]=
y=a(x-b)^2+c
4
-4 -2 2 4
-2
-4
33
In[138]:=
PlotLabel → "y=a(x-b)^2+c", a, - 1, 1, {b, - 1}, - 3, 3, c, 2, - 2, 2
Out[138]=
y=a(x-b)^2+c
-4 -2 2 4
-5
-10
-15
-20
-25
-30
-35
34
In[139]:=
PlotLabel → "y=a(x-b)^2+c", a, - 1, 1, {b, - 1}, - 3, 3, c, 2, - 2, 2
Out[139]=
y=a(x-b)^2+c
2
-4 -2 2 4
-1
-2
35
In[140]:=
PlotLabel → "y=a(x-b)^2+c", a, - 1, 1, {b, - 1}, - 3, 3, c, 2, - 2, 2
Out[140]=
y=a(x-b)^2+c
-6 -4 -2 2 4 6
-2
-4
-6
36
In[142]:=
MaxRecursion → mr, Mesh → m, pp, 64, "plot points", 4, 8, 16, 32, 64,
mr, 4, "MaxRecursion ", 0, 1, 2, 3, 4, m, Full, "Mesh", Full, Al, None
Out[142]=
plot points 4 8 1 3 6
6 2 4
MaxRecursion 0 1 2 3 4
1.0
0.5
-6 -4 -2 2 4 6
-0.5
-1.0
37
Settler Bar
In[143]:=
Manipulate
Plotf[x], x, 0, 4 Pi, Ticks → Range0, 4 Pi, Pi / 2, Automatic, PlotLabel → f[x],
f, Tan, "functions ", Cos, Sin, Sec, Csc, Tan, Cot, ControlType → SetterBar
Out[143]=
tan(x)
π 3π 5π 7π
π 2π 3π 4π
-2 2 2 2 2
-4
-6
38
In[144]:=
pt, 0, 0, "Move the axes: ", {- 20, - 20}, 20, 20, ControlPlacement → Left
Out[144]=
20
10
-20 -10 10 20
-10
-20
In[145]:=
20
10
-20 -10 10 20
-10
-20
39
In[146]:=
color
0.4
0.3
0.2
0.1
5 10 15 20
-0.1
-0.2
Dynamic Style
In[147]:=
85.2852
40
In[148]:=
0.8
0.6
0.4
0.2
-0.2
In[150]:=
OpenerView
Style"click the triangle ", "Text", Style"haha, you did it!", "Section "
Out[150]=
ListAnimate
Style"click the triangle ", "Text", Style"haha, you did it!", "Section "
Out[151]=
In[152]:=
FlipView
Style"click the triangle ", "Text", Style"haha, you did it!", "Section "
Out[152]=
In[154]:=
SlideView
Style"click the triangle ", "Text", Style"haha, you did it!", "Section "
Out[154]=
◂ ▸
click the triangle
Out[153]=
◂ ▸
click the triangle
In[155]:=
1 2
1.0
0.5
sine →
-0.5 1 2 3 4 5 6
-1.0
In[157]:=
ImageSize → Automatic 0
Out[157]=
0
Out[156]=
Exercise 3.4
1. The following simple Manipulate has two
sliders : one for x and one for y. Make a Manipulate that also has output {x, y},
but that has a single Slider2D controller.
42
In[159]:=
pt, 0, 0, "Move the axes: ", 0, 0, 1, 1, ControlPlacement → Left
Out[159]=
1.0
0.6
0.4
0.2
Out[158]=
1.0
0.6
0.4
0.2
In[161]:=
1.0
0.8
0.6
0.4
0.2
Out[160]=
1.0
0.8
0.6
0.4
0.2
2. Make a Manipulate of a Plot where the user can adjust the AspectRatio in real time,
from a starting value of 1 5 five times as wide as it is tall to
In[164]:=
-6 -4 -2
f[x_] := x ^ 2
Tablef[x], x, 1, 10
Out[166]=
In[168]:=
In[169]:=
Tablef[x], 10
Out[169]=
In[170]:=
In[171]:=
In[172]:=
{{1, 1}, {2, 4}, {3, 9}, {4, 16}, {5, 25}, {6, 36}, {7, 49}, {8, 64}, {9, 81}, {10, 100}}
In[176]:=
Grid[data]
Out[176]=
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
Out[173]=
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
In[179]:=
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
In[175]:=
{{x, x^2}, {1, 1}, {2, 4}, {3, 9}, {4, 16}, {5, 25}, {6, 36}, {7, 49}, {8, 64}, {9, 81}, {10, 100}}
46
In[177]:=
Grid[tablecontents]
Out[177]=
x x^2
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
In[182]:=
Grid[{{x, x^2}, {1, 1}, {2, 4}, {3, 9}, {4, 16}, {5, 25}, {6, 36}, {7, 49}, {8, 64}, {9, 81}, {10, 100}},
Alignment → Right, Dividers → {Center, {False, True}}, Spacings → 2]
x x^2
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
In[53]:=
In[13]:=
In[20]:=
Grid[{{1, f[1]}, {10, f[10]}, {100, f[100]}, {1000, f[1000]}, {10 000, f[10 000]}, {100 000, f[100 000]}},
Alignment → Right, Dividers → All, Spacings → 2]
In[56]:=
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
REFRENCE :-
48