# assume(x, 'real') returns non-real values when solving

%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)

# find where both are simultaneously equal to zero.

# the syntax is solve([system, of, equations, to, solve], variables, to, solve, for)

# 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 == -2*I*sqrt(3) - 2, y == -1/4*I*sqrt(3) - 1/4], [x == 2*I*sqrt(3) - 2, y == 1/4*I*sqrt(3) - 1/4]]
Why is it giving non-real values?

Which value is non-real?

Welcome to Ask Sage.

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

will produce:

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?