# How can I solve a set of equations with variables and eliminate a few variables at the same time?

I just started learning Mathematica since I needed for my current research. I'm trying to solve a set of equations with different variables, eliminate a few variables in the set, and express one variable by others in just one equation. But Mathematica won't give me that answer~ Actually to make the question clearer, here is my code:

hump[EM_, x_, y_, z_, Pa_, Pb_, miu_] :=
1/(2 EM (y^3 - x^3) z^2) (2 (Pa x^3 - Pb y^3) (1 - 2 miu) z^3 + (Pa -
Pb) (1 + miu) x^3 y^3)

u0d = hump[E0, c, d, d, P1, P0, miu0]
u0c = hump[E0, c, d, c, P1, P0, miu0]
u1c = hump[E1, b, c, c, P2, P1, miu1]
u1b = hump[E1, b, c, b, P2, P1, miu1]
u2b = hump[E2, a, b, b, P3, P2, miu2]
u2a = hump[E2, a, b, a, P3, P2, miu2]
u3a = hump[E3, a, 0, a, P3, 0, miu3]
ud = hump[E0, d, 0, d, P0, 0, miu0]

eqn = {ud == u0d, u0c == u1c, u1b == u2b, u2a == u3a}

Solve[eqn, {E0}, {P0, P1, P2, P3}]


As you see, I'm eliminating P0, P1, P2, P3 in the equation set and wanna have an expression for E0.

It took me more than two weeks trying to figure it out however failed, and nobody that I know had ever used Mathematica... So can anybody help me with it? Thanks~

• Luckily, everything is algebraic. Unluckily, this looks like a rather complicated multivariate system. Consider using GroebnerBasis[] as a preprocessor, before feeding the entire mess to Solve[]. – J. M.'s technical difficulties Jun 9 '16 at 6:29
• Please put the code in the code delimiters to make your question easier to read. For example – jackskis Jun 9 '16 at 22:52
• You are eliminating four variables from four equations. In general that will leave nothing remaining. – Daniel Lichtblau Jun 11 '16 at 2:02

The system is linear and homogeneous in the P's, so has the trivial solution {P1,P2,P3,P4}=0

We can put this into matrix form:

eqn = Simplify[{ud == u0d, u0c == u1c, u1b == u2b, u2a == u3a}]
m = Transpose@
Table[ Coefficient[#[] - #[], v] & /@
Simplify[eqn] , {v, {P0, P1, P2, P3}}] // Simplify;


verify..

Table[ Simplify[
m[[k]].{P0, P1, P2, P3} == eqn[[k, 1]] - eqn[[k, 2]] ], {k, 4}]


{True,True,True,True}

this is an eigenvalue problem, there are non trival P solutions if:

Solve[ Simplify[Det[m]] == 0 , E0]


which after simplification gives a not-too-nasty solution for E0:

(E1 (-1 + 2 miu0) (2 a^3 (b^3 (E1 + 2 E2 - 4 E2 miu1 + E1 miu2) + c^3 (E2 (1 + miu1) - E1 (1 + miu2))) (E3 - 2 E3 miu2 + E2 (-1 + 2 miu3)) - b^3 (c^3 (2 E1 + E2 + E2 miu1 - 4 E1 miu2) + 2 b^3 (E2 - 2 E2 miu1 + E1 (-1 + 2 miu2))) (-E3 (1 + miu2) + E2 (-2 + 4 miu3))))/(a^3 (b^3 (1 + miu1) (E1 + 2 E2 - 4 E2 miu1 + E1 miu2) + 2 c^3 (-1 + 2 miu1) (E2 (1 + miu1) - E1 (1 + miu2))) (E3 - 2 E3 miu2 + E2 (-1 + 2 miu3)) - b^3 (c^3 (-1 + 2 miu1) (2 E1 + E2 + E2 miu1 - 4 E1 miu2) + b^3 (1 + miu1) (E2 - 2 E2 miu1 + E1 (-1 + 2 miu2))) (-E3 (1 + miu2) + E2 (-2 + 4 miu3)))

• Shouldn't NullSpace[] be then a more efficient way to get to the answer? – J. M.'s technical difficulties Jun 11 '16 at 12:13
• @J.M. that is the next step if you want the non trivial P solution you do NullSpace[m/.E0->(E1 (-1 + 2 miu0) (2 a^3 (b^....] I'm sure its quite unwieldy so i didn't even try it. – george2079 Jun 11 '16 at 17:06
• Wow! Thanks George! that helps a lot~ – Hao Jun 13 '16 at 20:50