0% found this document useful (0 votes)
17 views24 pages

Mathematica assignment 1

The document contains a series of assignments related to plotting mathematical functions using various parameters and styles in a programming environment. It includes detailed instructions and observations for plotting functions such as Sin(x)/x, Sin(x)/x^2, and others, along with their derivatives. Additionally, it discusses the effects of parameters on the shape of graphs for quadratic functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views24 pages

Mathematica assignment 1

The document contains a series of assignments related to plotting mathematical functions using various parameters and styles in a programming environment. It includes detailed instructions and observations for plotting functions such as Sin(x)/x, Sin(x)/x^2, and others, along with their derivatives. Additionally, it discusses the effects of parameters on the shape of graphs for quadratic functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Assignment 1

Name - Ravi Ranjan Kumar

Q 1. Plot the graph of following functions using PlotRange, AxesLabel , PlotStyle and other com-
mands
(i) Sin(x)/x , x€[-300 Pi, 300 Pi]

In[1]:= PlotSin[x]  x, x, - 300 Pi, 300 Pi

0.005

Out[1]=
-500 500

-0.005

Using PlotRange:-
2

In[2]:= PlotSin[x]  x, x, - 300 Pi, 300 Pi, PlotRange → All


1.0

0.8

0.6

0.4
Out[2]=

0.2

-500 500

-0.2

Using AxesLabel:-

In[3]:= PlotSin[x]  x, x, - 300 Pi, 300 Pi, AxesLabel → {- 10, 10}
10

0.005

Out[3]=
-10
-500 500

-0.005

Using PlotStyle:
3

In[4]:= PlotSin[x]  x, x, - 300 Pi, 300 Pi, PlotStyle → Green, Thick[0.3]

0.005

Out[4]=
-500 500

-0.005

Observation: The plot of this function show oscillation that decay as x increases. As x->infinity , the
oscillations become smaller and smaller indicating that the function approaches 0.
(ii) Sin(x)/x^2 , x€[-30 Pi,30 Pi]

In[5]:= PlotSin[x]  x ^ 2 , x, - 30 Pi, 30 Pi

0.002

0.001

Out[5]=
-50 50

-0.001

-0.002

Using PlotRange:
4

In[6]:= PlotSin[x]  x ^ 2, x, - 30 Pi, 30 Pi, PlotRange → All

15

10

Out[6]=
-50 50

-5

-10

-15

Using AxesLabels:-

In[7]:= PlotSin[x]  x ^ 2, x, - 30 Pi, 30 Pi, AxesLabel → {- 5, 5}


5

0.002

0.001

Out[7]=
-5
-50 50

-0.001

-0.002

Using PlotStyle:-
5

In[8]:= PlotSin[x]  x ^ 2, x, - 30 Pi, 30 Pi, PlotStyle → Red, Thick[0.5]

0.002

0.001

Out[8]=
-50 50

-0.001

-0.002

Observation:-This plot show a similar behavior to first plot but with more rapid oscillations due to
square of sin(x).

(iii) x-Sin(2x), x€[0,Pi]

In[9]:= Plotx - Sin2 x, x, 0, Pi

Out[9]=

0.5 1.0 1.5 2.0 2.5 3.0

Using PlotRange:-
6

In[10]:= Plotx - Sin2 x, x, 0, Pi, PlotRange → All


Out[10]=

0.5 1.0 1.5 2.0 2.5 3.0

In[11]:=

Using AxesLabels:-

In[12]:= Plotx - Sin2 x, x, 0, Pi, AxesLabel → {- 3, 5}


Out[12]=
5

-3
0.5 1.0 1.5 2.0 2.5 3.0

Using PlotStyle:-
7

In[13]:= Plotx - Sin2 x, x, 0, Pi, PlotStyle → Pink, Thick[0.8]


Out[13]=

0.5 1.0 1.5 2.0 2.5 3.0

Observation :- This plot is a linear function combined with oscillations from the sine term. The linear
form dominates, so the graph increases steadily with smaller fluctuations.

(iv) 1/(x^2+1), x€[-10,10]

In[14]:= Plot[1 / (x ^ 2 + 1), {x, - 10, 10}]


Out[14]=
0.6

0.5

0.4

0.3

0.2

0.1

-10 -5 5 10

