Message Boards Message Boards

Solve the following equation with a Sum?

GROUPS:

Consider the following code:

In[4]:= Solve[Sum[i, {i, 1, n}] == 253, n]

Out[4]= {{n -> -23}, {n -> 22}}

In[7]:= Solve[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \(x\)] i\) == 253, x]

Out[7]= {{x -> -23}, {x -> 22}}

In[9]:= \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \(22\)]i\)

Out[9]= 253
POSTED BY: Dennis Lawler
Answer
9 days ago

Are you concerned about the negative answer n->-23? That is because Sum[i, {i, 1, n}] is evaluated symbolically first to the polynomial n(1+n)/2, and Solve works with that polynomial. The replacement is only correct if n is positive, but Mathematica leaves that check to the user. Wolfram may resolve the issue with with ConditionalExpression or Piecewise, at the cost of slowing down calculations and making beginners confused.

POSTED BY: Gianluca Gorni
Answer
9 days ago

Excellent. Thanks!

POSTED BY: Dennis Lawler
Answer
8 days ago

Group Abstract Group Abstract