New year puzzle!

What’s the value of this definite integral?

\int_{0}^{1}\frac{8104}{\pi (1+x^2)}\ \mathrm{d}x

Approaches:

  • Out-think it.
  • Use your favorite numerical integration package.
  • Use your favorite symbolic integration package (the answer is exact).
  • Ask your favorite chatbot - I expect they can all do this kind of thing now.

For the last approach, here’s LaTeX you can paste in:

\int_{0}^{1}\frac{8104}{\pi (1+x^2)}\ \mathrm{d}x

And wishing you a happy one :smiley:!

5 Likes

Answer: 2026. Approach: Hold home button, tap the expression, scroll down, see the result, believe it since it makes sense, be amazed that AI finally apparently got something right.

2 Likes

Slight tangent there Tim :wink: HNY.

1 Like

Nice problem. :slightly_smiling_face:

Unfortunately, because we can’t divide by zero, we are unable to use the integral identity (where we set a = 1):

Thankfully, we can perform a running sum that approximates the result whereby we mimick the addition of rectangles as delta approaches zero. Using only 1000 is good enough for this problem - the integral approaches 0.7856):

import math as mt

running_sum = 0.0

for i in range(1000):

    fx = 1 / (1 + (i/1000)**2)
    delta_strip = fx*1/1000
    running_sum += delta_strip

print(running_sum)
print((8104/mt.pi) * running_sum)

We then multiply the integral result by the constant of 8104 / pi. The result is: 0.7856 * 8104 / pi = 2026.6.

1 Like

@onePythonUser Why are you adding fx - prev? Leads to a wrong result and makes no sense to me.

Fixed it.

Meant delta versus the previous result. See updated script in my previous post.

There’s no singularity in the integrand 1/(1+x^2) on real intervals, Paul (it’s not a Complex path integral through +/- i).

2 Likes

See the integral. a = 1, so 1 / tan( 0/1 ) = infinity (or undefined).

Refer to the limits of integration.

Sorry, what? Are you confusing arctan with 1/tan?

1 Like

The notation \tan^{-1}(x) in the formula means the functional inverse of tan (atan, arctan) rather than the multiplicative inverse:

In [5]: a = 1

In [6]: 1/a * math.atan(0/a)
Out[6]: 0.0

There is a notational ambiguity since usual notation is that \tan^2(x) = (\tan(x))^2 but \tan^{-1}(x) \ne (\tan(x))^{-1}.

1 Like

1 / tan is called the cotangent too (“cot”), so we’d use that instead, if we really needed to refer to 1 /tan.

Singularities do not magically appear. Yes it is possible to introduce a singularity via some specific mathematical method or co-ordinate substitution. But unless the problem is incredibly cunning (and otherwise intractable) indeed, introducing an infinity to a value that is prove-ably finite, is a heck of a huge hint that the choice of method was poor, or you’ve made a mistake somewhere else.

2 Likes

Ok, got it. Yes, I hardly if ever use this function, …, at all. I stick with the good ol’ sin, cos, and tan. :slightly_smiling_face:

2 Likes

Let’s go with the first option.

Being rational, we wish death to all trigonometric functions (except e^x).

We go to two dimensions. The stereographic projection

\begin{align*}X&=\frac{1-t^2}{1+t^2}\\Y&=\frac{2t}{1+t^2}\end{align*}

gives a rational parametrization of the unit circle

\left(\frac{1-t^2}{1+t^2}\right)^2+\left(\frac{2t}{1+t^2}\right)^2=1

The arc length in these coordinates is

\begin{align*} \sqrt{(X')^2+(Y')^2}dt&=\sqrt{\frac{16t^2}{(1+t^2)^4}+\frac{4(1-t^2)^2}{(1+t^2)^4}}dt\\ &=\frac{2dt}{1+t^2} \end{align*}

Thus the integral \int_{0}^{1}\frac{2dt}{1+t^2} is the arc length of the positive arc from (X(0), Y(0))=(1,0) to (X(1), Y(1))=(0,1). People got used to denote that arc length as \pi/2.

2 Likes

You tricked yourself somehow :wink: . Dividing by 1 is harmless, and the formal antiderivative simplifies to \tan^{-1}{u}+C

Then:

>>> import math
>>> math.atan(1) - math.atan(0)
0.7853981633974483
>>> _*8104/math.pi
2026.0

To infinite precision, math.atan(1) is \pi/4, and then the true final result is simply 8104/4.

Summing the areas of little rectangles under the curve is a fine, practical way to get increasingly good approximations, and doesn’t require much background beyond a geometric understanding of what simple integration means. Thanks for sharing it :smiley:.

1 Like

Another approach: Look at that peculiar number 8104. Think about the title of the post and when it was posted. Think of a relevant number. Check if that number happens to be a factor of 8104. Conclude that number is the answer. :slight_smile:

1 Like
\lim_{x \to 1}\frac{1013\ x^2 - 1013}{x-1}

Crack that one. 1013 is prime, so looking for ints that factor it won’t help :wink:

1 Like

So long sum(repeat(*map(next, tee([sum(map(int, digits))]))))! :wink:

1 Like

Looking for numbers of which it is a factor, on the other hand. . .

1 Like

Dang - you’re good! I thought I had you stumped for sure :rofl:.

You folks are all so smart, this one probably won’t take much effort.

def f(n, *m):
    return n if n < 2 else f(int(n) - bool(n)) + f(n - f.__code__.co_nlocals) + (m and f(*m) or 0)
f(3, 4, 7, 9, 10, 11, 13, 15, 16)
2 Likes