Using PlotRange-
8

In[15]:= Plot[1 / (x ^ 2 + 1), {x, - 10, 10}, PlotRange → All]


Out[15]=

1.0

0.8

0.6

0.4

0.2

-10 -5 5 10

Using AxesLabel:-

In[16]:= Plot[1 / (x ^ 2 + 1), {x, - 10, 10}, AxesLabel → {15, 5}]


Out[16]=
5
0.6

0.5

0.4

0.3

0.2

0.1

15
-10 -5 5 10

Using PlotStyle:-
9

In[17]:= Plot1 / (x ^ 2 + 1), {x, - 10, 10}, PlotStyle → Green, Thick[0.9]


Out[17]=
0.6

0.5

0.4

0.3

0.2

0.1

-10 -5 5 10

Observation:- This is a bell shaped curve centred at x=0. This function approaches zero as mod of x
approaches infinity.

(v) Sin(1/x),xSin(x) and Abs(x)/x

In[18]:= PlotSin[1 / x], x * Sin[x], Abs[x]  x, {x, - 10, 10}


Out[18]=

-10 -5 5 10

-2

-4

Using PlotRange:-
10

In[19]:= PlotSin[1 / x], x * Sin[x], Abs[x]  x, {x, - 10, 10}, PlotRange → All
Out[19]=

-10 -5 5 10

-2

-4

-6

Using AxesLabels:-

In[20]:= PlotSin[1 / x], x * Sin[x], Abs[x]  x, {x, - 10, 10}, AxesLabel → {20, 10}
Out[20]=
10

20
-10 -5 5 10

-2

-4

Using PlotStyle:-
11

In[21]:= PlotSin[1 / x], x * Sin[x], Abs[x]  x, {x, - 10, 10},


PlotStyle → Green, Red, Blue, Thick[0.5, 0.7, 0.4]
Out[21]=

-10 -5 5 10

-2

-4

Observation:- These functions show interesting behavior near x=0. The first function oscillates
rapidly near 0, while second function combines this oscillation with a linear component and third
function is a sign function which is -1 for x<0 and 1 for x>0.

(vi) e^xCos(x)

In[22]:= PlotExp[x] * Cos[x], x, - Pi, Pi


Out[22]=
2

-3 -2 -1 1 2 3

-2

-4

-6

-8

-10

-12

Using PlotRange:-
12

In[23]:= PlotExp[x] * Cos[x], x, - Pi, Pi, PlotRange → All


Out[23]=

-3 -2 -1 1 2 3

-5

-10

-15

-20

Using AxesLabel:-

In[24]:= PlotExp[x] * Cos[x], x, - Pi, Pi, AxesLabel → {- 10, 10}


Out[24]=
10
2

-10
-3 -2 -1 1 2 3

-2

-4

-6

-8

-10

-12

In[25]:=

Using PlotStyle:-
13

In[26]:= PlotExp[x] * Cos[x], x, - Pi, Pi, PlotStyle → Pink, Thick[0.5]


Out[26]=
2

-3 -2 -1 1 2 3

-2

-4

-6

-8

-10

-12

Observation:- This function oscillates but grows exponentially as x->infinity leading to a graph that
shows oscillations with increasing amplitude.

Q 2. (i) Plot the graph of polynomial f(x)= x^4+x^3-x+1 and its derivative and second derivative
graphs on the same plane for x€[-10,10].

In[27]:= f[x_] = x ^ 4 + x ^ 3 - x + 1
f1[x_] = D[f[x], x]
f2[x_] = D[f1[x], x]
Out[27]=
1 - x + x3 + x4
Out[28]=
-1 + 3 x2 + 4 x3
Out[29]=
6 x + 12 x2

In[30]:= Plot{f[x], f1[x], f2[x]}, {x, - 10, 10}, PlotStyle → Red, Green, Yellow, Thick[0.5, 0.7, 0.9]
Out[30]=
4000

2000

-10 -5 5 10

-2000

-4000

Observations:-
1. f(x): The original function has a quartic nature. So it will have general "W" or "M" shape depending
14

upon coefficients. In this case it will rise steeply as x->+-infinity.


