![function [y]=fofx(x) y=x^3+2x^2-111*x+108 end](http://img.homeworklib.com/questions/d42e5650-2519-11eb-ae83-fd0b026e79ac.png?x-oss-process=image/resize,w_560)
`Hey,
Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
clc%clears screen
clear all%clears history
close all%closes all files
format long
disp('For minimum');
golden(@fofx,-10,7,1e-5,'min')
disp('For maximum');
golden(@(x) -fofx(x),-10,7,1e-5,'max')
function golden(fofx,a,b,epsilon,s)
iter= 50; % maximum number of iterations
tau=double((sqrt(5)-1)/2); % golden proportion coefficient, around
0.618
k=0; % number of iterations
x1=a+(1-tau)*(b-a); % computing x values
x2=a+tau*(b-a);
f_x1=fofx(x1); % computing values in x points
f_x2=fofx(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=fofx(x1);
f_x2=fofx(x2);
else
a=x1;
x1=x2;
x2=a+tau*(b-a);
f_x1=fofx(x1);
f_x2=fofx(x2);
end
k=k+1;
end
% chooses minimum point
if(f_x1<f_x2)
if(strcmp(s,'max'))
f_x1=-f_x1;
end
sprintf('x_%s=%f', s,x1)
sprintf('f(x_%s)=%f ', s,f_x1)
else
if(strcmp(s,'max'))
f_x2=-f_x2;
end
sprintf('x_%s=%f', s,x2)
sprintf('f(x_%s)=%f ', s,f_x2)
end
end
function y=fofx(x)
y=(x.^3+2*x.^2-111*x+108);
end

Kindly revert for any queries
Thanks.
using matlab, and fibonacci. i have included the picture of the function fofx i believe problem...
I need help with this code. Im using C++ coding. Non Recursive (iterative) Fibonacci Write a program that uses a for loop to calculate a Fibonacci sequence (NOT RECURSIVE!!!) up to a given position, starting with position 0. This function defines a Fibonacci sequence: If the number is 0, the function returns a 0 If the number is 1, the function returns a 1 If the number is higher than 1, it returns the sum of the previous two numbers...
4. One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence approaches a number called "the golden ratio". Create a program that accepts the first two numbers of a Fibonacci sequence as user input and then calculates additional values in the sequence until the ratio of adjacent values converges to within 0.001 You can do this in a while loop by comparing the ratio of element k to element k...
(a) (4 points) Fill in the blanks in the following MATLAB function M file trap so that it implements the composilu trapezidul rulo, using a soquence of w -1,2, 4, 8, 16,... trapezoids, to approximatel d . This M file uses the MATLAB built-in function trapz. If 401) and y=() f(!)..... fr. 1)). 3= ($1, then the execution of z = trapz(x, y) approximates using the composite trapezoidal rule (with trapezoids). (Note that the entries of are labeled starting at...
I included a picture of what the union of set Un
represents
Problem C. Define a function f:R CX by the formula f(x) = cos(272) + i sin(2x). (a) Verify that f is a homomorphism from (R, +) to (CX,.). (b) Find im(f) and ker(f). (c) Check that f(Q) = {f(x): 2 € Q} coincides with the group UN-, UN ů {ze C]z* = 1} n = 1
Question #1 (15 Marks) a) (8 Marks) Answer the following questions with True or False. 1) 2) 3) Every basic solution in the assignment problem is necessarily degenerate. The assignment problem cannot be solved using the transportation technique. If the gradient vector of a function at a given point is zero, the point can only be a maximum or minimum. If a single-variable function has two local minima, it must have at least one local 4) maximum 5) The Golden...
matlab only
Question 5: a.) Write an m-file using conditional statements to evaluate the following function, assuming that the scalar variable x has a value. The function is for x <-1 - 3e y=2+cos(m) for-1 x<5 y 10-5)+1 for r 2 5 Use your file to evaluate y for x5, x-3, and x-15, and Use keyboard entry for values of x. b.) Use a for loop in the above file to plot the above function over the interval -2x <10....
Please I need help with MATLAB .. PLease help me . Thankyou Write Matlab code to plot a 2D sinc function over a 2D cartesian grid where x ranges from 100 to 355 and y ranges from 0 to 255 and the sinc is centered at somewhere not midway in the grid. First plot the grid, and then plot the function on the grid (both as grayscale and as a surface plot). Comment the code well, generate the figures and...
In matlab, I keep getting the same issue for this problem can
someone help?
"myrowproduct.m" >> Filename myrowproduct (A,x) Undefined function or variable 'Filename' Did you mean: mfilename : myrowproduct (A, x) Undefined function or variable 'myrowproduct' function y = myrowproduct(A,x); function y my rowp roduct (A, x); Error: Function definition not supported in this context. Create functions in code file. (, 2,,)T 4. The product y Ax of an m x n matrix A times a vector x= can...
MATLAB Create a function that provides a definite integration
using Simpson's Rule
Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...
2 6, 9、19/ 1,12 '12,13,16,16, 16,18,3‘ = 12.5 4 IQR=46 Question #1 (15 Marks) a) (8 Marks) Answer the following questions with True or False. 1) Every basic solution in the assignment problem is necessarily degenerate. 2) The assignment problem cannot be solved using the transportation technique. maximum or minimum. If a single-variable function has two local minima, it must have at least one local 4) maximum. 5) The Golden Section Search method gives better results than the Fibanocci Search...