I'm solving a system defined by two rays. The rays originate from two points {x,y,z}
and {x,y,z-h}
. They go in directions (unit vectors) {u1,v1,w1}
and {u2,v2,w2}
. The rays are connected by a line segment of length l
. The endpoints of the line segment are t
units down the length of each ray. The variable to solve for is t
.
This solution is all well and good, but I notice in the output I have collections of terms like u1^2 ... + v1^2 ... + w1^2
. I know that {u1,v1,w1}
and {u2,v2,w2}
are unit vectors, so these could be substituted with a 1, and maybe even other simplifications could occur. I modified the solve like so:
This looks like a step in the right direction. (I tried Norm[{u1,v1,w1}]==1
but it had no effect.) So, I tried constraining {u2,v2,w2}
to a unit vector.
Sadly, it blows up to a size even larger than the first output. Doing this last step manually could be "an exercise left up to me," but I'm curious if there's some way I could approach this that yields better results. I thought maybe there was some way to declare a vector as a unit vector, and came across How can I use a unit vector notation found in physic texts? but I wasn't able to glean anything useful from it. How can I let Mathematica know that a vector is a unit vector so that it can use it as a hint in simplifying output?
Solve
by itself does not do everything it can toSimplify
a result. That makesSolve
faster and you can useSimplify
only if need be. ThisFullSimplify[(-h(2w1-2w2)-Sqrt[h^2(2w1-2w2)^2-4(h^2-l^2)(u1^2-2u1*u2+u2^2+v1^2-2v1*v2+v2^2+w1^2-2w1*w2+w2^2)])/(2(u1^2-2u1*u2+u2^2+v1^2-2v1*v2+v2^2+w1^2-2w1*w2+w2^2)), Norm[{u1,v1,w1}]==1&& Norm[{u2,v2,w2}]==1]
gives a substantially smaller result, but only because I have included the second argument toFullSimplify
telling it about two of your assumptions, otherwise Mathematica would never know. With more assumptions an even smaller result? $\endgroup$Replace[Solve[{EuclideanDistance[r1, r2] == l}, t], {u1^2 -> 1 - v1^2 - w1^2, u2^2 -> 1 - v2^2 - w2^2}, {6, 10}] // Simplify
. The idea is that you replace the solution at different "levels" inside the equation. To understand this more check out the help forReplace[]
$\endgroup$