Group Abstract Group Abstract

Message Boards Message Boards

0
|
105 Views
|
3 Replies
|
6 Total Likes
View groups...
Share
Share this post:

How to solve this type of vector operation problem?

Posted 5 days ago

enter image description here

Reduce[{Norm[a + b] == 1, Norm[a - b] == Sqrt[3], t == a . b}, t, {a, 
  b}, Reals]

The code above has been running for a long time without producing an answer. How can this problem be solved using code?

POSTED BY: Bill Blair
3 Replies

If such vectors a and b exist, then a.b should be -1/2 provided the context is a real vector space with an inner product (so it doesn't have to be vectors in the plane with the standard dot product). The usual trick on that sort of problem is to square both equations, use the properties of the inner/dot product to break down the left-hand sides into norms and the inner product <a,b> (or a.b), and then add/subtract the equations to eliminate the terms you don't want (in this case the norms/sizes).

I was able to translate that into code (somewhat clumsily) by treating a real vector kx as the list {k,x}, defining a function IP to be the inner product, and then setting the usual properties of the inner/dot product (including relating it to a "Size") for IP:

Clear[IP, Size]
IP[ {1, x_}, {1, y_ + z_}] := IP[{1, x}, {1, y}] + IP[{1, x}, {1, z}]
IP[ {1, x_}, {1, y_ - z_}] := IP[{1, x}, {1, y}] - IP[{1, x}, {1, z}]
IP[{1, x_ + y_}, {1, z_}] := IP[ {1, x}, {1, z}] + IP[{1, y}, {1, z}]
IP[{1, x_ - y_}, {1, z_}] := IP[ {1, x}, {1, z}] - IP[{1, y}, {1, z}]
IP[ {s_, x_}, {t_ , y_}] := s IP[ {1, x}, {t, y}] /; s != 1
IP[{s, x_}, {t_, y_}] := t IP[ {s, x}, {1, y}] /; t != 1
IP[ {1, x_}, {1, x_}] := Size[{1, x}]^2
Attributes[ IP] = {Orderless};

equation1 = IP[ {1, a + b}, {1, a + b}] == 1^2;
equation2 = IP[ {1, a - b}, {1, a - b}] == (Sqrt[3])^2;
Solve[ {equation1, equation2, Size[ {1, a}] >= 0, 
  Size[{1, b}] >= 0}, Reals]

solution to a system of 2 equations

So this gives the value of a.b (written as the horribly cumbersome IP[{1,a}, {1,b}]) as -1/2. Note that conditions in the solution (basically |a|^2+|b|^2=2) aren't if and only if; for example {1,b} really can't have size 0 as it would be the zero vector, in which case the original equations become |a| is both 1 and Sqrt[3] at the same time.

Just a little variation:

sqnrm[v_] := v . v;
With[{a = {a1, a2}, b = {b1, b2}},
 Reduce[{sqnrm[a + b] == 1, sqnrm[a - b] == 3, t == a . b},
  {t, a1, a2, b2, b2}]]
t /. List@ToRules@%
POSTED BY: Gianluca Gorni
Posted 5 days ago

My guess is that $a.b=-1/2$. I think the problem is in part that Mathematica doesn't know that $a$ and $b$ are vectors unless you make that explicit.

a = {a1, a2};
b = {b1, b2};
eq1 = Simplify[Norm[a + b]^2 == 1,  Assumptions -> {a1 \[Element] Reals, a2 \[Element] Reals, 
    b1 \[Element] Reals, b2 \[Element] Reals}]'
eq2 = Simplify[Norm[a - b]^2 == 3, Assumptions -> {a1 \[Element] Reals, a2 \[Element] Reals, 
    b1 \[Element] Reals, b2 \[Element] Reals}];
Reduce[{eq1, eq2, a . b == k}, k]

Equations where k = -1/2

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard