How can I caculate the range of value of a function by matlab?
29 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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)
xcrit = solve(dx, x, 'returnconditions', true)
dy = diff(f,y)
ycrit = solve(dy, y, 'returnconditions', true);
[ycrit.y, ycrit.conditions]
dz = diff(f,z)
zcrit = solve(dz, z, 'returnconditions', true)
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)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!