SPUG: S.O.S: Sum-Of-Squares

Itay Furman itayf at fhcrc.org
Thu Oct 2 01:06:46 CDT 2003


Thanks to Doug and Yitzchak for their detailed and illuminating reply.
I'd like to answer to their inquiries.


On Wed, 1 Oct 2003, Doug Beaver wrote:

> i'm curious, is it ever possible for the residue to be a value other
> than 0?
>
No (in theory).


On Wed, 1 Oct 2003, Yitzchak Scott-Thoennes wrote:

> But I'm not sure what you are trying to accomplish--  x/(x**.5 * x**.5)
> is supposed to always be one.  Are you sure you don't mean to be
> getting the ratio of the sum of squares to the square of the sum?
> 
I thought it was suppose to be 1, too :-|

Originally, I wanted to compute the deviation of the scalar product of 
two arbitrary normalized vectors v and u:
	1 - (u dot v) / |u||v|
I was surprised to find out that when u and v are incidentally identical
I get a non-zero deviation. Naiively, I didn't expect a numerical flow in such 
a simple operation :-(  After some experimenting I converged on the small 
script that I posted, that implements the above Eq for the special case
that u=v.

(
For those who follow up and need a reminder:
if u = (u1, u2, ..., uN) and v = (v1, v2, ..., vN) 
then
u dot v = u1*v1 + u2*v2 + ... uN*vN
|u| = sqrt( u1**2 + u2**2 + ... + uN**2)
|v| = sqrt( v1**2 + v2**2 + ... + vN**2).
Therefore, if u is identical to v one should get
1 - (u dot v) / |u||v|  =  1 - (u dot u)/|u||u| = 1 -  1 - 1 = 0
)

	Thanks again for the guidance,
	Itay








More information about the spug-list mailing list