subject

Golden Section Search Complete the code doing Golden Section Search for function minimization below. Stop the iteration when your bracket is less than 10-8 wide. You must be sure that you evaluate the objective function only as many times as necessary, and the autograder will check for this. The supplied plotting code shows the evolution of your brackets. Observe how one of the bracket midpoints stays the same from one iteration to the next. The setup code gives the following variables: Name Type f func(float) Description A unimodal function to minimize left end of starting bracket right end of starting bracket a float b float Your code snippet should define the following variables: Name Type a float Description left end of final bracket right end of final bracket b float * 1 import numpy as np 2 import matplotlib. pyplot as plt 3 4 brackets = [] 5 gs = (np. sqrt(5) - 1) / 2 6 m1 = a + (1 - gs) * (b - a) 7 m2 = a + gs (b - a) 8 9 # Begin your modifications below here 10 11. while False: 12 brackets. append([a, mi, m2, b]) 13 14 # End your modifications above here 15 16 # Plotting code below, no need to modify 17 x = np. linspace(-10, 10) 18 plt. plot(x, f(x)) 19 20 brackets = np. array(brackets) 21 names=['a', 'ml', 'm2', 'b'] 22, for i in range(4): 23 plt. plot(brackets[:, i], 3*np. arange(len(brackets)), '.-', label=names[i]) 24 plt. legend)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:00
Fast sportcars the top speeds of sportscars, given in miles per hour, are: 155 mph bmw m5 217 mph lamborghini aventador spyder 205 mph ferrari 488 205 mph nissan gtr 197 mph chevrolet corvette stingray zr1 258 mph bugatti veyron supersport 195 mph dodge viper 270 mph hennessey venom 155 mph bmw m3 195 mph mercedes sl given: topspeeds=[155; 217; 205; 205; 197; 258; 195; 270; 155; 195]; carnames=string(["bmw m5" "lamborghini aventador spyder" "ferrari 488" "nissan gtr" "chevrolet corvette stingray zr1" "bugatti veyron supersport" "dodge viper" "hennessey venom" "bmw m3" "mercedes sl"]); the variable is a rectangular array. write a function called selectcars to identify cars with the top speed within a given range, and display the identified names. the selected cars speed will be in a range given by lowerbound < speed < upperbound. inputs to the function selectcars are: a column array os all car top speeds named topspeeds, the corresponding chara
Answers: 2
question
Computers and Technology, 22.06.2019 17:30
Ou listened to a song on your computer. did you use hardware or software?
Answers: 2
question
Computers and Technology, 23.06.2019 03:50
Iam a bacterium. i cause stomach cramps and diarrhea. i am caused by eating rotten foodssuch as chicken, fish, or eggs. sometimes turtles carry my bacteria.what am i?
Answers: 2
question
Computers and Technology, 24.06.2019 08:20
Evaluate the scenario below and indicate how to handle the matter appropriately. situation: michael received an e-mail from what he thought was his doctor’s office, requesting his social security number. since he had just been in to see his doctor last week, he replied to the e-mail with his social security number.
Answers: 2
You know the right answer?
Golden Section Search Complete the code doing Golden Section Search for function minimization below....
Questions
question
Mathematics, 14.12.2020 18:20
question
English, 14.12.2020 18:20
Questions on the website: 13722360