From: Kurt TeKolste on
If I ask Mathematica to perform an indefinite integrate on a symbolic
summation (with terms of the form a_i x^i),

Integrate[Sum[Times[Power[x,i],Subscript[a,i]],{i,0,k}],

it does nothing. If I try to tell it that summation and integration
commute by applying the rule:

Integrate[Sum[term_,range_],variable_]->
Sum[Integrate[term_,variable_],range_]

I get a strange result equivalent to

term * range

or, in this case,

Times[Power[x,i],Subscript[a,i]] * {i,0,k}
or
{i a_i x^i, 0, k a_i x^i}

Any ideas as to what's going on?

(BTW:

1) If you use rules to extract each of term, range, and variable and
then take Sum[Integral[...],...] the correct answer is returned.

2) if you use a rule that changes Sum to Power, i.e.

Integrate[Sum[term_,range_],variable_] ->
Product[Integrate[term_,variable_],range_]

you get exponents

term^(range - 1)

Odd...
)

ekt

From: David Park on
I don't know why you have patterns in the rhs of the rule. In any case, the
following works. I set the a_i coefficients to 1 in the last step to obtain
a complete evaluation.

HoldForm(a)Integrate[
Sum[Times[Power[x, i], Subscript[a, i]], {i, 0, k}], x]
% /. Integrate[Sum[term_, range_], variable_] :>
Sum[Integrate[term, variable], range]
% // ReleaseHold
% /. Subscript[a, i] -> 1


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/


From: Kurt TeKolste [mailto:tekolste(a)fastmail.net]

If I ask Mathematica to perform an indefinite integrate on a symbolic
summation (with terms of the form a_i x^i),

Integrate[Sum[Times[Power[x,i],Subscript[a,i]],{i,0,k}],

it does nothing. If I try to tell it that summation and integration
commute by applying the rule:

Integrate[Sum[term_,range_],variable_]->
Sum[Integrate[term_,variable_],range_]

I get a strange result equivalent to

term * range

or, in this case,

Times[Power[x,i],Subscript[a,i]] * {i,0,k}
or
{i a_i x^i, 0, k a_i x^i}

Any ideas as to what's going on?

(BTW:

1) If you use rules to extract each of term, range, and variable and
then take Sum[Integral[...],...] the correct answer is returned.

2) if you use a rule that changes Sum to Power, i.e.

Integrate[Sum[term_,range_],variable_] ->
Product[Integrate[term_,variable_],range_]

you get exponents

term^(range - 1)

Odd...
)

ekt



From: Roland Franzius on
Kurt TeKolste schrieb:
> If I ask Mathematica to perform an indefinite integrate on a symbolic
> summation (with terms of the form a_i x^i),
>
> Integrate[Sum[Times[Power[x,i],Subscript[a,i]],{i,0,k}],
>
> it does nothing. If I try to tell it that summation and integration
> commute by applying the rule:
>
> Integrate[Sum[term_,range_],variable_]->
> Sum[Integrate[term_,variable_],range_]
>
> I get a strange result equivalent to
>
> term * range

meaning that Integrate does not see term dependent on variable

>
> or, in this case,
>
> Times[Power[x,i],Subscript[a,i]] * {i,0,k}
> or
> {i a_i x^i, 0, k a_i x^i}
>
> Any ideas as to what's going on?
>
> (BTW:
>
> 1) If you use rules to extract each of term, range, and variable and
> then take Sum[Integral[...],...] the correct answer is returned.
>
> 2) if you use a rule that changes Sum to Power, i.e.
>
> Integrate[Sum[term_,range_],variable_] ->
> Product[Integrate[term_,variable_],range_]
>
> you get exponents
>
> term^(range - 1)
>
> Odd...
> )
>
> ekt
>


Use rules that hold its pattern form unevaluated. HoldPattern preserves
execution of the first argument of RuleDelayed at any stage of the
defining or execution process.

Using RuleDelayed (:> )instead of Rule (->) delays evaluation of its
second argument to the time of applying the rule in a Replace (/.)

--

Roland Franzius
rule = HoldPattern[Integrate[Sum[expression_,j_],x_] :>
Sum[Integrate[expression,x],j]

 | 
Pages: 1
Prev: beginner question about syntax
Next: SparseArray