2. First derivative: It will show the slope of original function at any point. It will be a cubic function
and its zeroes will correspond to local maxima, minima and inflection points of f(x).
3. Second derivative: It will give information about the concavity of the function. It will be a
quadratic equation and its zeroes will indicate points of inflection where concavity changes.

Q 2. (ii) Plot the graphs of f(x)=x(x-3)(x+3) and g(x)= Cos 2x together on the same set of axes and over
the interval [-20,20]. Use the PlotRange option to adjust the viewing window so that intersection
points are visible.

In[31]:= f[x_] = x (x - 3) (x + 3)
g[x_] = Cos2 x
Plot{f[x], g[x]}, {x, - 20, 20}, PlotStyle → Red, Green, Thick[0.4, 0.6]
Out[31]=
(- 3 + x) x (3 + x)
Out[32]=
Cos2 x

Out[33]=

600

400

200

-20 -10 10 20

-200

-400

-600

Using PlotRange:-
15

In[34]:= Plot[{f[x], g[x]}, {x, - 20, 20}, PlotRange → All, PlotStyle → {Red, Green}]
Out[34]=

5000

-20 -10 10 20

-5000

Observations:-
1. f(x): Red graph
2. g(x) : Green graph
3. Intersection points: between x = -4 to 4

Q 3. Use the animate command to plot the graph of f(x) by varying the parameters a,b,c,d and e for
each of the following functions. Discuss how each parameter affects the shape of graph.
(i) f(x) = ax^2+bx+c
16

In[35]:=

AnimatePlota x ^ 2 + b x + c, {x, - 10, 10}, {a, - 5, 5}, {b, - 5, 5}, {c, - 10, 10}
Out[35]=

40

30

20

10

-10 -5 5 10

Observations:
1. Parameter a controls the curvature of parabola.As a increases , the parabola becomes steeper and
as a decreases, the parabola flips and becomes steeper in opposite direction.
2. Parameter b controls the tilt of the parabola. Positive b values tilt it to left and negative values tilt
it to right.
3. Parameter c controls the vertical shift. Increasing c shifts the graph upward while decreasing it
shift the graph downwards.

Q 3. (ii) f(x)=a x^4+b x^3+c x^2+d x+e


17

In[36]:= AnimatePlota x ^ 4 + b x ^ 3 + c x ^ 2 + d x + e, {x, - 10, 10},


{a, - 5, 5}, {b, - 5, 5}, {c, - 10, 10}, {d, - 5, 5}, {e, - 10, 10}
Out[36]=

-10 -5 5 10

-10 000

-20 000

-30 000

Observations:-
1. Parameter a controls the steepness and concavity of quartic curve. A positive a results in curve
opening upwards while a negative a results in opening curve downwards.
2. Parameter b affects the asymmetry of the graph introducing more complex changes in the slope.
3. Parameter c impacts the curvature similarly to the quadratic case but in combination with higher
order terms.
4. Parameter d affects the linear tilt of the graph.
5. Parameter e shifts the graph vertically.

Q 4. Plot the graph of the following functions using PlotRange, AxesLabel, PlotLabel and other
commands. Discuss how each parameter affects the shape of graph
(i) c+|ax+b|
18

In[37]:= AnimatePlotc + Absa x + b, {x, - 10, 10}, PlotRange → All,


PlotLabel → {- 20, 20}, AxesLabel → {- 15, 15}, {a, - 5, 5}, {b, - 10, 10}, {c, - 5, 5}
Out[37]=

{-20, 20}
15

14

12

10

2
-15
-10 -5 5 10

Observations:-
1. Parameter a controls the slope of the lines forming the V-shape. Increasing a makes the V-shape
steeper while decreasing a flattens the V-shape.
2. Parameter b horizontally shifts the graph. Positive b shifts the graph to left while negative b shifts
it to right.
3. Parameter c vertically shifts the entire graph. Increasing c raises the graph while decreasing c
lowers it.

Q 4 (ii) Sin(ax)
19

In[38]:= AnimatePlotSina x, x, - 2 Pi, 2 Pi, PlotRange → {- 10, 10},


AxesLabel → {- 5, 5}, PlotLabel → {- 10, 10}, {a, - 5, 5}
Out[38]=

{-10, 10}
5
10

-5
-6 -4 -2 2 4 6

-5

-10

Observations:-
1. Parameter a controls the frequency of sine wave. As a increases the wave oscillates more rapidly.
As a decreases the wave oscillates more slowly.

