How can I solve an equation with two variables where x is the maximum?

Suppose I have an equation - x ^ 2 + y ^ 2 = 100 - obviously, there is more than one solution.
I want Mathematica 8 to give me a solution (where only natural numbers were involved), where x will be maximized (i.e. X = 10, y = 0)
I am new to Mathematica - and really confused what happens ...

+4
source share
1 answer

Without diophantine explicit requirement:

Maximize[{x , x^2 + y^2 == 100}, {x, y}] (* -> {10, {x -> 10, y -> 0}} *) 

Edit

As you can see, the result is a list of two elements. The first element ( 10 ) is the value for x (the function for which maximization is performed). The second element is {x -> 10, y -> 0} , corresponding to the rules for assigning variables in max. Point.

Note that here we maximize x , so the value 10 repeated in both elements, but this is not always the way we usually want to maximize the general function of variables, not vars ourselves.

In this particular case, we have two simple ways to assign the maximum value to x : n :

Using the first list item:

 n = First@Maximize [{x , x^2 + y^2 == 100}, {x, y}] 

Or more general, using the appropriate rule:

 n = x /. Last@Maximize [{x, x^2 + y^2 == 100}, {x, y}] 
+4
source

All Articles