« first day (3214 days earlier)      last day (1568 days later) » 

04:45
Quick question (didn't think it's substantial enough to post it), how do I get this integral to display 0? Integrate[Sin[k x],{x,0,2Pi}] (with the additional assumption that k is an integer)
I tried adding the option assumptions -> k [Element] Integers, but it still doesn't give 0
It gives an expression that is zero, though - one just needs to realize that Sin(k pi) = 0 for integer k
05:27
@Allure Assuming[k \[Element] Integers, Integrate[Sin[k x],{x,0,2Pi}]]?
Thanks, that worked. Why would Assuming work but not Assumptions, though?
 
11 hours later…
16:05
@Allure Assuming just creates a local environment where $Assumptions is set. So it basically works as if you would set $Assumptions globally for this call and I guess it's not only used for the integration itself but also for intermediate simplification steps. So one explanation "could" be that the Assumption option of Integrate is only used for certain integration steps.
That'd explain, why this works:
In[68]:= int = Integrate[Sin[k x], {x, 0, 2 Pi}];
Assuming[k \[Element] Integers, Simplify[int]]

Out[69]= 0
 
2 hours later…
17:52
@halirutan I assumed that was all that was going on internally, but check this out:
Assuming[k \[Element] Integers, Integrate[Sin[k x], {x, 0, 2 Pi}]] // AbsoluteTiming

{0.155795, 0}

Assuming[k \[Element] Integers, Simplify@#] &@Integrate[Sin[k x], {x, 0, 2 Pi}] // AbsoluteTiming

{0.00918, 0}
Clearly the extra assumption is actually slowing things down internally...
Anyone got a good primer on optimizing over combinatoric problems? I've got a bunch of cases where I basically have to sum over different combinations of terms and I know I can optimize a bunch if I'm clever about things since I've got a huge raft of non-contributing terms
And each problem feels similar, but different, and so I'm trying to look into standard approaches
18:24
@b3m2a1 Yes, I'd expect that. In your first example, the assumption needs to be taken into account on each step in the integration while it's only used to simplify the result in your second case. What I wanted to suggest is that probably Integrate does intermediate simplification steps along the way of integration and it appears that for these steps the settings of the Assumption option is not used.
But it's really only wild guessing on my side.

« first day (3214 days earlier)      last day (1568 days later) »