Question

5. i) Modify some of the Python code developed in Week11.ipynb to min- imize the function 25 – 12x3 + 7x2 + 2x + 7 on the int

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

1)

import scipy.optimize
f=lambda x: x**5-12*x**3+7*x**2+2*x+7
xopt = scipy.optimize.fmin(func=f, x0=[1]);
print("Minimum value is");
print(f(xopt));

2)

import scipy.optimize
f=lambda x: 100*(2*x[1]-x[0]*x[0])*(2*x[1]-x[0]*x[0])+x[0]*(1-x[1]);
xopt = scipy.optimize.fmin(func=f, x0=[1,-1]);
print("Minimum value is");
print(f(xopt));

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
5. i) Modify some of the Python code developed in Week11.ipynb to min- imize the function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need to modify my C++ code so it can get the min value of the...

    I need to modify my C++ code so it can get the min value of the stack code is as follows: #include <iostream> using namespace std; #define MAX_SIZE 100 class Stack { private: int S[MAX_SIZE]; int top; public: Stack() {   top = -1; } void push(int x) {   if (top == MAX_SIZE - 1) {    cout << "Stack is Full." << endl;    return;   }   S[++top] = x; } void pop() {   if (top == -1) {    cout << "Stack is...

  • for this code fix the smtax error this is a python code for some reason my...

    for this code fix the smtax error this is a python code for some reason my code isnt liking my returns and it bring up other symtax error so fix the following code answer should pop out the following when runned 1/ 2 + 1/ 3 + 1/ 12 = 11/12 z=' ' def math(x,y):     global z     if y==0 or x==0:         return     if y%x ==0:         z=("1/"+str(int(y/x))         return      if x%y ==0         z+=(int(x/y))    ...

  • i need the code on matlab or octave for ploting this function in the interval [0,3]...

    i need the code on matlab or octave for ploting this function in the interval [0,3] i also need a copy of the graph x2-2x + 1 f(x) = 2

  • Encapsulate the following Python code from Section 7.5 in a function named my_sqrt that takes a...

    Encapsulate the following Python code from Section 7.5 in a function named my_sqrt that takes a as a parameter, chooses a starting value for x, and returns an estimate of the square root of a. while True: y = (x + a/x) / 2.0 if y == x: break x = y Part 2 Write a function named test_sqrt that prints a table like the following using a while loop, where "diff" is the absolute value of the difference between...

  • Using python Here is the code import turtle def draw_triangle(vertex, length, k): ''' Draw a ...

    Using python Here is the code import turtle def draw_triangle(vertex, length, k): ''' Draw a triangle at depth k given the bottom vertex.    vertex: a tuple (x,y) that gives the coordinates of the bottom vertex. When k=0, vertex is the left bottom vertex for the outside triangle. length: the length of the original outside triangle (the biggest one). k: the depth of the input triangle. As k increases by 1, the triangles shrink to a smaller size. When k=0, the...

  • For each relation below, determine the following.(i) Is it a function? If not, explain why not...

    For each relation below, determine the following.(i) Is it a function? If not, explain why not and stop. Otherwise, answer part (ii).(ii) What are its domain and image? (a){(x, y) :x, y∈Z, y- 2x}. (b){(x, y) :x, y∈Z, xy- 0}. (c){(x, y) :x, y∈Z, y-x2}. (d){(x, y) :x, y∈Z, x|y}. (e){(x, y) :x, y∈Z, x+y= 0}. (f){(x, y) :x, y∈R, x2+y2= 1}.

  • Write the code in python 5. (10 points) Write a function that takes a square matrix...

    Write the code in python 5. (10 points) Write a function that takes a square matrix and compute the summation of items on both diagonals. Example: 9 13 5 27 1 11X76 6 0 7 102

  • From the graph of the function, state the intervals on which the function is increasing, decreasing,...

    From the graph of the function, state the intervals on which the function is increasing, decreasing, or constant The function is increasing on what interval? O A. (-1, o0) OB. 14, oo) О с. (4.00) O D. I-1,00 The function is constant on what interval? O A. 1-4,4 O B. (-4,4) O C. (-1,8) The function is decreasing on what interval? 0 A. [-4, 41 O c. (-1, oo) O D. (-0, -4) Click to select your answer Find (f...

  • Number 3 please 1. Diaw some Boquants for this production function (1.2) = min {x1 +...

    Number 3 please 1. Diaw some Boquants for this production function (1.2) = min {x1 + x2, 2x2). (6 points) 2. Consider this production function f(x1,x2) = x, + x,. Does it exhibit decreasing, constant, or increasing returns to scale? (6 points) 3. A competitive firm has the production function y=Z, where y is the quantity of output and Z the amount of labor used. (a) Suppose the hourly wage rate for labor is w = $10 and the price...

  • PYTHON:please display code in python Part 1: Determining the Values for a Sine Function Write a...

    PYTHON:please display code in python Part 1: Determining the Values for a Sine Function Write a Python program that displays and describes the equation for plotting the sine function, then prompts the user for the values A, B, C and D to be used in the calculation. Your program should then compute and display the values for Amplitude, Range, Frequency, Phase and Offset. Example input/output for part 1: Part 2: Displaying a Vertical Plot Header A vertical plot of the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT