# Solving an equation for the length of a vector

This topic is 4158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'd like to solve an equation similar to the following: H(x,p) = |p|^2 + x.p where both x and p are 2-element vectors, |p| is the euclidean norm (vector length) |p| = sqrt( p_x^2 + p_y^2 ), and x.p is the dot product of x and p. I'm trying to solve this for |p| in H(x,p) = 0. Any hints or suggestions on how to go about doing this would be greatly appreciated!

##### Share on other sites
|p|2 + x.p = 0
|p|2 = -x.p
|p| = sqrt(-x.p)

If the angle between x and p is less than 90 degrees or greater than -90 degrees then you'll get an imaginary answer for |p|.

##### Share on other sites
You can write that as

p1^2 + p2^2 + x1*p1 + x2*p2 = 0

That looks like the equation of a circle.

(p1+x1/2)^2+ (p2+x2/2)^2 = (x1^2+x2^2)/4

That's a circle centered around (-x1/2,-x2/2) which passes through the origin. You can get all your solutions in a parametric way. If we define r:=(x1^2+x2^2)/4,

p1 = -x1/2 + r*cos(t)
p2 = -x2/2 + r*sin(t)

##### Share on other sites
Quote:
 Original post by alvaroYou can write that asp1^2 + p2^2 + x1*p1 + x2*p2 = 0That looks like the equation of a circle.(p1+x1/2)^2+ (p2+x2/2)^2 = (x1^2+x2^2)/4That's a circle centered around (-x1/2,-x2/2) which passes through the origin. You can get all your solutions in a parametric way. If we define r:=(x1^2+x2^2)/4,p1 = -x1/2 + r*cos(t)p2 = -x2/2 + r*sin(t)

This is now the second time in which there has been mention of a solution around a circle. However, I don't think this makes a lot of sense, since I expect just one solution.

Samith: Unfortunately, I don't know p either.

--------------------

And it looks like I've made some mistakes in my simplification above. The full equation, if it's of any assistance, is:

H(x,p) = a * sqrt( b*|p|^2 + (x.p)^2 + c^2 ) - c = 0

where a,b,c are all constant.

Thanks again.

##### Share on other sites
it seems to me that there are many solutions. are you sure your equation is correct?

c*c/(a*a)-c*c = k = b*|p|^2 + (x.p)^2

writing p = r*cos(t),

k = b*r^2 + cos(t)^2 / (r^2*|x|^2) which means k*r^2 = b*r^4 + cos(t)^2/|x|^2

this is a quadratic for r^2.

##### Share on other sites
Quote:
 Original post by mooserman352it seems to me that there are many solutions. are you sure your equation is correct?c*c/(a*a)-c*c = k = b*|p|^2 + (x.p)^2writing p = r*cos(t),k = b*r^2 + cos(t)^2 / (r^2*|x|^2) which means k*r^2 = b*r^4 + cos(t)^2/|x|^2this is a quadratic for r^2.

I'm certain the equation is correct. However, I'm not sure that the approach (to solve this directly) is correct, so I'll have to go back over my work and check that this is what I want.

Thanks anyway!

##### Share on other sites
why don't you post the original problem so we might be able to help.

##### Share on other sites
Quote:
Original post by salmonsolid
Quote:
 Original post by alvaroYou can write that asp1^2 + p2^2 + x1*p1 + x2*p2 = 0That looks like the equation of a circle.(p1+x1/2)^2+ (p2+x2/2)^2 = (x1^2+x2^2)/4That's a circle centered around (-x1/2,-x2/2) which passes through the origin. You can get all your solutions in a parametric way. If we define r:=(x1^2+x2^2)/4,p1 = -x1/2 + r*cos(t)p2 = -x2/2 + r*sin(t)

This is now the second time in which there has been mention of a solution around a circle. However, I don't think this makes a lot of sense, since I expect just one solution.

Samith: Unfortunately, I don't know p either.

--------------------

And it looks like I've made some mistakes in my simplification above. The full equation, if it's of any assistance, is:

H(x,p) = a * sqrt( b*|p|^2 + (x.p)^2 + c^2 ) - c = 0

where a,b,c are all constant.

Thanks again.

If you only impose one condition on a pair of numbers, you will typically get a whole curve of solutions.

How about you work it out in a particular example and then we can easily see what the solutions look like? It would also help if the problem would stop mutating. As mooserman352 said, post the original problem.

##### Share on other sites
Quote:
 Original post by salmonsolidH(x,p) = |p|^2 + x.p

H(x,p) + x.x/4 = (p + x/2).(p + x/2)

so for the zero locus of H you have

(x/2).(x/2)=(p + x/2).(p + x/2)

i.e. p is on a circle around -x/2 passing through the origin.

Quote:
 Original post by salmonsolidH(x,p) = a * sqrt( b*|p|^2 + (x.p)^2 + c^2 ) - c

Disregarding the aesthetical problem that your equation depends on the choice of scale, you'll still get a conic, which is probably easier to handle geometrically than analytically. With p=ux+vx and |x|=w, you get

(c/a)^2 = bw^2(u^2 + v^2) + u^2w^4 + c^2

which is clearly an equation of a conic with axes alongside x and x, the actual type depending on the relationship between |a| and 1 as well as -b and x.x.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
18

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632998
• Total Posts
3009803
• ### Who's Online (See full list)

There are no registered users currently online

×