Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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 as

sum boole(gcd(i,10)=1), i=1..10

enter image description here

Of 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.