How to do Symbolic Optimization in matlab?

25 次查看(过去 30 天)
For example:
syms a b c x;
y = a*x^2 + b*x + c;
gra = gradient(y,x);
solve(gra==0,x)
I got this:
ans =
-b/(2*a)
But when the question is more complex, or includes some constraints, what can i do it more easily?
Is there any "SymbolicOptimization.m" kind functions so that i can do this:
syms a b c x;
y = a*x^2 + b*x + c;
SymbolicOptimization(y,x)
And it gives the answer(I hope):
when a>0, y have globle min at x = -b/(2*a), y=...
when a<0, y have globle max at x= -b/(2*a), y=...
when a=0, y range [-inf, inf].
Yes, What i want is to let computer do the Optimization analysis based on optimization theory.
So how to do it?

采纳的回答

Walter Roberson
Walter Roberson 2020-7-12
No, there is no function for that.
For polynomials, you can proceed by
dy = diff(y, x);
extrema = solve(dy, x);
d2y = diff(dy);
d2y_at_extrema = subs(d2y, x, extrema);
In general, d2y_at_extrema will be symbolic in your coefficients, and you would need to examine each one for the conditions under which each is positive (indicating minima) or negative (indicating maxima) or zero (indicating saddle point).
You will end up having a list of conditions under which each value might be "global" minima or maxima.
When you get beyond degree 5 (and so derivative is degree 4, exactly solvable) you will not be able to list the possibilities.
I suspect that it will be difficult to figure out the conditions for global minima or maxima for degree 4 polynomials.
Multinomials get more complicated.
Non-linear sometimes have closed-form solutions (in some sense of "closed form") but not generally.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by