[Solved]Building Module Optimization Lessons Frequent Tasks Included Finding Zeroes Minima Derivat Q37026274

Building a Module In the optimization lessons, our frequent tasks included finding zeroes, minima, derivatives, and integrals. In this assignment, you will build a small self-contained module which is capable of accepting a function and returning the following 10 points 1. A zero. 2. The global minimum, found by brute force. 3. The local minimum starting fromz-0, found by hill climbing. 4. The derivative of the function at a given point 5. The integral of the function from 0 to a given point Pretend that the text entry box is the entire script itseif defining your module. The autograder will check for the presence and function of each part of your module independenty. We won’t test this with pathological functions that don’t have answers (ike y well sick to wellbehaved functions like y1 and y sin r. Your submission should include: ) which accepts the function and locates a zero. You may use any method provided by Python to locate the zeroes 1. A funcion find zerot fune not f(r)-as a float, not an array or other type.) (This returns which accepts the function and locates the global minimum. You may use any method provided by Python (func 2. A function find global,min( (z*) or discussed in class, but you should find the minimum to within 0 1 % (This returns z. not scipy.optimize.basinhopping is a good approach to find a global minimum. float , not an array or other type ) as a 3. A function find_local min( func,xe) which accepts the function and a starting guess and locates the nearest minimum. You should use a as a flat , not an greedy algorithm like hill climbing (really valley climbing) to find the minimum within 0.1% (This returns r, not f(z array or other type.) scipy.optimize.ninimize is a good appr or other type.) scipy.optimize.ninimize is a good approach to find a local minimum 4. A function find der( func,x) which accepts the function and a target point and returns the derivative of the function at that ponit. You may use any method to determine the derivative within 0.1%. As always, your answer should be a float 5. A function find_int( func,n ) which accepts the function and a right-hand bound for the integral and returns the integral in z from 0 to n. You integral and an error estimate: your and a scipy. integrate. quad returns a tuple with the may use any method to determine the integral within 0.1%, anwer should be a float 6. A function main() which calls each function once in order (at the point z-0 or n-# і if necessary) and print s the results on separate lines with no commentary. The default function in this case should be r2 -cosar A test case for main is: >>> main) 0,5500093499272616 .3354180398964832 0.33541883892819084 1.0014999999583551 0.888137651474563155 Starter code (dick so vew) Answer 1 # Compose your functions here. 3 def f x): 5 import numpy as np # Don’t change this function. 6 return x *2 np.cos(x)+X 8 def nain): 9 pass 11 if-name-·- ·-main_.· 12 main) Show transcribed image text Building a Module In the optimization lessons, our frequent tasks included finding zeroes, minima, derivatives, and integrals. In this assignment, you will build a small self-contained module which is capable of accepting a function and returning the following 10 points 1. A zero. 2. The global minimum, found by brute force. 3. The local minimum starting fromz-0, found by hill climbing. 4. The derivative of the function at a given point 5. The integral of the function from 0 to a given point Pretend that the text entry box is the entire script itseif defining your module. The autograder will check for the presence and function of each part of your module independenty. We won’t test this with pathological functions that don’t have answers (ike y well sick to wellbehaved functions like y1 and y sin r. Your submission should include: ) which accepts the function and locates a zero. You may use any method provided by Python to locate the zeroes 1. A funcion find zerot fune not f(r)-as a float, not an array or other type.) (This returns which accepts the function and locates the global minimum. You may use any method provided by Python (func 2. A function find global,min( (z*) or discussed in class, but you should find the minimum to within 0 1 % (This returns z. not scipy.optimize.basinhopping is a good approach to find a global minimum. float , not an array or other type ) as a 3. A function find_local min( func,xe) which accepts the function and a starting guess and locates the nearest minimum. You should use a as a flat , not an greedy algorithm like hill climbing (really valley climbing) to find the minimum within 0.1% (This returns r, not f(z array or other type.) scipy.optimize.ninimize is a good appr or other type.) scipy.optimize.ninimize is a good approach to find a local minimum
4. A function find der( func,x) which accepts the function and a target point and returns the derivative of the function at that ponit. You may use any method to determine the derivative within 0.1%. As always, your answer should be a float 5. A function find_int( func,n ) which accepts the function and a right-hand bound for the integral and returns the integral in z from 0 to n. You integral and an error estimate: your and a scipy. integrate. quad returns a tuple with the may use any method to determine the integral within 0.1%, anwer should be a float 6. A function main() which calls each function once in order (at the point z-0 or n-# і if necessary) and print s the results on separate lines with no commentary. The default function in this case should be r2 -cosar A test case for main is: >>> main) 0,5500093499272616 .3354180398964832 0.33541883892819084 1.0014999999583551 0.888137651474563155 Starter code (dick so vew) Answer 1 # Compose your functions here. 3 def f x): 5 import numpy as np # Don’t change this function. 6 return x *2 np.cos(x)+X 8 def nain): 9 pass 11 if-name-·- ·-main_.· 12 main)
Expert Answer
Answer to Building a Module In the optimization lessons, our frequent tasks included finding zeroes, minima, derivatives, and inte… . . .
OR

