Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

Can sage do symbolic optimization?

asked 7 years ago

anonymous user

Anonymous

I know sage has many functions to do numerical optimization.

Now, I am wondering if sage can do symbolic optimization as well.

For example, if I wanted to maximize a function using numerical methods, I could do this:

f(x,y) = -(x * log(x) + y * log(y))
minimize(-f,[0.1, 0.1])

Which gives the answer:

(0.367880005621,0.367880005621)

Is there a function that can give the solution as (1e,1e) or do I have to compute the stationary points and perform the necessary substitutions myself?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 7 years ago

mforets gravatar image

updated 7 years ago

The particular case is readily solved with Sage:

sage: stationary_points = lambda f : solve([gi for gi in f.gradient()], f.variables())
sage: f(x,y) = -(x * log(x) + y * log(y))
sage: stationary_points(f)
[[x == e^(-1), y == e^(-1)]]

More generally, f(x1,,xn)=0 is a necessary and sufficienty condition for optimality provided that f is twice continuously differentiable and convex (see e.g. BV Ch. 9.1 page 457). In this setting, we can use stationary_points as above, but in general the solve function will fail to find explicit solutions. Indeed, from that book:

"In a few special cases, we can find an optimal solution by analytically solving the optimality equation, but usually the problem must be solved by an iterative algorithm."

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 7 years ago

Seen: 1,407 times

Last updated: Jun 24 '17