1
$\begingroup$

I have absolutely no experience using Mathematica or similar packages, so please bear in mind with me. I am an IB student that has gotten themselves a copy of Mathematica for the purpose of simply performing Gaussian elimination, a method that I am largely unfamiliar with (as it is not part of our syllabus). System of Equations

I have the above system of equations that I would like to solve, and I have the following numerical values: Coordinates Radii

I would like to ask, how can I apply Gaussian elimination in Mathematica to obtain the following numbers, through solving system S?

Results

Again, I want to mention that I know little about Gaussian elimination and even less about Mathematica, which is the reason I came to this exchange. Any help would be really greatly appreciated, thanks in advance!


{
 2 (x2 - x1) x + 2 (y2 - y1) y + 2 (z2 - z1) z == r1^2 - x1^2 - r2^2 + x2^2,
 2 (x3 - x1) x + 2 (y3 - y1) y + 2 (z3 - z1) z == r1^2 - x1^2 - r3^2 + x3^2,
 2 (x4 - x1) x + 2 (y4 - y1) y + 2 (z4 - z1) z == r1^2 - x1^2 - r4^2 + x4^2,
 x1 == 2088202.299, x3 == 35606984.591,
 y1 == -11757191.37, y3 == 94447027.237,
 z1 == 25391471.881, z3 == 9101378.572,
 x2 == 11092568.240, x4 == 3966929.048,
 y2 == -14198201.090, y4 == 7362851.831,
 z2 == 21471165.950, z4 == 26388447.172,
 r1 == 23204698.51, r2 == 21585835.37,
 r3 == 31364260.01, r4 == 24966798.73
}
$\endgroup$
2
  • $\begingroup$ Solve[] is what you want; look at the second example in the linked doc page. The only tricky thing here is that you can't use subscripts here, so you would need to write e.g. the first equation as 2 (x2 - x1) x + 2 (y2 - y1) y + 2 (z2 - z1) z == r1^2 - x1^2 - r2^2 + x2^2. $\endgroup$ Dec 15 '21 at 20:11
  • $\begingroup$ Omit the commas in the number. $\endgroup$
    – josh
    Dec 15 '21 at 20:25
6
$\begingroup$

If you really want to use Gaussian elimination (HW requirement) then you can do the following:

Clear["Global`*"]
eqs = {2 (x2 - x1) x + 2 (y2 - y1) y + 2 (z2 - z1) z == 
    r1^2 - x1^2 - r2^2 + x2^2, 
   2 (x3 - x1) x + 2 (y3 - y1) y + 2 (z3 - z1) z == 
    r1^2 - x1^2 - r3^2 + x3^2, 
   2 (x4 - x1) x + 2 (y4 - y1) y + 2 (z4 - z1) z == 
    r1^2 - x1^2 - r4^2 + x4^2};
par = {x1 -> 2088202.299, x3 -> 35606984.591, y1 -> -11757191.37, 
   y3 -> 94447027.237, z1 -> 25391471.881, z3 -> 9101378.572, 
   x2 -> 11092568.240, x4 -> 3966929.048, y2 -> -14198201.090, 
   y4 -> 7362851.831, z2 -> 21471165.950, z4 -> 26388447.172, 
   r1 -> 23204698.51, r2 -> 21585835.37, r3 -> 31364260.01, 
   r4 -> 24966798.73};
eqs = eqs /. par
vars = {x, y, z};
{b, A} = Normal@CoefficientArrays[eqs, vars];
Row[{"we need to solve ", MatrixForm@A . MatrixForm@vars == MatrixForm[-b]}]

Mathematica graphics

Now you can do Gaussian elimination using displayRREF which gives

displayRREF[A, -b]

Mathematica graphics

Mathematica graphics

Mathematica graphics

Mathematica graphics

To verify, you can use NSolve as suggested, or use

 LinearSolve[A, -b] // MatrixForm

Mathematica graphics

$\endgroup$
3
$\begingroup$

Typing in your equations, then using NSolve:

eqs = {
   2 (x2 - x1) x + 2 (y2 - y1) y + 2 (z2 - z1) z == r1^2 - x1^2 - r2^2 + x2^2,
   2 (x3 - x1) x + 2 (y3 - y1) y + 2 (z3 - z1) z == r1^2 - x1^2 - r3^2 + x3^2,
   2 (x4 - x1) x + 2 (y4 - y1) y + 2 (z4 - z1) z == r1^2 - x1^2 - r4^2 + x4^2,
   x1 == 2088202.299,   x3 == 35606984.591,   y1 == -11757191.37,
   y3 == 94447027.237,   z1 == 25391471.881,   z3 == 9101378.572,
   x2 == 11092568.240,   x4 == 3966929.048,   y2 == -14198201.090,
   y4 == 7362851.831,   z2 == 21471165.950,   z4 == 26388447.172,
   r1 == 23204698.51,   r2 == 21585835.37,   r3 == 31364260.01,
   r4 == 24966798.73
};

NSolve[eqs]

(* Out: {
 {r1 -> 2.32047*10^7, r2 -> 2.15858*10^7, r3 -> 3.13643*10^7, 
  r4 -> 2.49668*10^7, x1 -> 2.0882*10^6, x2 -> 1.10926*10^7, 
  x3 -> 3.5607*10^7, y1 -> -1.17572*10^7, y3 -> 9.4447*10^7, 
  x4 -> 3.96693*10^6, y4 -> 7.36285*10^6, z1 -> 2.53915*10^7, 
  z4 -> 2.63884*10^7, z3 -> 9.10138*10^6, y2 -> -1.41982*10^7, 
  z2 -> 2.14712*10^7,
  x -> -2.99306*10^6, y -> 1880.12, z -> -3.12609*10^7}
} *)

You will notice that the results for $x$, $y$, $z$ are similar, but not identical, to those you proposed.

$\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.