Showing posts with label integration. Show all posts
Showing posts with label integration. Show all posts

Wednesday, 21 January 2026

An Interesting Limit

Here is a report generated by Gemini Pro based on the content of this video. I found the video moved a little too quickly at times and the author read out every mathematical expression symbol by symbol which wasn't really necessary and it didn't aid comprehension. It's useful to be able to take the content of the video and put into a report that can be read at your leisure. If you want to tweak the LaTeX code, you can do so easily and I've done that below for a few of expressions.

The Limit of the nth Root: An Exploration of Euler's Sequence

At first glance, the limit of the sequence involving factorials and powers can seem intuitive, but as with many problems in analysis, the "obvious" answer can be misleading. This report dismantles the problem of finding the limit of the nth root of n factorial divided by n to the power of n. Following the path likely walked by Leonhard Euler, we move from discrete sequences to continuous calculus to find a beautiful truth connecting factorials, limits, and Euler’s number, e.

1. The Sequence and Intuition

We begin by defining our sequence \( a_n \):

$$ a_n = \frac{n!}{n^n} $$

Intuitively, the denominator \( n^n \) grows much faster than the numerator \( n! \), suggesting that the terms drop toward zero. To prove this rigorously, we employ the Ratio Test. We investigate the ratio of consecutive terms:

$$ \frac{a_{n+1}}{a_n} = \frac{(n+1)!}{(n+1)^{n+1}} \cdot \frac{n^n}{n!} $$

Simplifying the factorials (\( (n+1)! = (n+1)n! \)) and regrouping terms gives:

$$ \frac{a_{n+1}}{a_n} = \frac{(n+1) \cdot n^n}{(n+1)^{n+1}} = \frac{n^n}{(n+1)^n} = \left( \frac{n}{n+1} \right)^n $$

This expression can be rewritten to reveal a fundamental definition of Euler's number:

$$ \lim_{n \to \infty} \frac{a_{n+1}}{a_n} = \lim_{n \to \infty} \frac{1}{\left( \frac{n+1}{n} \right)^n} = \lim_{n \to \infty} \frac{1}{\left( 1 + \frac{1}{n} \right)^n} = \frac{1}{e} $$

Since \( \dfrac{1}{e} \approx 0.3679 \) is strictly less than 1, the Ratio Test confirms that the sequence converges to 0.

2. The Main Problem: The nth Root

Establishing that the base sequence goes to 0 is just the preamble. The true challenge is finding the limit of the nth root of this sequence:

$$ L = \lim_{n \to \infty} \sqrt[n]{a_n} = \lim_{n \to \infty} \left( \frac{n!}{n^n} \right)^{\frac{1}{n}} $$

Since the base approaches 0 and the exponent \( \frac{1}{n} \) also approaches 0, we are facing the indeterminate form \( 0^0 \). To resolve this, we use the natural logarithm to transform the product into a sum, bridging the gap between discrete algebra and integral calculus.

3. From Logarithms to Riemann Sums

Let \( y = \sqrt[ \uproot{4} n]{a_n} \). Taking the natural log of the limit allows us to work with sums:

$$ \ln(L) = \lim_{n \to \infty} \ln \left( \left( \frac{n!}{n^n} \right)^{\frac{1}{n}} \right) = \lim_{n \to \infty} \frac{1}{n} \ln \left( \frac{n!}{n^n} \right) $$

Using logarithm rules, we expand the term inside:

$$ \ln \left( \frac{n!}{n^n} \right) = \ln(n!) - \ln(n^n) = \sum_{k=1}^{n} \ln(k) - n \ln(n) $$

We can cleverly rewrite \( n \ln(n) \) as a sum of \( n \) identical terms: \( \displaystyle \sum_{k=1}^{n} \ln(n) \). Substituting this back into our limit equation gives:

