1 Project Project - IBeam Design.py X Peaks plotting.py> Peaks Optimization.py X v Homework 10 Solution - 36 A5 A22 X8 ^ V Hw10 Parameter Estima...
This question has been answered
Question

Make a python3 file called, "Peaks Optimization.py"

Plot a surface plot of the "peaks" function from "Peaks plotting.py"

Find the peaks and valleys from peaks function using scipy minimize, using Nelder-mead method

Print the (x, y) coordinates of minimums and maximums of the function, using the following starting guesses:

Find minimums using 2 guesses:

·        (0, -2) and (-2, 0)

Find maximums using 2 guesses:

·        (0, 2) and (-1, 1)


Peaks Optimization.py:

from scipy.optimize import minimize
import numpy as np
import matplotlib.pyplot as plt

# Find minimums using two different guesses:
# (0, -2) and (-2, 0)

# Find maximums using two different guesses:
# (0, 2) and (-1, 1)

def main():


main()





Peaks plotting.py:

from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt


def peaks(x, y):
    return 3*(1-x)**2.*np.exp(-(x**2) - (y+1)**2) 
   - 10*(x/5 - x**3 - y**5) * np.exp(-x**2-y**2) 
   - 1/3*np.exp(-(x+1)**2 - y**2)

def surfacePlot():
    x = np.outer(np.linspace(-3, 3, 30), np.ones(30))
    y = x.copy().T  # transpose

    z = np.zeros((30, 30))
    for i in range(len(x)):
        for j in range(len(y)):
            z[i, j] = peaks(x[i, j], y[i, j])

    fig = plt.figure()
    ax = plt.axes(projection='3d')
    ax.plot_surface(x, y, z, cmap='PuBu', edgecolor='none')
    ax.set_title('Surface plot')
    plt.show()


surfacePlot()



Key (code we need to write in main() is hidden):

Screenshot 2020-11-12 192802.jpg

Image transcriptions

1 Project Project - IBeam Design.py X Peaks plotting.py> Peaks Optimization.py X v Homework 10 Solution - 36 A5 A22 X8 ^ V Hw10 Parameter Estima 7I-beam Equations.pdf 37 # Find minimums using two different guesses i IBeam Design-py 38 # [0, -2] and [-2, 0] IBeam Design2.py 39 Figure 1 - X machine 1.txt 40 # Find maximums using two different guess + + Q : W A machine2.txt 41 # [0, 2] and [-1 -1] machine3.txt 42 Peaks Optimization.py 43 def main () : . . . Peaks plotting.py 62 Surface plot Q3P2.py Surface Plot.py 63 Ill External Libraries 64 main () Scratches and Consoles 65 66 67 abNONDOO main( - 3 -2 -1 0 01 2 Run: Peaks Optimization X 3 C: \Users\dela\anaconda3\python. exe "E: /Users/dela/Dropbox/_Cla: Homework 10 Solution - F20/Peaks Optimizati [ 0. 22830006 -1. 62551843] -6.551133325915419 I Z: Structure [-1.34742305 0.20450411] -3.049849397391256 [-0. 0092947 1.58134542] 8. 106213576688221 [-0. 46005125 -0.62920651] 3.77658099159881 2: Favorites I 4: Run TODO 6: Problems 5: Debug Terminal Python Console Event Log 61:18 CRLF UTF-8 4 spaces Python 3.8 2

Answered by Expert Tutors

or nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec alique

ng elit. Nam laec facilisis. Pe

icitur laoreeconsectetur adipiscing elit. Nam lacinia pulvinar to

Step-by-step explanation

acinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor

The student who asked this found it Helpful
Overall rating 100%

"Thank you sir"

Get unstuck

493,444 students got unstuck by Course
Hero in the last week

step by step solutions

Our Expert Tutors provide step by step solutions to help you excel in your courses