Question

Check my we Use the golden-section method to solve for the value of x that maximizes 14--1.5X6-2/4 + 12x Employ initial guess
0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOLUTION :

Matlab code:

a=0;                            % start of interval
b=2;                            % end of interval
epsilon=0.000001;               % accuracy value
iter= 3;                       % maximum number of iterations
tau=double((sqrt(5)-1)/2);      % golden proportion coefficient, around 0.618
k=0;                            % number of iterations
function r = f(x)
r = -1.5*x^6 - 2*x^4 + 12*x;
end

x1=a+(1-tau)*(b-a);             % computing x values
x2=a+tau*(b-a);

f_x1=f(x1);                     % computing values in x points
f_x2=f(x2);

while ((abs(b-a)>epsilon) && (k<iter))
    k=k+1;
    if(f_x1>f_x2)
        b=x2;
        x2=x1;
        x1=a+(1-tau)*(b-a);
    
        f_x1=f(x1);
        f_x2=f(x2);
    else
        a=x1;
        x1=x2;
        x2=a+tau*(b-a);
    
        f_x1=f(x1);
        f_x2=f(x2);
    end

    sprintf('Iteration %d: x1=%f, f(x1)=%f, x2=%f, f(x2)=%f', k, x1, f_x1, x2, f_x2)
end


% chooses maximum point
if(f_x1<f_x2)
    sprintf('x_max=%f', x2)
    sprintf('f(x_max)=%f ', f_x2)
else
    sprintf('x_max=%f', x1)
    sprintf('f(x_max)=%f ', f_x1)
end

Output:

Iteration 1: x1=0.472136, f(x1)=5.549637, x2=0.763932, f(x2)=8.187885
Iteration 2: x1=0.763932, f(x1)=8.187885, x2=0.944272, f(x2)=8.677842
Iteration 3: x1=0.944272, f(x1)=8.677842, x2=1.055728, f(x2)=8.107398
x_max=0.944272
f(x_max)=8.677842

Hence max value of f(x) rounded upto 4 decimals is 8.6778

Add a comment
Know the answer?
Add Answer to:
Check my we Use the golden-section method to solve for the value of x that maximizes...
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
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