# Why isn't my vector equation solving correctly [closed]

Completely new to Mathematica, started using it yesterday. Don't have the luxury of time to read through a whole long 300 pages manual.

I need to calculate a point on two lines such that the vector between these points its perpendicular to both lines.

Define my points

A = {2, 1, -1};
B = {24, -2, 3};
qa = {23, 21, 3};
qb = {-12, -14, 2};


Solve for t1, and t2, the parameters for which the constraints are satisfied

sol = Solve[{
Dot[(A*t1 + qa) - (B*t2 + qb), A] == 0,
Dot[(A*t1 + qa) - (B*t2 + qb), B] == 0
}, {t1, t2}];


Extracting solutions and obtaining the points to which they refer, from the parameters

res = {a, b} /. sol[];
r1 = res[]
r2 = res[]
p1 = A*r1 + qa;
p2 = B*r2 + qb;


I my test is n, the normal vector

n = Cross[A, B]


I compute the difference vector from the two points

dp = p2 - p1


And check if the dot products are zero

Dot[n, B](* => 0*)


But for dp it is not.

Dot[dp, B] (*=> not zero, but  *)


What is going on?

## closed as off-topic by MarcoB, m_goldberg, Sascha, bbgodfrey, Bob HanlonFeb 15 '17 at 14:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, m_goldberg, Sascha, bbgodfrey, Bob Hanlon
If this question can be reworded to fit the rules in the help center, please edit the question.

• In general it is recommended not to use capitol letters for user defined symbols as they may collide with predefined Mathematica symbols. – Jack LaVigne Feb 15 '17 at 14:56

## 1 Answer

What you did wrong was to not look at the intermediate results you were getting. If you had that you would have seen

res = {a, b} /. sol[]


{a, b}

which is, of course, useless.

What you really want is

{a, b} = {t1, t2} /. sol[]


{-(28017/1685), 166/1685}

Then

p1 = A*a + qa;
p2 = B*b + qb;
{p1, p2}


{{-(17279/1685), 7368/1685, 33072/1685}, {-(16236/1685), -(23922/1685), 3868/1685}}

dp = p2 - p1


{1043/1685, -(6258/337), -(29204/1685)}

Dot[dp, B]


0