1
$\begingroup$

I want to find the common positive solutions of two polynomials $f_{a,b}(x,y)$, $g_{a,b}(x,y)$ where $a,b$ runs from 0 to 1 with an interval 0.01. Let $(x_0,y_0)$ be a common positive solution. Then I want evaluate a third polynomial $h_{a,b}(x_0,y_0)$. If this value is less than zero, I will change $b$ accordingly.

I have this tried in Mathamatica but could not succeed as follows: b=0 For[$a=0,a<1,a=a+0.01$, Solve[{$x^2$-$ax$+$by$==0, $2xa+y^2-5ab==0$},{$x,y$}]].

2 Answers 2

2

First, remember that Solve[] returns its solutions as "rules" of the form {{x -> (*something*), y -> (*something*)}, ...}; what you can then do is {x, y} /. Solve[(*stuff*)] and then use the Select[] function accordingly (by construcing an appropriate test function, perhaps using > or Positive[]), after which you can then substitute into your third expression.

  • 1
    To add to Dennis's solution (since I can't comment there), you have the choice of joining together equations and inequalities with `||` and `&&`, or collecting them in a list, like `Reduce[{x^2 - a x + b y == 0, 2 x a + y^2 - 5 a b == 0, x > 0, y > 0}, {x, y}]`. You can then use `ToRules[]` for postprocessing the output of `Reduce[]`. Note that it is a good idea to use `1/100` instead of `0.01` as the increment here so that you are working with exact values all throughout.2011-06-30
1

Try the following:

Table[Reduce[ x^2 - a x + b y == 0 && 2 x a + y^2 - 5 a b == 0, {x, y}], {a, 0, 1, 0.01}, {b, 0, 1, 0.01}]

  • 0
    Ok. Thanks for your help.2011-07-23