Search code examples
symbolic-mathmaxima

Differentiating sums with Maxima


I have the following sum:

sum((R[i]-(a*X[i]+b)*t + 1/2*(c*X[i]+d)^2*t)^2/((c*X[i]+d)^2*t), i, 1, N);

which I want to differenciate wrt. a:

diff(%, a);

but Maxima (wxMaxima to be precise) just prints d/da . Can I make it actually differentiate the sum (so because N is finite is should differentiate every element in the sum separately)?

If I set N to some constant, e.g.:

sum((R[i]-(a*X[i]+b)*t + 1/2*(c*X[i]+d)^2*t)^2/((c*X[i]+d)^2*t), i, 1, 100);

then I get explicit sum of 100 elements (takes about 2 pages), and then differentiation works (but again I get 2 pages instead of a small sum). Can I get this result displayed as a sum?


Solution

  • Which version of Maxima do you use ?

    Here is my session of Maxima with you equation differentiated wrt.a and than substituted to N=100.

    ~$ maxima 
    Maxima 5.24.0 http://maxima.sourceforge.net
    using Lisp SBCL 1.0.51
    Distributed under the GNU Public License. See the file COPYING.
    Dedicated to the memory of William Schelter.
    The function bug_report() provides bug reporting information.
    (%i1) sum((R[i]-(a*X[i]+b)*t + 1/2*(c*X[i]+d)^2*t)^2/((c*X[i]+d)^2*t), i, 1, N);
                                       2
                             (c X  + d)  t
                       N         i                             2
                      ====  (------------- - (a X  + b) t + R )
                      \            2             i           i
                       >    ------------------------------------
                      /                           2                                                                                                
                      ====              (c X  + d)                                                                                                 
                      i = 1                 i                                                                                                      
    (%o1)             ------------------------------------------                                                                                   
                                          t                                                                                                        
    (%i2) diff(%, a);                                                                                                                              
                                           2                                                                                                       
                                 (c X  + d)  t                                                                                                     
                        N            i
                       ====  X  (------------- - (a X  + b) t + R )
                       \      i        2             i           i
    (%o2)          - 2  >    --------------------------------------
                       /                            2
                       ====               (c X  + d)
                       i = 1                  i
    (%i3) %, N=100;
                                           2
                                 (c X  + d)  t
                       100           i
                       ====  X  (------------- - (a X  + b) t + R )
                       \      i        2             i           i
    (%o3)          - 2  >    --------------------------------------
                       /                            2
                       ====               (c X  + d)
                       i = 1                  i