Ask Your Question

asdrubalivan's profile - activity

2015-02-18 23:28:57 +0100 received badge  Famous Question (source)
2015-01-13 21:26:44 +0100 received badge  Taxonomist
2013-12-05 11:12:00 +0100 received badge  Notable Question (source)
2013-07-04 09:25:19 +0100 received badge  Popular Question (source)
2012-04-20 00:59:02 +0100 commented answer Set global precision for reals?

I was searching anything like this for a long time!! Thanks a lot :) PS: Sorry for my english, that is not my mother tongue.

2012-04-19 18:06:05 +0100 commented answer How can I find the maximum of a two variable function?

Yes!! This works perfectly! Thanks a lot :)

2012-04-19 18:05:45 +0100 marked best answer How can I find the maximum of a two variable function?

I just took a few minutes to modify the example from this page http://www.sagemath.org/doc/reference... I apologize in advance if there is a mistake. Basically there isn't a function to maximize with constraint. So what we can do is minimize the negative of the function. The constraints are of the for '>0' for example c_1 tells the solver that x>0, c_2 tells that -x+1 > 0 => x<1 and so on

f = lambda p: - p[0]*p[1] + p[1]*p[1]
c_1 = lambda p: p[0]
c_2 = lambda p: - p[0] + 1
c_3 = lambda p: p[1]
c_4 = lambda p: -p[1] + 2
a = minimize_constrained(f,[c_1, c_2,c_3,c_4],[0.5,0.5])
view(a)

The answer I get is (1.0,0.5001)

If I plot the negative of the function in the range you are interested, the minimum looks like it is around that.

image description

Let me know if this works.

2012-04-19 18:05:45 +0100 received badge  Scholar (source)
2012-04-12 01:24:00 +0100 received badge  Student (source)
2012-04-11 22:45:26 +0100 received badge  Supporter (source)
2012-04-11 22:35:03 +0100 asked a question How can I find the maximum of a two variable function?

Hello everyone, I'm trying to find the maximum of the following function:

var('x,y')
func(x,y) = x*y - y^2

Is there any way I can find the maximum of that function (func) when 0 < x < 1 and 0 < y < 2 for example?

Thanks in advance :)