$$ \ln(L) = \lim_{n \to \infty} \frac{1}{n} \left( \sum_{k=1}^{n} \ln(k) - \sum_{k=1}^{n} \ln(n) \right) = \lim_{n \to \infty} \frac{1}{n} \sum_{k=1}^{n} \left( \ln(k) - \ln(n) \right) $$

Combining the logs, we arrive at a recognizable form:

$$ \ln(L) = \lim_{n \to \infty} \frac{1}{n} \sum_{k=1}^{n} \ln \left( \frac{k}{n} \right) $$

This structure—a sum of function values multiplied by a small width \( \frac{1}{n} \) is precisely the definition of a Riemann Sum on the interval \([0, 1]\). As \( n \to \infty \), the sum converges to a definite integral:


$$ \ln(L) = \int_{0}^{1} \ln(x) \, dx $$

4. Evaluating the Integral

We now evaluate the improper integral of \( \ln(x) \) from 0 to 1. Using integration by parts (where \( u = \ln(x) \) and \( dv = dx \)), we get:

$$ \int \ln(x) \, dx = x \ln(x) - x $$

We evaluate the definite integral by taking the limit as the lower bound approaches 0:

$$ \Bigl[ x \ln(x) - x \Bigr]_0^1 = (1 \ln(1) - 1) - \lim_{a \to 0^+} (a \ln(a) - a) $$

We know \( \ln(1) = 0 \), so the first term is \( -1 \). For the limit \( \lim_{a \to 0^+} a \ln(a) \), we use L'Hôpital's rule, which shows that this term vanishes to 0. Thus:

$$ \ln(L) = -1 - 0 = -1 $$

Conclusion

We have found that the natural logarithm of the limit is \( -1 \). To find the original limit \( L \), we simply exponentiate both sides:

$$ L = \lim_{n \to \infty} \left( \frac{n!}{n^n} \right)^{\frac{1}{n}}=e^{-1} = \frac{1}{e} $$

We have proven that while the sequence \( \dfrac{n!}{n^n} \) collapses to zero, its geometric mean—the nth root—stabilizes at exactly 1 over e. This problem serves as an elegant bridge connecting basic sequence properties, the definition of e, and the power of integral calculus.

Tuesday, 20 January 2026

Newton's Approximation For Pi

I watched an interesting YouTube video about how Newton approximated \( \pi \) and I thought it would be an interesting exercise to get Gemini to access the video and recreate the steps outlined. Once Gemini had created its response, I then got it to create a HTML version of the information for easy pasting into Blogger. Here is what it came up with and it's really quite impressive:

Based on the video provided, specifically the section starting around [00:06:50], here is the step-by-step derivation of Newton’s approximation of $\pi$.

Newton's method combines two different ways of calculating the area of a specific portion of a circle: using calculus (integration of an infinite series) and geometry. By equating these two results, he solved for $\pi$.

Step 1: The Equation of the Circle

Newton started with the equation of a unit circle centered at the origin:

$$x^2 + y^2 = 1$$

Solving for $y$ gives the function for the upper semicircle:

$$y = \sqrt{1 - x^2} = (1 - x^2)^{\frac{1}{2}}$$

Newton wanted to find the area under this curve from $x = 0$ to $x = \frac{1}{2}$. This can be expressed as the definite integral:

$$\text{Area} = \int_{0}^{\frac{1}{2}} (1 - x^2)^{\frac{1}{2}} \, dx$$

Step 2: Binomial Expansion

Since calculus was in its infancy, Newton applied his generalized binomial theorem to expand $(1 - x^2)^{\frac{1}{2}}$ into an infinite series. The general form for $(1+u)^n$ is:

$$(1+u)^n = 1 + nu + \frac{n(n-1)}{2!}u^2 + \frac{n(n-1)(n-2)}{3!}u^3 + \dots$$

By substituting $u = -x^2$ and $n = \frac{1}{2}$, he derived the series for the circle's equation:

$$(1 - x^2)^{\frac{1}{2}} = 1 - \frac{1}{2}x^2 - \frac{1}{8}x^4 - \frac{1}{16}x^6 - \frac{5}{128}x^8 - \dots$$

