From: compton@plains.NoDak.edu (Curtis M. Compton)
Newsgroups: comp.compression
Subject: Re: Math question
Date: 16 Nov 92 16:20:49 GMT
Article-I.D.: ns1.BxtHEp.F36
Organization: University of North Dakota, Grand Forks

In article <24005@hacgate.SCG.HAC.COM>
	abirenbo@rigel.cel.scg.hac.com (Aaron Birenboim) writes:

>While working on an optimization problem related to compression
>I bumped into the following nasty little problem :

>   evaluate:
>
>                {           [(i+1)q                                      }
>             d  {           [                                            }
>            --- {  Integral [      (x - (i + 0.5) q)^2 * exp(-c * x) dx  }
>             dq {           [                                            }
>                {           [i*q                                         }

>  I have evaluated the integral..... and it is terribly nasty.  Even if I
>didn't goof on the evaluation, i would surely goof on the differentiation.

>  c and i are constants.  I'm trying to minimize error for q.

>  I seem to remember some terribly nasty formulas for handling the
>differentiation before evaluating any integral.

>  I think it involved the bounds, derivitives of the bounds, the integrand
>and the derivitave of the integrand.

Well, I ran your problem through Macsyma and here goes...

[Macsyma header deleted]
 
(C1) (x - (i + 0.5) * q)^2 * exp(-c * x);
 
                                            2   - C X
(D1)                       (X - (I + 0.5) Q)  %E
(C2) integrate (%,x,i*q,(i+1)*q);
 
Is   Q   zero or nonzero?
nonzero;

/* Just a guess on my part. */

[Macsyma garbage deleted]

Is   Q   positive or negative?
positive;

/* Just another guess. */

[stuff deleted]

        2  2                - C I Q     2  2                - C I Q - C Q
      (C  Q  - 4 C Q + 8) %E          (C  Q  + 4 C Q + 8) %E
(D2)  ----------------------------- - -----------------------------------
                     3                                  3
                  4 C                                4 C
(C3) diff (%,q);
 
                     2  2                - C I Q - C Q
       (- C I - C) (C  Q  + 4 C Q + 8) %E
(D3) - -----------------------------------------------
                               3
                            4 C
 
       2            - C I Q - C Q       2  2                - C I Q
   (2 C  Q + 4 C) %E                I (C  Q  - 4 C Q + 8) %E
 - ------------------------------ - -------------------------------
                   3                                2
                4 C                              4 C
 
       2            - C I Q
   (2 C  Q - 4 C) %E
 + ------------------------
                3
             4 C
(C4) fullratsimp (%);
 
          2    2                                  C Q       2      2   2
(D4) - ((C  I Q  + (- 4 C I - 2 C) Q + 8 I + 4) %E    + (- C  I - C ) Q
 
                                                            - C I Q - C Q     2
                           + (- 4 C I - 2 C) Q - 8 I - 4) %E             /(4 C )

There's your answer!  I hope it helps.
-- 
Curtis M. Compton           | Future home of Rookerie Software |
compton@plains.NoDak.edu    +----------------------------------+
560 Carleton Court, Apt #11 | "I am the Walrus"               - John Lennon
Grand Forks, ND 58203       | "I am the Keeper of the Cheese" - Ren Hoek
(701) 795-5099              | "I am the Master of Penguins"   - Curt Compton