Re: Simplify formula for iterative programming



On 3 Jun 2005 03:32:16 -0700, stefaan.lhermitte@xxxxxxxxxxxxxxxxxx
wrote:

Meta comment: Your question is virtually unreadable because the
character set is getting munged. I'm not going to attempt to answer
your question when it is in this format. That said, see comments at
bottom.

>Dear,
>
>I am looking for the simplification of a formula to improve the
>calculation speed of my program. Therefore I want to simplify the
>following formula:
>
>H =3D Si (Sj ( sqrt [ (Ai - Aj)=B2 + (Bi - Bj)=B2 ] ) )
>
>where:
>A, B =3D two vectors (with numerical data) of length n
>sqrt =3D square root
>Si =3D summation over i (=3D 0 to n)
>Sj =3D summation over j (=3D 0 to n)
>Ai =3D element of A with index i
>Aj =3D element of A with index j
>Bi =3D element of B with index i
>Bj =3D element of B with index j
>
>n is not fixed, but it changes with every run for my program. Therefore
>for I am looking for a simplication of H in order to calculate it when
>my A and B get extendend by 1 element (n =3D n + 1).
>
>I know a computional simplified formula exists for the standard
>deviation (sd) that is much easier in iterative programming. Therefore
>I wondered I anybody knew about analog simplifications to simplify H:
>
>sd =3D sqrt [ ( Si (Xi - mean(X) )=B2 ) /n ] -> simplified computation
>-> sqrt [ (n * Si( X=B2 ) - ( Si( X ) )=B2 )/ n=B2 ]
>
>This simplied formula is much easier in iterative programming, since I
>don't have to keep every element of X.
>E=2Eg.: I have a vector X[1:10] and I already have caculated Si(
>X[1:10]=B2 ) (I will call this A) and Si( X ) (I will call this B).
>When X gets extendend by 1 element (eg. X[11]) it easy fairly simple to
>calculate sd(X[1:11]) without having to reuse the elements of X[1:10].
>I just have to calculate:
>
>sd =3D sqrt [ (n * (A + X[11]=B2) - (A + X[11]=B2)=B2 ) / n=B2 ]
>
>This is fairly easy in an iterative process, since before we continue
>with the next step we set:
>A =3D (A + X[11]=B2)
>B =3D (B + X[11])
>
>Can anybody help me to do something comparable for H? Any other help to
>calculate H easily in an iterative process is also welcome!
>
>Kind regards,
>Stef
>\

If, as I guessing, your H is the sum over i,j of point distances from
each other (that's what your formula looks like) then there is no
really nice extension formula. In the standard deviation formula you
are taking the square root of a sum; in your case you are taking the
sum of square roots. That said you can use the general extension
formula, e.g.,

H(n+1) = H(n) + sum_over_i(E(i,n+1) + E(n+1,i)) + E(n+1,n+1)

where E(1,j) is term i,j in the summation. This isn't any faster
overall, but it does let you use previous results.


Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
.



Relevant Pages

  • Simplify iterative programming
    ... calculation speed of my program. ... I wondered I anybody knew about analog simplifications to simplify H: ... This simplied formula is much easier in iterative programming, ...
    (comp.programming)
  • Simplify formula for iterative programming
    ... deviation that is much easier in iterative programming. ... I wondered I anybody knew about analog simplifications to simplify H: ... This simplied formula is much easier in iterative programming, ... This is fairly easy in an iterative process, ...
    (comp.programming)
  • Re: Simplify infinite series with Sines???
    ... use a square wave as well and I'd get the same result too. ... it makes it easier to simplify; then using a saw/square wave for k=2 ... this that it is equal to a sum. ... the coefficient aof z^i in P is ...
    (sci.math)
  • Re: Problem using solve... keeps busy
    ... However, if you then simplify() the result, you get a *large* ... Then at the end of the sum, there are a few lines of other terms ... and you simplifyafter substitution (applying the ... a=x into the original equation ...
    (comp.soft-sys.matlab)
  • Re: Some questions about simplification
    ... When I try to calculate sum of ... sines or cosines, the calculator makes calculation in approximation ... SEQ SigmaLIST SIMPLIFY>> ...
    (comp.sys.hp48)