Step 3: Term-by-Term Integration

Newton then found the area (fluxion) by integrating the series term by term:

$$\int \left( 1 - \frac{1}{2}x^2 - \frac{1}{8}x^4 - \frac{1}{16}x^6 - \dots \right) \, dx$$

This yields the algebraic formula for the area:

$$\text{Area}(x) = x - \frac{1}{6}x^3 - \frac{1}{40}x^5 - \frac{1}{112}x^7 - \frac{5}{1152}x^9 - \dots$$

Step 4: Calculating the Area for $x = \frac{1}{2}$

Newton improved efficiency by choosing the limit $x = \frac{1}{2}$ (instead of 1), which makes the powers of $x$ shrink very rapidly. Substituting $x = \frac{1}{2}$ into the series:

$$\text{Area} \approx \frac{1}{2} - \frac{1}{6}\left(\frac{1}{2}\right)^3 - \frac{1}{40}\left(\frac{1}{2}\right)^5 - \frac{1}{112}\left(\frac{1}{2}\right)^7 - \dots$$

Simplifying the fractions:

$$\text{Area} \approx \frac{1}{2} - \frac{1}{48} - \frac{1}{1280} - \frac{1}{14336} - \dots$$

This sum gives a numerical value for the area.

Step 5: Equating to Geometry



Screenshot from video

Geometrically, the area under the unit circle from $x=0$ to $x=\frac{1}{2}$ corresponds to a slice of the circle. As described in the video, this region consists of two shapes:

  1. A triangle with base $\frac{1}{2}$ and height $\frac{\sqrt{3}}{2}$ (since $y = \sqrt{1 - (0.5)^2} = \sqrt{0.75} = \frac{\sqrt{3}}{2}$).
  2. A circular sector of $30^{\circ}$ (or $\frac{\pi}{6}$ radians).

The total geometric area is:

$$\text{Area} = \text{Area}_{\text{triangle}} + \text{Area}_{\text{sector}}$$ $$\text{Area} = \left( \frac{1}{2} \cdot \text{base} \cdot \text{height} \right) + \left( \frac{\theta}{2\pi} \cdot \pi r^2 \right)$$ $$\text{Area} = \left( \frac{1}{2} \cdot \frac{1}{2} \cdot \frac{\sqrt{3}}{2} \right) + \left( \frac{\pi/6}{2\pi} \cdot \pi (1)^2 \right)$$ $$\text{Area} = \frac{\sqrt{3}}{8} + \frac{\pi}{12}$$

Step 6: Solving for $\pi$

Finally, Newton equated the Algebraic Area (from Step 4) with the Geometric Area (from Step 5) and solved for $\pi$:

$$\frac{\sqrt{3}}{8} + \frac{\pi}{12} = \text{Series Sum}$$ $$\frac{\pi}{12} = \text{Series Sum} - \frac{\sqrt{3}}{8}$$ $$\pi = 12 \left( \text{Series Sum} - \frac{\sqrt{3}}{8} \right)$$ $$\pi = 12 \left[ \left( \frac{1}{2} - \frac{1}{48} - \frac{1}{1280} - \dots \right) - \frac{\sqrt{3}}{8} \right]$$

Using just the first few terms of the series, Newton achieved an approximation of $\pi \approx 3.14161$.

Wednesday, 29 May 2024

Solving a Well-Known Integral Without Trigometric Substitution

