Question

In: Computer Science

Plot the functions x, x2, exp(-x), exp(-x2) on four different graphs (two rows and two columns)...

Plot the functions x, x2, exp(-x), exp(-x2) on four different graphs (two rows and two columns) between 0 and 5 in python

Solutions

Expert Solution

Here is the answer...

CODE:

import numpy as np
import matplotlib.pyplot as plt

pos_array = np.arange(0, 5, 0.1)
#creating x between 0 to 5 with range 0.1

neg_array = [-i for i in pos_array] # -x

exp_array = np.exp(neg_array) #exp(-x)


sq_array = [-i*i for i in pos_array] #-x^2
#print(sq_array)
exp_sq_array = np.exp(sq_array) #exp(-x^2)
#print(exp_sq_array)

fig = plt.figure()
ax1 = fig.add_subplot(2, 2, 1)
ax1.title.set_text('x')
ax1.plot(pos_array)

ax2 = fig.add_subplot(2, 2, 2)
ax2.title.set_text('-x')
ax2.plot(neg_array)

ax3 = fig.add_subplot(2, 2, 3)
ax3.title.set_text('exp(-x)')
ax3.plot(exp_array)

ax4 = fig.add_subplot(2, 2, 4)

ax4.title.set_text('exp(-x2)')
ax4.plot(exp_sq_array)
plt.show()

CODE Snapshot:

if you have any doubts please COMMENT.....

If you understand the answer please give THUMBS UP....


Related Solutions

"Create a program that displays a table consisting of four rows and five columns. The first...
"Create a program that displays a table consisting of four rows and five columns. The first column should display the numbers 1 through 4. The second and sub-sequent columns should display the result of multiplying the number in the first column by the numbers 2 through 5. If necessary, create a new project named Introductory14 Project, and save it in the Cpp8\Chap08 folder. Enter the C++ instructions into a source file named Introductory14.cpp. Also enter appropriate comments and any additional...
a) For the function f (x) = x – exp(−x2), do a calculation by hand using...
a) For the function f (x) = x – exp(−x2), do a calculation by hand using a calculator to find the root to an accuracy of 0.1. At most, five iterations (or fewer) are needed to obtain the desired accuracy. b) For f (x) = x2 – sin x, x0 = 1⁄2, do three iterations of Newton’s method (by hand); tabulate the result.
Find and classify all the extrema of the function f(x; y) = Exp(-x2 -y2 )*(x2 +...
Find and classify all the extrema of the function f(x; y) = Exp(-x2 -y2 )*(x2 + 2y2).
1 – Create a webpage that contains a table with exactly three rows and two columns....
1 – Create a webpage that contains a table with exactly three rows and two columns. The first row will contain a table heading containing the name of a US National Park, that spans across all columns. Hint: use the colspan attribute inside the opening th tag Give the table heading an onmouseover that will change the text of the heading when it is moused over to read My Favorites Park! (Hint: use innerHTML). Use onmouseout to change it back....
1 – Create a webpage that contains a table with exactly three rows and two columns....
1 – Create a webpage that contains a table with exactly three rows and two columns. The first row will contain a table heading containing the name of a US National Park, that spans across all columns. Hint: use the colspan attribute inside the opening th tag Give the table heading an onmouseover that will change the text of the heading when it is moused over to read My Favorites Park! (Hint: use innerHTML). Use onmouseout to change it back....
Use matlab to plot Taylor approximation for f(x) for x near 0 Given f(x) = exp(x)...
Use matlab to plot Taylor approximation for f(x) for x near 0 Given f(x) = exp(x) Use subpots to plot and its absolute and realative erros for N= 1,2,3 PLease give matlab code for Taylor and explain in detail, Thank you
Plot the contour plot and the gradient (shown by arrows) for the function f(x, y) = -x2 + 2xy + 3y2
Plot the contour plot and the gradient (shown by arrows) for the functionf(x, y) = -x2 + 2xy + 3y2
There are four numeric columns in R programming language's iris data set. Create a scatter plot...
There are four numeric columns in R programming language's iris data set. Create a scatter plot between the four numeric columns using R programming language and give answers to the following parts. Calculate the correlation between each pair of the four numeric columns in iris. Which pair of variables has the strongest linear relationship? Interpret their ??. Which pair of variables has the weakest linear relationship? Interpret their ??. Which pair(s) of variables can you conclude have a population correlation...
Given Fxy(x,y)=u(x)u(y)[1-Exp(-x/2)-Exp(-y/2)+Exp(-(x+y)/2)]. Note: The step functions mean that Fxy(x,y)=0 for either or both x<0 and y<0....
Given Fxy(x,y)=u(x)u(y)[1-Exp(-x/2)-Exp(-y/2)+Exp(-(x+y)/2)]. Note: The step functions mean that Fxy(x,y)=0 for either or both x<0 and y<0. Any x or y argument range below zero must be truncated at zero. Determine: a) P{X<=1,Y<=2} Ans: 0.2487 b) P{0.5<X<1.5} Ans: 0.3064 c) P{-1.5<X<=2, 1<Y<=3} Ans: 0.2423
Create new Deck object Run testDeck( ) Should get four columns (13 rows each), each column...
Create new Deck object Run testDeck( ) Should get four columns (13 rows each), each column with a unique suit and ranked ace to king Run shuffle( ) then run testDeck( ) again Should get four NEAT columns,(13 rows each) with random numbers and suits in each column Create another Deck object Run testDeal( ) with a parameter of 5 Should get Ace, 2, 3, 4, 5 of spades as the “hand” Now run shuffle( ) then run testDeal( )...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT