Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.maple > #774

Gradient with respect to set of indexed variables sum

Newsgroups comp.soft-sys.math.maple
Date 2013-06-24 17:43 -0700
Message-ID <ae8e50ae-65e0-4d34-8f88-0cdc552201cd@googlegroups.com> (permalink)
Subject Gradient with respect to set of indexed variables sum
From doctorleff@gmail.com

Show all headers | View raw


How does one take the gradient of a expression involving sums in terms of a 
set of indexed  variables.   

I am trying to find the maxima for  the satisfaction for a public good
from a tax code.  The sum represents the total revenue.  The tax code
is defined as a piecewise linear function of income and indexed
variables.  The indexed variables represent the points of the kinks and 
the marginal tax rate for each income bracket.    (The set of indexed variables
will vary based upon other parameters of the problem--and I want to 
write the solution in terms of these values.  That is I want a solution
in terms of M sub p and N sub p.
Ultimately, I will use Maple's code generation package to transfer the
results to our simulation written in Java.

I tried several approaches by creating loops to do the differentiation
with respect to each indexed variable.  I also tried the suggestion of 
Alex Mihailov in Maple Primes to the question by Paul Weiss.  None have worked;
can anyone suggest the best approach?

Dr. Laurence Leff  Western Illinois University, Macomb IL 61455 ||(309) 298-1315
Stipes 447 Assoc. Prof. of Computer Sci. Pager: 309-367-0787 FAX: 309-298-2302 

> Tax:=(p) ->
> sum  (R[i+1]*k[L], i=M[p]+1..N[p]) + R[M[p]]*(k[M[p]]-Inb[p])
> +R[N[p]]*(Ine[p]-k[N[p]]);
                 /    N[p]                  \
                 |   -----                  |
                 |    \                     |
     Tax := p -> |     )       R[i + 1] k[L]| + R[M[p]] (k[M[p]] - Inb[p])
                 |    /                     |
                 |   -----                  |
                 \i = M[p] + 1              /

          + R[N[p]] (Ine[p] - k[N[p]])

> TT := sum (Tax(p)*Pop[p],p=1..P);
             P    /    N[p]                  \
           -----  |   -----                  |
            \     |    \                     |
     TT :=   )   (|     )       R[i + 1] k[L]| + R[M[p]] (k[M[p]] - Inb[p])
            /     |    /                     |
           -----  |   -----                  |
           p = 1  \i = M[p] + 1              /

          + R[N[p]] (Ine[p] - k[N[p]])) Pop[p]

# this is wht we optimize
> ToP:=m[i]*TT^2/2+b[i]*TT - Tax[i];
                     P    /    N[p]                  \
                   -----  |   -----                  |
                    \     |    \                     |
  ToP := 1/2 m[i] (  )   (|     )       R[i + 1] k[L]|
                    /     |    /                     |
                   -----  |   -----                  |
                   p = 1  \i = M[p] + 1              /

       + R[M[p]] (k[M[p]] - Inb[p]) + R[N[p]] (Ine[p] - k[N[p]])) Pop[p])^2 +

              P    /    N[p]                  \
            -----  |   -----                  |
             \     |    \                     |
      b[i] (  )   (|     )       R[i + 1] k[L]| + R[M[p]] (k[M[p]] - Inb[p])
             /     |    /                     |
            -----  |   -----                  |
            p = 1  \i = M[p] + 1              /

       + R[N[p]] (Ine[p] - k[N[p]])) Pop[p]) - Tax[i]

> print(`hello`.ToP);
                     P    /    N[p]                  \
                   -----  |   -----                  |
                    \     |    \                     |
  hello.(1/2 m[i] (  )   (|     )       R[i + 1] k[L]|
                    /     |    /                     |
                   -----  |   -----                  |
                   p = 1  \i = M[p] + 1              /

       + R[M[p]] (k[M[p]] - Inb[p]) + R[N[p]] (Ine[p] - k[N[p]])) Pop[p])^2 +

              P    /    N[p]                  \
            -----  |   -----                  |
             \     |    \                     |
      b[i] (  )   (|     )       R[i + 1] k[L]| + R[M[p]] (k[M[p]] - Inb[p])
             /     |    /                     |
            -----  |   -----                  |
            p = 1  \i = M[p] + 1              /

       + R[N[p]] (Ine[p] - k[N[p]])) Pop[p]) - Tax[i])

Back to comp.soft-sys.math.maple | Previous | Next | Find similar


Thread

Gradient with respect to set of indexed variables sum doctorleff@gmail.com - 2013-06-24 17:43 -0700

csiph-web