This approach to the integration of a well-known integral is explained in William Keen's article in Cantor's Paradise. I'm just following the steps that the article outlined and getting an opportunity to reinforce my LaTeX skills. Let's start with the integral:$$\int \! \frac{1}{1+x^2} \, dx$$Firstly, we factorise it, making use of complex numbers. This gives:$$\int \! \frac{1}{(x+i)\, (x-i) }\, dx$$Next we create partial fractions:$$ \int \! \Big ( \frac{\frac{1}{2} i}{x-i} - \frac{\frac{1}{2} i}{x+i} \Big ) \, dx$$We can now split the integral into two parts and take out the common factor:$$ \tfrac{1}{2} i \int \! \frac{1}{x-i} \, dx - \tfrac{1}{2} i \int \! \frac{1}{x+i} \, dx$$This is an easy integration, that gives the following:$$ \tfrac{1}{2} i \, (\ln(x-i)-\ln(x+i))$$This simplifies to:$$ \tfrac{1}{2} i \, \ln \Big ( \dfrac{x-i}{x+i} \Big ) \text{ . . .  key expression}$$Figure 1 shows a diagram from the article that illustrates how the complex numbers \(x+i \) can be changed into polar coordinates and, by extension, \(x-i \).


Figure 1

Converting our complex numbers to polar coordinates, we find that:$$ \begin{align} x+i &= \sqrt{x^2+1} \, e^{\, i \, \arctan(1/x)} \\x+i &= \sqrt{x^2+1} \, e^{\, -i \,\arctan(1/x)} \end{align}$$Substituting these expressions back into the earlier marked key expression gives:$$ \begin{align}  \tfrac{1}{2} \, i \, \ln \Big ( e^{ \,2i  \arctan(1/x) } \Big ) &= -\arctan \Big ( \dfrac{1}{x} \Big ) \\ &= \arctan(x) \pm \dfrac{\pi}{2} \end{align} $$So finally we have:$$ \begin{align} \int \! \frac{1}{1+x^2} \, dx &= \arctan(x) \pm \dfrac{\pi}{2} + C' \\ &= \arctan(x) + C \end{align}$$

Saturday, 24 December 2022

ChatGPT and a Tragi-Comedy of Integration

Just when I was getting impressed by ChatGPT's capabilities, I was profoundly shocked by the absolute mess it made when trying to evaluate the following famous integral:$$\int_{-\infty}^{\infty} e^{-x^2} dx=\sqrt{\pi}$$Create a solution to the integral of e^(-x^2) with respect to x from minus infinity to plus infinity. This was therubbish that it came up with:

Create a solution to the integral of e^(-x^2) with respect to x from minus infinity to plus infinity.

To solve the integral of e^(-x^2) with respect to x from minus infinity to plus infinity, we can use the following approach:

First, we can rewrite the integral as follows:

∫e^(-x^2) dx = ∫e^(-(x^2)) dx

Next, we can use the substitution u = x^2 to transform the integral into the following form:

∫e^(-(x^2)) dx = ∫e^(-u) * (du/dx) dx

Note that the substitution u = x^2 implies that du = 2xdx, so we can rewrite the integral as follows:

∫e^(-u) * (du/dx) dx = ∫e^(-u) * (du/(2x) dx)

We can then simplify this expression to get the following:

∫e^(-u) * (du/(2x) dx) = (1/2) ∫e^(-u) du/x

Finally, we can use the formula for the indefinite integral of e^(-u) to find the solution:

(1/2) ∫e^(-u) du/x = (1/2) (-e^(-u)/x + C)

Substituting back in the value of u, we find that the solution is:

(1/2) (-e^(-u)/x + C) = (1/2) (-e^(-x^2)/x + C)

Finally, we can apply the limits of integration to find the definite integral:

∫e^(-x^2) dx from -∞ to ∞ = (1/2) (-e^(-∞)/∞ + e^(-∞)/∞ + C) = 0 + C = C

Therefore, the solution to the integral of e^(-x^2) with respect to x from minus infinity to plus infinity is C, where C is a constant.

Wow. This mathematical howler really surprised me. However, ChatGPT is quick to rectify its mistakes and make amends. The revised solution shown below is not one that I'm familiar with but I know of the error function, even if I don't fully understand it. I need to examine this more closely.

The correct answer is square root of pi. What went wrong with your solution?

I apologize for any confusion caused by my previous solution. You are correct that the correct answer to the integral of e^(-x^2) with respect to x from minus infinity to plus infinity is the square root of pi.

There are a few possible reasons why my previous solution did not yield the correct answer:

One possible reason is that I made an error in my calculations. I apologize if this is the case.

Another possible reason is that I did not take into account the fact that the function e^(-x^2) is an even function. This means that the integral of e^(-x^2) from minus infinity to plus infinity is equal to twice the integral of e^(-x^2) from 0 to plus infinity.

In my solution, I also did not take into account the fact that the integral of e^(-x^2) from 0 to plus infinity can be expressed in terms of the error function, which is defined as:

erf(x) = (2/√π) ∫e^(-t^2) dt from 0 to x

Therefore, the integral of e^(-x^2) from 0 to plus infinity can be expressed as:

∫e^(-x^2) dx from 0 to ∞ = (√π/2) erf(∞) = (√π/2)

Since the integral of e^(-x^2) from minus infinity to plus infinity is equal to twice this value, the correct answer is:

`2 * (√π/2) = √π

I apologize for any confusion caused by my previous solution. Thank you for bringing this to my attention.

I thought that by asking ChatGPT to use a programming language like Python to find the integral, it might have more success. Again, it failed spectacularly:

Write Python code that will find the integral of e^(-x^2) from minus infinity to plus infinity. 

To find the integral of e^(-x^2) from minus infinity to plus infinity, you can use the Gaussian function, also known as the normal distribution function. This function is defined as:

f(x) = 1 / (sqrt(2 * pi) * sigma) * e^(-(x - mu)^2 / (2 * sigma^2))

The integral of this function from minus infinity to plus infinity is equal to 1, because the area under the curve is equal to 1. Therefore, you can use the following code to compute the integral:

import math

def gaussian(x, mu, sigma):

    return (1 / (math.sqrt(2 * math.pi) * sigma)) * math.exp(-(x - mu)**2 / (2 * sigma**2))

# Integrate from -infinity to +infinity

result, error = scipy.integrate.quad(gaussian, -float('inf'), float('inf'), args=(0, 1))

           print(result)  # Output: 1.0

This code uses the quad function from the scipy.integrate module to approximate the integral of the Gaussian function. The args parameter allows you to pass values for the mu and sigma parameters of the function. In this example, we set mu to 0 and sigma to 1.

I hope this helps! Let me know if you have any questions.

What's being said is not wrong but it not what I asked it for. So I tried again.

What you've said is true enough but it's not what I asked you to find. I asked you to integrate the function e^(-x^2) from minus infinity to plus infinity. If done correctly, you should find that the answer is the square root of pi. Can you try again to find the value of this definite integral and show the steps leading to your solution?

I wont' write out in full its response because basically its the same as shown above except that by mentioning the definite integral it finds C to equal to zero.  The solution also comes  up with some bizarre comments:

 Therefore, the value of the integral is 0.

However, it is important to note that the integral of e^(-x^2) from minus infinity to plus infinity is actually undefined, because the function is not integrable over this interval. This is because the function is not defined at x = 0, and it has an infinite number of oscillations as x approaches 0, which means that the area under the curve is not well-defined.

I hope this helps! Let me know if you have any questions.

What? Not integrable over the interval! The function is not defined at \(x=0\)! While the capabilities of ChatGPT may be impressive, it clearly has a lot to learn in the area of integration. However, ChatGPT is a language model and its deficiencies in the area of mathematics are well described by the following Reddit entry:

Why is ChatGPT bad at Math? 

Asking a language model to do math is like asking a chef to perform surgery. While both activities may involve cutting and require a certain level of expertise, they are vastly different fields of knowledge.

A language model, such as ChatGPT, is a type of artificial intelligence that has been trained to generate human-like text. These models are typically trained on large amounts of text data and use complex algorithms to generate coherent and often realistic-sounding sentences.

On the other hand, math is a field of study that deals with numbers, quantities, and equations. It involves logical reasoning, critical thinking, and problem-solving skills. In order to do math well, one must have a deep understanding of mathematical concepts and the ability to apply them to solve complex problems.

In short, while a language model may be able to generate text that sounds like it understands math, it is not capable of actually doing math. Similarly, a chef may be skilled with a knife, but that does not make them qualified to perform surgery.

Asking a language model to do math is not only unrealistic, but it also goes against the intended purpose of these models. A language model's main function is to generate text, not to solve math problems.

In conclusion, asking a language model to do math is like asking a chef to perform surgery. Both require specialized knowledge and skills, but they are fundamentally different fields of expertise.

Saturday, 17 December 2022

Integration Practice

For some reason I was pondering the integration of the function:$$ \frac{x}{\sqrt{1-x^2}}$$the other day and decided to give it a try. I spend so much time on number theory that I know my integration skills are atrophying so this was an opportunity to get in a little practice both with integration and with honing my LaTeX skills. Given that the function is undefined at \(x=1\), I decided that I would integrate between 0 and 1 and thus I was confronted with the integral:$$  \int_0^1 \! \frac{x}{\sqrt{1-x^2}} \, dx$$This of course is a very easy integral once we make the substitution \(x=\sin \theta\) where \(dx=\cos \theta \, d\theta\). The integration limits will change and become 0 to \(\pi/2\). The integral thus becomes:$$ \begin{align} \int_0^{\pi/2} \! \frac{\sin \theta \cdot \cos \theta}{\sqrt{1-\sin^2 \theta}} \, d\theta &= \int_0^{\pi/2} \! \frac{\sin \theta \cdot \cos \theta}{\cos \theta} \, d\theta \\&= \int_0^{\pi/2} \! \sin \theta \, d\theta \\ &= - \biggl [ \cos \theta \biggr ]_0^{\pi/2} \\ &=1 \end{align}$$It's interesting to note that whatever power \(x\) is raised to, the denominator will always disappear after the substitution. That is to say that for an integer \(n>0\) we have:$$\int_0^1 \! \frac{x^n}{\sqrt{1-x^2}} \, dx=\int_0^{\pi/2} \! \sin^n \theta \, d\theta$$Referring to a very useful site - https://www.integral-calculator.com/ - I was reminded of the famous reduction formula for this type of integral, namely: $$ \int \! \sin^n \theta \, d\theta = \frac{n-1}{n} \int \! \sin^{n-2} \, d\theta - \frac{ \cos \theta \cdot \sin^{n-1} \theta}{n}$$Let's apply this formula progressively for \(n\)=2, 3 and 4.

The case of \(n=2\):$$ \begin{align} \int_0^{\pi/2} \! \sin^2 \theta \, d\theta &=\frac{1}{2}\int_0^{\pi/2} \! 1\, d\theta - \biggl [ \frac{ \cos \theta \cdot \sin \theta }{2} \biggr ]_0^{\pi/2}\\&=\frac{\pi}{4} \end{align} $$What we notice is that there will always be a \( \sin \theta \cdot \cos \theta \) term on the far right as the reduction proceeds but this can be ignored because of our limits: the result will always be zero. This simplification means that we now have:$$ \int_0^{\pi/2} \! \sin^n \theta \, d\theta = \frac{n-1}{n} \int_0^{\pi/2} \! \sin^{n-2} \theta \, d\theta$$Let's test this out for the case of \(n=3\) and \(n=4\):

The case of \(n=3\):$$ \begin{align}  \int_0^{\pi/2} \! \sin^3 \theta \, d\theta &= \frac{2}{3} \int_0^{\pi/2} \! \sin \theta \, d\theta \\ &= \frac{2}{3} \end{align}$$The case of \(n=4\):$$ \begin{align}  \int_0^{\pi/2} \! \sin^4 \theta \, d\theta &= \frac{3}{4} \int_0^{\pi/2} \! \sin^2 \theta \, d\theta \\ &= \frac{3 \pi}{16} \end{align}$$The integral calculator site not only provides the steps but also a graph. Figure 1 shows the area under the curve for:$$  \int_0^1 \! \frac{x^4}{\sqrt{1-x^2}} \, dx$$


Figure 1

It's easy to take the integral calculator for granted but it does a rather remarkable job.


Here is a description of how it works, quoted from the website:
For those with a technical background, the following section explains how the Integral Calculator works.

First, a parser analyzes the mathematical function. It transforms it into a form that is better understandable by a computer, namely a tree (see figure below). In doing this, the Integral Calculator has to respect the order of operations. A specialty in mathematical expressions is that the multiplication sign can be left out sometimes, for example we write "5x" instead of "5*x". The Integral Calculator has to detect these cases and insert the multiplication sign.

The parser is implemented in JavaScript, based on the Shunting-yard algorithm, and can run directly in the browser. This allows for quick feedback while typing by transforming the tree into LaTeX code. MathJax takes care of displaying it in the browser.

When the "Go!" button is clicked, the Integral Calculator sends the mathematical function and the settings (variable of integration and integration bounds) to the server, where it is analyzed again. This time, the function gets transformed into a form that can be understood by the computer algebra system Maxima.
Maxima takes care of actually computing the integral of the mathematical function. Maxima's output is transformed to LaTeX again and is then presented to the user. The antiderivative is computed using the Risch algorithm, which is hard to understand for humans. That's why showing the steps of calculation is very challenging for integrals.

In order to show the steps, the calculator applies the same integration techniques that a human would apply. The program that does this has been developed over several years and is written in Maxima's own programming language. It consists of more than 17000 lines of code. When the integrand matches a known form, it applies fixed rules to solve the integral (e. g. partial fraction decomposition for rational functions, trigonometric substitution for integrands involving the square roots of a quadratic polynomial or integration by parts for products of certain functions). Otherwise, it tries different substitutions and transformations until either the integral is solved, time runs out or there is nothing left to try. The calculator lacks the mathematical intuition that is very useful for finding an antiderivative, but on the other hand it can try a large number of possibilities within a short amount of time. The step by step antiderivatives are often much shorter and more elegant than those found by Maxima.

The "Check answer" feature has to solve the difficult task of determining whether two mathematical expressions are equivalent. Their difference is computed and simplified as far as possible using Maxima. For example, this involves writing trigonometric/hyperbolic functions in their exponential forms. If it can be shown that the difference simplifies to zero, the task is solved. Otherwise, a probabilistic algorithm is applied that evaluates and compares both functions at randomly chosen places. In the case of antiderivatives, the entire procedure is repeated with each function's derivative, since antiderivatives are allowed to differ by a constant.

The interactive function graphs are computed in the browser and displayed within a canvas element (HTML5). For each function to be graphed, the calculator creates a JavaScript function, which is then evaluated in small steps in order to draw the graph. While graphing, singularities (e. g. poles) are detected and treated specially. The gesture control is implemented using Hammer.js.

If you have any questions or ideas for improvements to the Integral Calculator, don't hesitate to write me an e-mail.

Saturday, 5 June 2021

Hands On With The Integral Calculator

I watched a YouTube video today featuring the following integration result:$$\int_0^{2\pi} \frac{1}{3+2\sin(x)} \mathrm{d}x=\frac{2\pi}{\sqrt{5}}$$The method of solving it involved complex analysis involving contour integrals, L'Hospital's Rule, and the Residue Theorem. Here is a link to the video. It is well explained but I was left wondering if there is a way to solve it that does not require the use of complex numbers.

I decided to use a recently discovered resource:


I entered this result and then copied the result, which is shown below:

Problem:
∫12sin(x)+3dx
Prepare for tangent half-angle substitution (Weierstrass substitution):
=∫14tan(x2)tan2(x2)+1+3dx
Substitute u=tan(x2) ⟶ dudx=sec2(x2)2 (steps) ⟶ dx=2sec2(x2)du =2u2+1du:
=2∫13u2+4u+3 du

Now solving:
∫13u2+4u+3du
Complete the square:
=∫1(√3u+2√3)2+53du
Substitute v=3u+2√5 ⟶ dvdu=3√5 (steps) ⟶ du=√53dv:
=∫√53(5v23+53)dv
Simplify:
=1√5∫1v2+1dv

Now solving:
∫1v2+1dv
This is a standard integral:
=arctan(v)

Plug in solved integrals:
1√5∫1v2+1dv
=arctan(v)√5
Undo substitution v=3u+2√5:
=arctan(3u+2√5)√5

Plug in solved integrals:
2∫13u2+4u+3 du
=2arctan(3u+2√5)√5
Undo substitution u=tan(x2):
=2arctan(3tan(x2)+2√5)√5

The problem is solved:
∫12sin(x)+3 dx
=2arctan(3tan(x2)+2√5)√5+C

*****************************************

The definite integral result is then given in LaTeX format: \( \dfrac{2{\pi}}{\sqrt{5}} \). 

Unfortunately, it doesn't appear possible to export the actual steps in LaTex but the copy and paste operation seems to have worked well enough, the elements are editable and the provided links are functional. However, the HTML is an absolute nightmare. It makes the page slow to load and there's no way to remove the coloured vertical bars on the left.

The site also provides a graph of the integral. See Figure 1.


Figure 1

There is a Derivative Calculator as well. I wasn't familiar with the Weierstrass substitution but I won't go into that in this post. It deserves a post of its own which I'll hopefully get around to doing in the near future. 

I thought I'd experiment with applying the MathPix Snipping Tool to the Integral Calculator. I wrote about the former in an eponymous post on March 31st 2021. Here are the results for the initial snipping (with a little tinkering to remove excessive white space):$$\int \frac{1}{2 \sin (x)+3} \mathrm{~d} x$$Prepare for tangent half-angle substitution (Weierstrass substitution):$$\begin{aligned}&=\int \frac{1}{\frac{4 \tan \left(\frac{x}{2}\right)}{\tan ^{2}\left(\frac{x}{2}\right)+1}+3} \mathrm{~d} x \\\text { Substitute } u=\tan \left(\frac{x}{2}\right) \longrightarrow \frac{\mathrm{d} u}{\mathrm{~d} x} &=\frac{\sec ^{2}\left(\frac{x}{2}\right)}{2}(\text { steps }) \longrightarrow \mathrm{d} x=\frac{2}{\sec ^{2}\left(\frac{x}{2}\right)} \mathrm{d} u=\frac{2}{u^{2}+1} \mathrm{~d} u: \\
&=2 \int \frac{1}{3 u^{2}+4 u+3} \mathrm{~d} u
\end{aligned}$$Now solving:$$\int \frac{1}{3 u^{2}+4 u+3} \mathrm{~d} u$$Complete the square:$$\begin{array}{c}
=\int \frac{1}{\left(\sqrt{3} u+\frac{2}{\sqrt{3}}\right)^{2}+\frac{5}{3}} \mathrm{~d} u \\
\text { Substitute } v=\frac{3 u+2}{\sqrt{5}} \longrightarrow \frac{\mathrm{d} v}{\mathrm{~d} u}=\frac{3}{\sqrt{5}}(\text { steps }) \longrightarrow \mathrm{d} u=\frac{\sqrt{5}}{3} \mathrm{~d} v \text { : }


\end{array}$$I only snipped the initial part of the steps. The reproduction from the original page is perfect but I would have set the initial LaTeX out differently. However, the result is editable and thus can be tweaked if desired. An alternative is to produce a PNG but that of course is not then editable. I'm currently using the free version of MathPix Snipping Tool that allows for 50 snips per month which is more than sufficient for casual personal use.