2
$\begingroup$

I'm working on simple expression evaluation in one competition.

Now i'm wondering how should i evaluate empty brackets. I think i should evaluate them as zeros. Is that mathematically right or should i treat them as errors?

$()+5 = 5$

$()*5 = 0$

$()^5 = 0$

  • 0
    @anon I was doing little exercise in programming :)2012-05-28

1 Answers 1

2

Empty brackets make no sense in themselves.

By convention, empty products are always 1, and empty sums are always 0. So the interpretation would depend on what was inside the brackets before they were emptied. The general rule is that "a binary operation applied to no operands" produces the neutral element for that operation. If the operation has no neutral element (or if it is not unique), it makes no sense to apply it to no operands.

In cases where it doesn't make sense to ask which operation you're seeing an empty application of, it's either an error, or something really strange that you should seek further clarification on from the source that gave you the expression.

In other words, if you see something like $\sum_{n=1}^{k} f(n)$, then when $k=0$ you should unfold this directly to "$0$", rather than supposing that it means "$()$" and that the latter has some inherent meaning. Similarly

  • $\prod_{n=1}^0 g(n)$ should unfold directly to "$1$".
  • $\bigcup_{n=1}^0 A_n$ is always $\varnothing$.
  • $\bigcap_{n=1}^0 B_n$ is undefined, except if it's clear that the result is to be a subset of some particular universe, and arguably not even then.
  • 0
    Okay. Right. Not that that would make much sense in the OP's context.2011-11-18