Problem in putting limit to the variable
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I want to find the maximum value of f for x between 0 and 0.9. Please tell how can I put the limit to x in this code.
syms x
0<x & x<0.9;
f=0.3*(x-0.6)*(x-0.9)-0.9*cos(0.6)*x*(x-0.9)+0.6*cos(0.9)*x*(x-0.6)-cos(x);
f2 = diff(f,x)==0;
extreme_points = vpasolve(f2==0,x);
extreme_values = subs(f, x, extreme_points);
extreme_values
0 comentarios
Respuestas (1)
Ameer Hamza
el 27 de Nov. de 2020
'x' is already in this range. You are printing the value of 'extreme_values', not 'extreme_points'
syms x
f=0.3*(x-0.6)*(x-0.9)-0.9*cos(0.6)*x*(x-0.9)+0.6*cos(0.9)*x*(x-0.6)-cos(x);
f2 = diff(f,x)==0;
extreme_points = vpasolve(f2==0,x);
extreme_values = subs(f, x, extreme_points);
Result
>> extreme_points
extreme_points =
0.0061113661628718004024766518326605 % greater than 0
>> extreme_values
extreme_values =
-0.83801606593057221627803628819248
In general, you can specify the range in vpasolve like this
extreme_points = vpasolve(f2==0,x, [0 0.9]);
0 comentarios
Ver también
Categorías
Más información sobre Quantum Computing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!