%sage %var x, y

# our function

f(x,y) = x*y + 8/x + 1/y

# first order partial derivatives

fx(x,y) = diff(f(x,y), x) fy(x,y) = diff(f(x,y), y)

# To keep from finding any complex number solutions, we tell sage to assume that x and y are real numbers

assume(x, 'real') assume(y, 'real') solutions = solve([fx(x,y) == 0, fy(x,y) == 0], x, y) solutions

returns [[x == 4, y == (1/2)], [x == -2Isqrt(3) - 2, y == -1/4Isqrt(3) - 1/4], [x == 2Isqrt(3) - 2, y == 1/4Isqrt(3) - 1/4]] Why is it giving non-real values?

edit retag close merge delete

1

To display inline code, use backticks. To display blocks of code or error messages, separate them by a blank line from the rest of the text, and indent them with 4 spaces, or select code lines and click the "code" button (the icon with '101 010').

For instance, typing

If we define f by

def f(x, y):
return (x, y)

then f(2, 3) returns (2, 3) but f(2) gives:

TypeError: f() takes exactly 2 arguments (1 given)


will produce:

If we define f by

def f(x, y):
return (x, y)


then f(2, 3) returns (2, 3) but f(2) gives:

TypeError: f() takes exactly 2 arguments (1 given)


Can you edit your question to do that?

When you say "Why is it giving non-real values?", I assume you mean "Why aren't the values returned as floating-point numbers?"... Right?