3
$\begingroup$

I'm trying to check if a system of equations has a solution around a given point, the problem is that I'm using FindRoots and doesn't work when there are a different number of equations and variables, for example:

eq1 = Abs[x]^2 + Abs[y]^2 + Abs[z]^2 + Abs[u]^2 == 1
eq2 = 3 Abs[x]^2 + Abs[y]^2 == Abs[z]^2 + 3 Abs[u]^2

Now FindRoot will not work

FindRoot[{eq1, eq2}, {x, 1/Sqrt[2]}, {y, 0}, {z, 0}, {u, 1/Sqrt[2]}]

FindRoot::nveq: "The number of equations does not match the number of variables in FindRoot[{eq1,eq2},{x,1/Sqrt[2]},{y,0},{z,0},{u,1/Sqrt[2]}]"

I can bypass this problem by including eq1 and eq2 twice

FindRoot[{eq1, eq1, eq2, eq2}, {x, 1/Sqrt[2]}, {y, 0}, {z, 0}, {u, 1/Sqrt[2]}]

{x -> 0.707107, y -> 0., z -> 0., u -> 0.707107}

Now, I also have the problem to have more equations that variables, is there other command or list or commands which allow me to do the same without the restriction of need the same number of equations than variables

$\endgroup$
  • $\begingroup$ I'd say try minimizing the sum of squares of differences. $\endgroup$ – Daniel Lichtblau Dec 1 '14 at 19:49
2
$\begingroup$

Because you have two equations and four unknowns, you have a two-fold infinity of solutions. Your FindRoot calculation has given you just one of them. You can Solve for them as follows.

Solve[{eq1, eq2}, {u, z}]

with the solution

{{u -> -(Sqrt[-1 + 4*Abs[x]^2 + 2*Abs[y]^2]/Sqrt[2]), z -> -(Sqrt[3 - 6*Abs[x]^2 - 4*Abs[y]^2]/Sqrt[2])}, 
 {u -> Sqrt[-1 + 4*Abs[x]^2 + 2*Abs[y]^2]/Sqrt[2], z -> -(Sqrt[3 - 6*Abs[x]^2 - 4*Abs[y]^2]/Sqrt[2])}, 
 {u -> -(Sqrt[-1 + 4*Abs[x]^2 + 2*Abs[y]^2]/Sqrt[2]), z -> Sqrt[3 - 6*Abs[x]^2 - 4*Abs[y]^2]/Sqrt[2]}, 
 {u -> Sqrt[-1 + 4*Abs[x]^2 + 2*Abs[y]^2]/Sqrt[2], z -> Sqrt[3 - 6*Abs[x]^2 - 4*Abs[y]^2]/Sqrt[2]}}

To visualize, say, the fourth solution, use

{fu, fz} = {u, z} /. Solve[{eq1, eq2}, {u, z}][[4]];
Plot3D[%, {x, 0, 2}, {y, 0, 2}, PlotStyle -> {Red, Blue}, PlotLegends -> {u, z}]

Solution 4

Any point {x,y} that has solutions {u,v} on both curves satisfies your equation.

$\endgroup$
1
$\begingroup$

It is not an independent answer, but some modification of the previous one. One can make an evident replacement:

eq1 = Abs[x]^2 + Abs[y]^2 + Abs[z]^2 + Abs[u]^2 == 
   1 /. {Abs[x] -> Sqrt[X], Abs[y] -> Sqrt[Y], Abs[z] -> Sqrt[Z], 
   Abs[u] -> Sqrt[U]}
eq2 = 3 Abs[x]^2 + Abs[y]^2 == 
   Abs[z]^2 + 3 Abs[u]^2 /. {Abs[x] -> Sqrt[X], Abs[y] -> Sqrt[Y], 
   Abs[z] -> Sqrt[Z], Abs[u] -> Sqrt[U]}

(*   U + X + Y + Z == 1

3 X + Y == 3 U + Z   *)

yielding a simple linear system. We know about linear systems everything. It can be solved as usually:

Solve[{eq1, eq2}, {X, Y}]

yielding

(*  {{X -> 1/2 (-1 + 4 U + 2 Z), Y -> 1/2 (3 - 6 U - 4 Z)}}  *)

That's all one can do without any additional assumptions. Say, one may be interested in a solution where X is minimal and Y is maximal.

$\endgroup$

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.