danielpf

25 Reputation

2 Badges

20 years, 133 days

MaplePrimes Activity


These are replies submitted by danielpf

@Carl Love I'd like to point out for any readers who are not paying close attention that in your original Question, you asked about differentiating wrt x[i], while in your Reply to Markiyan, you changed that to x[j].

I beg to differ.  One should be able to use any symbol outside sum as the particular symbol used for summation, like the integration variable for int, can be replaced by any other symbol.    Mathematica does the right thing in such a case by replacing the summation symbol by another distinct one, and use the Kronecker symbol for keeping the element of the sum that matches.

 

@vv Thanks, this is the most practical way around Maple limitations around sum and diff.  I remember doing something similar with subs when calculating the Lagrange equations of a dynamical system, where Maple cannot differentiate directly wrt to a function.

@Markiyan Hirnyk 

Similar questions have been discussed but no good answer came from Maple updates.   This is clearly a bug.

Mathematica answers correctly.  In Maple notation the solution should read:

> diff(sum(sin(x[i],i=1..N), x[j]); 

         sum(cos(x[i])*Dirac(i-j),i=1..N)

@Mariusz Iwaniuk 

Thanks, I should have read the help page, but I use Maple since so long (Maple 4) (add was invented in Maple 2015)

that rereading the page seemed not necessary.

Thus sum behaves like int, when the start and end values runs backward, but unlike usual math conventions, 

which is probably confusing for beginners.  If this is not a bug this is certainly a "feature".  It would have been

preferable to keep sum for what add does, and give a name like summation for what sum does.

 

Actually updated Maple 16 is able to do the shown integral correctly:

> Int(sin(a*x)/x,x=0..b);
                      /b           
                     |          sin(a x)   
                     |          -------- dx
                     |             x       
                    /0                     
> diff(%, a);

                      /b          
                     |                     
                     |          cos(a x) dx
                     |                     
                    /0                     

Replacing b by infinity gives the matching expressions (the particular result is undetermined for b=infinity but this is just an example). 

Actually the problem is general, another simpler example gives the same error message:

> diff(Int(a*x,x=0..1,method=_d01amc),a);
Error, (in diff/Int) invalid Int(...) format

The bug results from diff trying to differentiate the option part from the integral.  If method= is removed, one gets a wrong double integral

> diff(Int(a*x,x=0..1,_d01amc),a);


                       /   /1              
                      |   |                
                      |   |   x dx d_d01amc
                      |   |                
                     /   /0                

This time the integrand is differentiated correctly but the option _d01amc is taken as a variable and the result is a double integral!

I need to use method=_d01amc in a more complicated integral before differentiating because the result then needs to be evaluated numerically fast enough in plots, which is only possible by  using a method of integration using the NAG library.  

 

Actually updated Maple 16 is able to do the shown integral correctly:

> Int(sin(a*x)/x,x=0..b);
                      /b           
                     |          sin(a x)   
                     |          -------- dx
                     |             x       
                    /0                     
> diff(%, a);

                      /b          
                     |                     
                     |          cos(a x) dx
                     |                     
                    /0                     

Replacing b by infinity gives the matching expressions (the particular result is undetermined for b=infinity but this is just an example). 

Actually the problem is general, another simpler example gives the same error message:

> diff(Int(a*x,x=0..1,method=_d01amc),a);
Error, (in diff/Int) invalid Int(...) format

The bug results from diff trying to differentiate the option part from the integral.  If method= is removed, one gets a wrong double integral

> diff(Int(a*x,x=0..1,_d01amc),a);


                       /   /1              
                      |   |                
                      |   |   x dx d_d01amc
                      |   |                
                     /   /0                

This time the integrand is differentiated correctly but the option _d01amc is taken as a variable and the result is a double integral!

I need to use method=_d01amc in a more complicated integral before differentiating because the result then needs to be evaluated numerically fast enough in plots, which is only possible by  using a method of integration using the NAG library.  

 

Page 1 of 1