That hard problem was invented by V. P. Beshkarev (Russia) in 1971:

Sum[Tan[(4*j - 3)*Pi/180], {j, 1, 45}] // FullSimplify

The result should be 45, but the command is running on my comp without any output for hours. I know its tricky calculation by hand which cannot be mimicked with Mathematica.

  • $\begingroup$ N[Sum[Tan[(4*j - 3)*Pi/180], {j, 1, 45}]] gives 45. $\endgroup$ – Carl Lange Feb 7 at 20:02
  • $\begingroup$ @Carl Lange: Up to a certain precision, is not so? Did you carefully read the question and its tags? $\endgroup$ – user64494 Feb 7 at 20:04
  • $\begingroup$ Sorry, it's not clear to me what you're expecting as a result except "The result should be 45". Why do you expect FullSimplify to do anything in this case? $\endgroup$ – Carl Lange Feb 7 at 20:11
  • $\begingroup$ @Carl Lange: A simpler problem of such type is Sum[j,{j,1,100}], where the result should be 5050, not 5050.0 . Hope I am clear now. $\endgroup$ – user64494 Feb 7 at 20:14
  • 1
    $\begingroup$ @CarlLange I guess, it is only about challenging Mathematica's symbolic capabilities. $\endgroup$ – Henrik Schumacher Feb 7 at 20:27

Sometimes the easiest approach is to just divide it up into steps and see which transformations can be done reasonably quickly. First, I define the expression:

expr = Sum[Tan[(4*j - 3)*Pi/180], {j, 1, 45}];

Verify its result numerically:



This is likely, but not necessarily, exact. Thus, the strategy will be trying to prove that some transformation of expr - 45 is 0 exactly. Since expr is primarily trigonometric, there's a few functions that come to mind immediately. TrigExpand does not evaluate quickly, but TrigToExp shows a fairly self-similar form of a group of fractions. I find fractions usually become easier to work with after Apart, and it turns out that transformation is also reasonably quick. However, after Apart the numbers do not precisely add up to anything specific, so the 45 would seem to be a residual effect of several independent parts of this expression.

At this point I tried to see if Simplify could sort it out:

Simplify[Apart[TrigToExp[expr]] - 45]


Which is an exact result, though derived through somewhat convoluted means, which shows that expr == 45 exactly, so long as no errors occurred during TrigToExp and Apart, which are both supposed to be complex safe.

  • $\begingroup$ Sorry, but the code suggested by you is running without any output on my comp during several minutes. The same issue with Apart[TrigToExp[expr]] too. I will try to execute your code in cloud. $\endgroup$ – user64494 Feb 7 at 20:37
  • $\begingroup$ It takes about 5 seconds on an i7 4770K on Mathematica 10.1. It takes about 8.4 on a fresh start of 11.2 for me as well. Not a super easy computation, so I wouldn't be surprised if it takes a little bit, but I'd expect it to take less than 2 minutes on most machines. $\endgroup$ – eyorble Feb 7 at 20:40
  • $\begingroup$ Reproduced in Mathematica online in 6 s.. Simply and strongly. $\endgroup$ – user64494 Feb 7 at 20:47
  • 2
    $\begingroup$ Hm. I am very curious. I am on version 11.3 on a 4980HQ (so the single-thread performance should be very similar to the 4770K) and this computation takes 47 seconds (returning the correct result). That's significant slow-down... $\endgroup$ – Henrik Schumacher Feb 7 at 21:21
  • 1
    $\begingroup$ @HenrikSchumacher on the cloud it takes like 90s $\endgroup$ – b3m2a1 Feb 8 at 0:01

Use RootReduce

Sum[Tan[(4*j - 3)*Pi/180], {j, 1, 45}] // RootReduce

(* 45 *)
  • 1
    $\begingroup$ +1. It is unclear to me how it works. $\endgroup$ – user64494 Feb 8 at 3:50
  • 1
    $\begingroup$ @user64494 - Mostly only people at Wolfram know "how it works". It is one of the functions like Simplify, FullSimplify, ComplexExpand, TrigReduce, etc. that are used to find alternate forms of expressions. Experimentation is often required to find which one or which combination is best for a given expression. $\endgroup$ – Bob Hanlon Feb 8 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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