# Finding "nice" solution for under-determined system with constraint?

Consider the following equation:

0 == 32 + 8 a^2 (2 + b) + 4 a (2 + b) (6 + b) - b (-4 (8 + U1 + U2 - W1) + b (-8 + (-2 + U1) U1 - 2 U2 + W1^2 + 2 W2) + 2 (U2^2 + W2^2))


We have two variables U2 and W2 available to us, which we can fix in order to solve this equation. However, there are some constraints:

U2 may not contain W1, and W2 may not contain U1.

I would like to find classes of solutions in variables {U2,W2} satisfying these constraints, so that I can single out some specific "nice" looking solution (i.e. no square roots, as short as possible) to use. Any suggestions on how to do this in Mathematica?

If I understand the question correctly, you wish to obtain a parameterized solution {U2[U1], W2[W1]} from the equation in the question, so that you can vary that parameter to obtain a "nice" solution. One approach is as follows. Define

exp = 32 + 8 a^2 (2 + b) + 4 a (2 + b) (6 + b) - b (-4 (8 + U1 - W1 + U2[U1]) +
b (-8 + (-2 + U1) U1 + W1^2 - 2 U2[U1] + 2 W2[W1]) + 2 (U2[U1]^2 + W2[W1]^2))


and split exp into an expression dependent only on U1 and another dependent only on W1.

su = Flatten@DSolve[D[exp, U1] == 0, U2[U1], U1] /. C[1] -> cu
(* {U2[U1] -> 1/2 (2 + b - Sqrt[4 + 4 b + b^2 - 4 cu + 8 U1 + 4 b U1 - 2 b U1^2]),
U2[U1] -> 1/2 (2 + b + Sqrt[4 + 4 b + b^2 - 4 cu + 8 U1 + 4 b U1 - 2 b U1^2])} *)

sw = Flatten@DSolve[D[exp, W1] == 0, W2[W1], W1] /. C[1] -> cw
(* {W2[W1] -> 1/2 (-b - Sqrt[b^2 + 4 cw - 8 W1 - 2 b W1^2]),
W2[W1] -> 1/2 (-b + Sqrt[b^2 + 4 cw - 8 W1 - 2 b W1^2])} *)


{U2[U1], W2[W1]} now are parameterized in terms of constants {cu, cw}. However, exp == 0 still is to be satisfied. Do so by

FullSimplify[exp /. {su[[1]], sw[[1]]}]
(* 2 (16 + 4 a^2 (2 + b) + 2 a (2 + b) (6 + b) + b (16 + 4 b + cu - cw)) *)


(FullSimplify[exp /. {su[[2]], sw[[2]]}] gives the same result.)

Flatten@Solve[(% /. cu - cw -> c) == 0, c]
(* {c -> -((2 (8 + 12 a + 4 a^2 + 8 b + 8 a b + 2 a^2 b + 2 b^2 + a b^2))/b)} *)


Thus, with cu - cw now known, {U2[U1], W2[W1]} is parameterized in terms of a single constant, say cu + cw, which can be varied to obtain the "nice" solution.

• Unfortunately, the constant cu+cw is not sufficient to kill off the square root in both U2[U1] and W2[W1], but I might be able to tweak my expression to get an extra unfixed constant in to do that. Jul 22 '16 at 12:52