The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
please help me with those problems using python plt plot , thanks
Â
Â
MATH 210 Assignment 4
NumPy and Matplotlib INSTRUCTIONS
â—¦ Create a new Python 3 Jupyter notebook
â—¦ Answer each question in the Jupyter notebook and clearly label the solutions with headings
â—¦ Functions should include documentation strings and comments
â—¦ There are 24 total points and each question is worth 4 points
â—¦ Submit the .ipynb file to Connect by 6pm Tuesday, February 14, 2017
â—¦ You may work on these problems with others but you must write your solutions on your own
QUESTIONS
1. Define a function called curve which takes inputs A, B and C and plots the parametric curve:
x = A sin3 (t) , y = B cos(t) − C cos(2t) , t ∈ [0, 2π] ,
Use the plt.axis('equal') command to display the figure with equal units on both axes.
For example: 2. Write a function called power_series which takes 2 input parameters a and x where a is a
1-dimensional NumPy array representing a sequence a0 , a1 , . . . , aN and x is a number, and
the function returns the (partial) power series sum
N
X a0 xk k=0 For example: 3. (a) Write LaTeX code to display the Fourier series of the triangle wave:
∞
sin(2Ï€(2k + 1)t)
8 X
(−1)k
ftriangle (t) = 2
Ï€
(2k + 1)2
k=0 (b) Write a function called triangle_wave which takes a positive integer N and a Python
list interval of length 2 and plots the N th partial sum of the Fourier series:
ftriangle,N (t) = N
sin(2Ï€(2k + 1)t)
8 X
(−1)k
2
Ï€
(2k + 1)2
k=0 over the interval given by the list interval. For example: 4. (a) Write LaTeX code to display the Fourier series of the sawtooth wave:
fsawtooth (t) = ∞
2 X (−1)k+1 sin(2πkt)
Ï€
k
k=1 (b) Write a function called sawtooth_waves which takes 3 parameters n, m and T and
creates a n by m grid of subplots (with nm total plots) where the N th partial sum of
the Fourier series
N
2 X (−1)k+1 sin(2πkt)
fsawtooth,N (t) =
Ï€
k
k=1 is plotted in the N th subplot position over the interval [0, T ]. For example: Note: the command plt.tight_layout() will provide spacing between subplots to
display the figure properly.
5. (a) Write LaTeX code to display the Euler product formula for the Riemann zeta function:
ζ(s) = ∞
X
Y
1
1
1
1
1
1
1
=
=
·
·
·
···
···
s
−s
−s
−s
−s
−s
n
1−p
1−2
1−3
1−5
1−7
1 − p−s n=1 p prime (b) Write a function called euler_product which take 2 input parameters s and N and
computes the partial Euler product
Y
p≤N 1
1
1
1
1
1
=
·
·
·
···
−s
−s
−s
−s
−s
1−p
1−2
1−3
1−5
1−7
1 − p−s
N where pN denotes the largest prime less than or equal to N . For example: The example above shows an approximation for the special value formula:
ζ(4) = π4
90 6. Write a function called slope_field which takes 4 input parameters f, tlims, ylims and
grid_step where
â—¦ f is a function of 2 variables f (t, y) representing the right side of a first order differential
equation y 0 = f (t, y)
â—¦ tlims and ylims are Python lists of length 2 which set the display limits of the figure
â—¦ grid_step is a number which sets the distance between grid points in the plot
The function should plot a small line (ie. length smaller than grid_step) of slope f (ti , yj )
centred at (ti , yj ) for each point (ti , yj ) in the grid of points defined by the t and y limits and
the grid step. The result is the slope field for the equation y 0 = f (t, y). For example: