How can I caculate the range of value of a function by matlab?

29 views (last 30 days)
I want to find the interval of values in a symbolic function. Suppose that there is a function f(x,y,z)=x^z+2*y^3. And the x>1, 4>y>-3, 2>=z>=-1. How can I use matlab to get the f(x,y,z) range of value? Or could you tell me which code I can get my target? Thank you.
I just reach the step as follow:
syms x y z
f(x,y,z)=x^z+2*y^3

Accepted Answer

Walter Roberson
Walter Roberson on 14 Aug 2021
You need to use calculus to find all the critcal points -- the places where the derivative are 0. Figure out which of the critical points are within the boundaries. Evaluate the function at each of those in-range critical points. Now, also evaluate the function at each combination of boundaries -- for example, minimum x, minimum y, maximum z; minimum x, maximum y, minimum z, and so on. You will end up with 8 boundary values, together with however-many critical points. Now you can take max() and min() to evaluate the range of the function.
syms x y z
assume(x > 1);
assume(-3 < y & y < 4)
assume(-1 <= z & z <= 2)
f = x^z+2*y^3;
dx = diff(f,x)
dx = 
xcrit = solve(dx, x, 'returnconditions', true)
xcrit = struct with fields:
x: [0×1 sym] parameters: [1×0 sym] conditions: [0×1 sym]
dy = diff(f,y)
dy = 
ycrit = solve(dy, y, 'returnconditions', true);
[ycrit.y, ycrit.conditions]
ans = 
dz = diff(f,z)
dz = 
zcrit = solve(dz, z, 'returnconditions', true)
zcrit = struct with fields:
z: [0×1 sym] parameters: [1×0 sym] conditions: [0×1 sym]
x would normally have a critical point at x = 0, since 0^positive = 0, but the assumption is that x > 1
x does have a critcal point at x = infinity and z < 0, which solve() has missed.
A moment thought experiment: since x can be infinite, and z can be positive, then the upper range of the function has to be infinity. The x^z term cannot be negative for positive x, but infinity^-1 is 0 so it can be 0; therefore the minima of the function is determined by the 2*y^3 term, and since y can be negative, the minima of that is going to be at the most-negative y.
The dy solutions of y = 0 are inflection points.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!