3
$\begingroup$

I have 6 equations: $$\begin{array}{l} x_1^2+y_1^2=(x_2-x_1)^2+(y_2-y_1)^2 \\ x_3^2+(3-y_3)^2=(x_3-x_1)^2+(y_3-y_1)^2 \\ 4[(x_3-x_2)^2+(y_3-y_2)^2]=(4-x_2)^2+y_2^2 \\ x_2^2+y_2^2=4(x_1^2+y_1^2)\\ 4[x_3^2+(3-y_3)^2]=x_1^2+(3-y_1)^2\\ 9[(x_3-y_2)^2+(y_3-y_2)^2]=(4-x_3)^2+y_3^2 \end{array} $$

that I know (if equations are set up correctly) has a real solution inside the right triangle {{0,0},{0,3},{4,0}}. However, NSolve returns the null solution. I was wondering if someone could look at my code and confirm if I am coding it correctly or if NSolve perhaps cannot solve it, suggest an alternate method I could use to do so?

Thanks.

    r1 = Polygon[{{0, 0}, {0, 3}, {4, 0}, {0, 0}}];
eqn1 = x1^2 + y1^2 == (x2 - x1)^2 + (y2 - y1)^2;
eqn2 = x3^2 + (3 - y3)^2 == (x3 - x1)^2 + (y3 - y1)^2;
eqn3 = 4 ((x3 - x2)^2 + (y3 - y2)^2) == (4 - x2)^2 + y2^2;
eqn4 = x2^2 + y2^2 == 4 (x1^2 + y1^2);
eqn5 = 4 (x3^2 + (3 - y3)^2) == x1^2 + (3 - y1)^2;
eqn6 = 9 ((x3 - x2)^2 + (y3 - y2)^2) == (4 - x3)^2 + y3^2;
NSolve[{eqn1 && eqn2 && eqn3 && eqn4 && eqn5 && eqn6 && 
   Element[ {x1, x2, x3, y1, y2, y3}, r1]}, {x1, x2, x3, y1, y2, y3}]
$\endgroup$
9
$\begingroup$

There are a few issues with your code.

  1. Region constrains are incorrect.
  2. Should use Solve instead of NSolve (numerical approximation).

The region constrain is in $\mathbb{R}^2$ but your syntax is for an $\mathbb{R}$ constraint. To check the pairs are in $\mathbb{R}^2$.

Element[Alternatives @@ {{x1, y1}, {x2, y2}, {x3, y3}}, r1]

Mathematica graphics

Use this constraint with Solve produces the answer.

Solve[{eqn1 && eqn2 && eqn3 && eqn4 && eqn5 && eqn6 &&
   Element[Alternatives @@ {{x1, y1}, {x2, y2}, {x3, y3}}, r1]},
 {x1, x2, x3, y1, y2, y3}]
{{x1 -> 4/5, x2 -> 8/5, x3 -> 2/5, y1 -> 3/5, y2 -> 6/5, y3 -> 9/5}}

Hope this helps.

PS: Note that you only need to add the ordered vertices for Polygon as the closure is applied between the first and last vertices. So r1 can be defined as Polygon[{{0, 0}, {0, 3}, {4, 0}}].

$\endgroup$
  • $\begingroup$ You guys are tops in here! :) $\endgroup$ – Dominic Sep 14 at 13:32
  • $\begingroup$ I should point out it took about 40 min for Solve to find the solution above on my machine at 2.2 GHz running ver. 11.1. $\endgroup$ – Dominic Sep 14 at 19:47
  • $\begingroup$ @Dominic Its about 2 seconds in 12.0 on my 4 yr old laptop (2.4 GHz). $\endgroup$ – Edmund Sep 14 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.