Q 4. (iii) 1/(ax+b)
20

In[39]:= AnimatePlot1  a x + b, {x, - 10, 10}, PlotRange → All,


AxesLabel → {- 5, 5}, PlotLabel → {- 10, 10}, {a, - 5, 5}, {b, - 10, 10}
Out[39]=

{-10, 10}
5

100

50

-5
-10 -5 5 10

-50

-100

In[40]:=

Observations-
1. Parameter a controls the slope of asymptote. As a increases the steepness of graph around asymp-
tote increases.
2. Parameter b shifts the vertical asymptote horizontally.Increasing b shift it to left while decreasing
b shift it to right.

Q 4. (iv) e^ax
21

In[41]:= AnimatePlotExpa x, {x, - 5, 5}, PlotRange → All,


AxesLabel → {- 10, 10}, PlotLabel → {- 5, 5}, {a, - 10, 10}
Out[41]=

{-5, 5}
10
15
4 × 10

15
3 × 10

15
2 × 10

15
1 × 10

-10
-4 -2 2 4

Observations-
1. Parameter a controls the rate of exponential growth or decay.

Q 5. Analyse the effect of shift f(x+a),f(x)+a,f(bx) and bf(x) for the various values of a and b for func-
tion f(x)= Cos x.
(i) f(x+a)

In[42]:= AnimatePlotCos[x + a], x, - 2 Pi, 2 Pi, {a, - 5, 5}


Out[42]=

1.0

0.5

-6 -4 -2 2 4 6

-0.5

-1.0

Observations:
Horizontal shift: The parameter a shifts the graph horizontally .Positive values of a shifts the graph to
22

the left while negative value shift it to the right. This is because adding a to x modifies the phase of
cosine wave moving its peaks and troughs through x axis.
(ii) f(x)+a

In[43]:= AnimatePlotCos[x] + a, x, - 2 Pi, 2 Pi, {a, - 5, 5}


Out[43]=

-6 -4 -2 2 4 6

-2.0

-2.5

-3.0

-3.5

Observations-
Vertical Shift: The parameter a shifts the graph vertically. Increasing a moves the entire graph
upwards while decreasing a shifts the graph downwards.The shape of graph remains same but its
position on y axis changes.

(iii) f(bx)
23

In[44]:= AnimatePlotCosb x, x, - 2 Pi, 2 Pi, {b, - 5, 5}


Out[44]=

1.0

0.5

-6 -4 -2 2 4 6

-0.5

-1.0

Observations:-
Horizontal stretch/compression: The parameter b controls the frequency of the wave. When b>1 the
graph is compressed horizontally increasing the frequency of oscillations . When 0<b<1 the graph
stretches decreasing the frequency of oscillations. The amplitude of wave remains unchanged.

(iv) bf(x)

In[45]:= AnimatePlotb Cos[x], x, - 2 Pi, 2 Pi, {b, - 5, 5}


Out[45]=

1.5

1.0

0.5

-6 -4 -2 2 4 6

-0.5

-1.0

-1.5

Observations:-
Vertical Stretch/compression: The parameter b affects the amplitude of wave. When |b|>1 the graph
24

is stretched vertically making the peaks and troughs more pronounced. When 0<|b|<1 the graph is
compressed vertically reducing the amplitude. Negative values of b reflect the graph about x axis
flipping the troughs and peaks.

Q 6. Show [Plot 1, Plot 2] displays the graphics plot 1, plot 2 on one coordinate system. Use show
command to display the graph of function Sin x, x€[-Pi,Pi] and the points (0,0) ,(Pi/2,Pi),(Pi,0)
together on same set of axes.

In[46]:=

In[47]:= plot1 = PlotSin[x], x, - Pi, Pi, PlotRange → - 1.5, 1.5,


AxesLabel → "x", "f(x)", PlotLabel → "Graph of Sin(x)", PlotStyle → Blue;

plot2 = ListPlot0, 0, Pi  2, Pi, Pi, 0, PlotStyle → Red, PointSize[Large];

Showplot1, plot2
Out[49]=
Graph of Sin(x)
f(x)
1.5

1.0

0.5

x
-3 -2 -1 1 2 3

-0.5

-1.0

-1.5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy