I wish to simplify a sum by doing "simplify sum_{a=0}^L f(a)" where $f(a)$ is just some arbitrary expression, but I want to only do the sum when some condition is met.
Using the Iverson brackets, I am trying to do "simplify sum_{a=0}^L [some condition] f(a)" if that makes sense.
Best Answer
You might be able use
boole
, which returns $0$ or $1$ depending on whether it's argument is True or False. Thus, for $n=10$, Euler's phi function $\varphi(n)$ (which counts the number of positive integers less than and relatively prime to $n$) can be expressed asOf course, it's hard to say for sure, since you don't mention your specific application. This method of computing $\varphi(n)$, however, happens to be Wikipedia's first example application of Iverson brackets.