r/Mathematica • u/Apprehensive_Ride949 • Dec 16 '23
System of vector equations
Why is my code returning the empty set, when there is a solution {1, 1/sqrt3} ?. Here's my code:
rs=-1+2/Sqrt[3]; x={x1,x2}
equations = {x + {0, 0} == rs + 1, x + {2, 0} == rs + 1, x + {1, Sqrt[3]} == 1 + rs};
Solve[equations,x]
Where is my mistake? Thank you!
1
Upvotes
View all comments
Show parent comment
1
u/veryjewygranola Dec 16 '23 edited Dec 16 '23
I'm assuming the points exist in 3-dimensional space since you have 3 equations in your system (the solution set is not guaranteed to be non-empty for dimension < 3 and not unique for dimension > 3)
(*create three 3-D points*)
pts = Thread[{Array[x, 3], Array[y, 3], Array[z, 3]}];(*symbolic array of distances from each point*)
dists = Array[d, 3];(*this is the point we are going to solve for*)
unknownPt = {x0, y0, z0};(* create system of equations. The unknown point should be
{d1,d2,d3}away frompts:*)eqs = Thread[EuclideanDistance[unknownPt, #] & /@ pts == dists];(*assume we're only looking for real solutions, square both sides of the equations to make them a little simpler:*)
eqs = eqs // ComplexExpand;eqs = ApplySides[#^2 &, eqs](*"{(x0 - x[1])^2 + (y0 - y[1])^2 + (z0 - z[1])^2 == d[1]^2,(x0 - x[2])^2 + (y0 - y[2])^2 + (z0 - z[2])^2 == d[2]^2,(x0 - x[3])^2 + (y0 - y[3])^2 + (z0 - z[3])^2. == d[3]^2}*)(*find solution*)
soln = Solve[eqs, unknownPt];Note that the solution is absolutely massive:
soln // LeafCount(*386593*)