필터 지우기
필터 지우기

Determine the extreme values for the function f(x)

조회 수: 39 (최근 30일)
Duncan Weakley
Duncan Weakley 2020년 12월 8일
답변: Rohit Pappu 2020년 12월 28일
Hi there
I need to determine the extreme values for the function f(x) on the interval [0,4]
I am gridlocked with this
I am trying to use vpa, but only get one answer
I need to determine the local maximum and mininum values as well as global
I need this rounded to 4 decimals, and I dont see how simply reading it of the graph can help since 1. the graph give 3 decimals and 2. I dont see that i can place the cursor accurate enough
syms x
total_function = x.*(cos(x.^2)) - exp(sqrt(x))+x.^3 - 4*(x.^2);
f = x.*(cos(x.^2)) - exp(sqrt(x));
g = x.^3 - 4*(x.^2);
dif = diff(x.*(cos(x.^2)) - exp(sqrt(x))) + diff(x.^3 - 4*(x.^2));
vpasolve(dif == 0, x, 4);
extrema = vpa(ans, 6)
fplot(total_function)
xlim([0 4])
Thank you for your help in advance

답변 (1개)

Rohit Pappu
Rohit Pappu 2020년 12월 28일
To determine the extrema, optimization toolbox can be used . For example
%% Finding local minima in [0,4] using fminbnd
minima = fminbnd(@(y) y.*cos(y.^2) - exp(sqrt(y))+y.^3-4.*(y.^2),0,4);
%% Finding local minima of -f(x) to get the maxima of f(x)
maxima = fminbnd(@(y) -y.*cos(y.^2) + exp(sqrt(y))-y.^3+4.*(y.^2),0,4);
To determine the global extrema, GlobalSearch can be used

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by