1. Home
  2. Explore
  3. Mathematics
  4. Prime Numbers Near a Trillion

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Prime Numbers Near a Trillion

Natural Logarithms, Prime Numbers, and Exponential Growth

Prime density at large numbers

Prime numbers become less frequent as numbers grow. A number has more possible factors to test when it is large, so checking whether a large number is prime takes more work. For example, trial division only needs to test possible factors up to approximately the square root of the number.

A useful estimate for the density of primes near a large number xxx is

1ln⁡x,\frac{1}{\ln x},lnx1​,

where ln⁡x\ln xlnx is the natural logarithm of xxx. This is a local estimate: among numbers near xxx, roughly one in every ln⁡x\ln xlnx is prime.

For numbers near one trillion, x=1012x=10^{12}x=1012, and

ln⁡(1012)=12ln⁡(10)≈27.6.\ln(10^{12})=12\ln(10)\approx 27.6.ln(1012)=12ln(10)≈27.6.

Thus, near one trillion, the estimate is roughly one prime in every 282828 numbers. In a range of 1,0001{,}0001,000 consecutive integers, this predicts about

1,000ln⁡(1012)≈36\frac{1{,}000}{\ln(10^{12})}\approx 36ln(1012)1,000​≈36

primes. In the range from one trillion through one trillion plus 1,0001{,}0001,000, there are 373737 primes, so the observed proportion is

371,000=0.037,\frac{37}{1{,}000}=0.037,1,00037​=0.037,

or about one prime in every 272727 numbers. This is close to the logarithmic estimate.

The Prime Number Theorem gives a related large-scale approximation: the number of primes up to xxx is approximately x/ln⁡xx/\ln xx/lnx. The local density estimate 1/ln⁡x1/\ln x1/lnx captures the corresponding idea that primes thin out gradually, rather than disappearing rapidly.

Near a large number xxx, the proportion of integers that are prime is approximately 1/ln⁡x1/\ln x1/lnx.


Natural logarithms

The natural logarithm is the logarithm with base eee. The statement

ln⁡x=y\ln x=ylnx=y

means exactly that

ey=x.e^y=x.ey=x.

In other words, ln⁡x\ln xlnx asks: “To what power must eee be raised to obtain xxx?”

For example,

ln⁡(10)≈2.3\ln(10)\approx 2.3ln(10)≈2.3

because e2.3e^{2.3}e2.3 is approximately 101010. This value is useful for converting between powers of eee and powers of 101010.

The natural logarithm appears in the estimate for prime density: near x=1012x=10^{12}x=1012, the reciprocal logarithm 1/ln⁡x1/\ln x1/lnx predicts how frequently primes occur. Its appearance is one instance of a broader mathematical pattern: logarithms and primes are connected through series and products built from prime numbers.


Infinite series connected to π\piπ and primes

An infinite series is a sum of a sequence of terms. Some series approach a finite value as more terms are added; others grow without bound.

The sum of reciprocal squares

The series

1+122+132+142+⋯=∑n=1∞1n21+\frac{1}{2^2}+\frac{1}{3^2}+\frac{1}{4^2}+\cdots = \sum_{n=1}^{\infty}\frac{1}{n^2}1+221​+321​+421​+⋯=∑n=1∞​n21​

converges to the value

∑n=1∞1n2=π26.\sum_{n=1}^{\infty}\frac{1}{n^2}=\frac{\pi^2}{6}.∑n=1∞​n21​=6π2​.

This result, known as the Basel problem, is surprising because it connects the familiar constant π\piπ with the sum of reciprocals of integer squares.

Filtering the series to keep prime powers

The sum of reciprocal squares can be rearranged using prime factorization. Every integer greater than 111 is built from primes, and the resulting identity is

ln⁡(∑n=1∞1n2)=∑p prime∑k=1∞1kp2k,\ln\left(\sum_{n=1}^{\infty}\frac{1}{n^2}\right) = \sum_{p\ \mathrm{prime}}\sum_{k=1}^{\infty} \frac{1}{k p^{2k}},ln(∑n=1∞​n21​)=∑p prime​∑k=1∞​kp2k1​,

so that

∑p prime∑k=1∞1kp2k=ln⁡(π26).\sum_{p\ \mathrm{prime}}\sum_{k=1}^{\infty} \frac{1}{k p^{2k}} = \ln\left(\frac{\pi^2}{6}\right).∑p prime​∑k=1∞​kp2k1​=ln(6π2​).

This double sum includes terms associated with prime powers. A prime ppp contributes its own term, and each power pkp^kpk contributes a term scaled by 1/k1/k1/k. For instance, the prime power 4=224=2^24=22 contributes with a factor of 1/21/21/2, and 8=238=2^38=23 contributes with a factor of 1/31/31/3. Numbers with multiple different prime factors, such as 666, do not appear as individual prime powers in this sum.

The logarithm arises from the relationship between sums and products. The Euler product for the reciprocal-square series is

∑n=1∞1n2=∏p prime11−p−2.\sum_{n=1}^{\infty}\frac{1}{n^2} = \prod_{p\ \mathrm{prime}}\frac{1}{1-p^{-2}}.∑n=1∞​n21​=∏p prime​1−p−21​.

Taking the logarithm of a product turns it into a sum. Expanding each factor then produces the terms involving prime powers.

An alternating series involving primes

Another series connected to π\piπ is the alternating sum over odd integers:

1−13+15−17+19−⋯=π4.1-\frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\frac{1}{9}-\cdots = \frac{\pi}{4}.1−31​+51​−71​+91​−⋯=4π​.

This is the alternating odd-reciprocal series. If its terms are reorganized using odd prime numbers and their powers, the corresponding prime-based sum gives

ln⁡(π4).\ln\left(\frac{\pi}{4}\right).ln(4π​).

The prime-power terms carry signs determined by the alternating pattern, and prime powers are scaled according to their exponent. The relationship is another example of a logarithm turning a product involving primes into a sum over primes and their powers.

These identities show why prime numbers, prime powers, logarithms, and π\piπ often appear together: prime factorizations organize infinite products, and logarithms convert those products into sums.


Two important series involving reciprocals

The alternating harmonic series

The series

1−12+13−14+15−⋯1-\frac{1}{2}+\frac{1}{3}-\frac{1}{4}+\frac{1}{5}-\cdots1−21​+31​−41​+51​−⋯

converges to

ln⁡2.\ln 2.ln2.

Since ln⁡2≈0.693\ln 2\approx 0.693ln2≈0.693, the partial sums approach a value just under 0.70.70.7. Although the terms become smaller and the sum settles to a finite value, it does so slowly.

This series is part of a more general family:

x−x22+x33−x44+⋯=ln⁡(1+x),x-\frac{x^2}{2}+\frac{x^3}{3}-\frac{x^4}{4}+\cdots = \ln(1+x),x−2x2​+3x3​−4x4​+⋯=ln(1+x),

for −1<x≤1-1<x\leq 1−1<x≤1. Substituting x=1x=1x=1 gives the alternating harmonic series and the value ln⁡2\ln 2ln2.

The harmonic series

In contrast, the nonalternating harmonic series

1+12+13+14+⋯1+\frac{1}{2}+\frac{1}{3}+\frac{1}{4}+\cdots1+21​+31​+41​+⋯

does not converge. Its terms get smaller, but their sum grows without bound. It eventually exceeds any fixed target, such as 100100100 or a million.

A useful way to understand this divergence is to group terms in ranges whose sizes double:

1,12,(13+14),(15+⋯+18),(19+⋯+116),…1,\qquad \frac{1}{2},\qquad \left(\frac{1}{3}+\frac{1}{4}\right),\qquad \left(\frac{1}{5}+\cdots+\frac{1}{8}\right),\qquad \left(\frac{1}{9}+\cdots+\frac{1}{16}\right),\ldots1,21​,(31​+41​),(51​+⋯+81​),(91​+⋯+161​),…

In each group, every term is at least as large as the reciprocal of the group’s largest denominator.

  • The group containing 1/31/31/3 and 1/41/41/4 has two terms, each at least 1/41/41/4, so its sum is at least 2(1/4)=1/22(1/4)=1/22(1/4)=1/2.

  • The group from 1/51/51/5 through 1/81/81/8 has four terms, each at least 1/81/81/8, so its sum is at least 4(1/8)=1/24(1/8)=1/24(1/8)=1/2.

  • The group from 1/91/91/9 through 1/161/161/16 has eight terms, each at least 1/161/161/16, so its sum is at least 8(1/16)=1/28(1/16)=1/28(1/16)=1/2.

Every such group contributes at least 1/21/21/2. Since there are infinitely many groups, the total sum cannot remain bounded.

The harmonic sum grows logarithmically

Although the harmonic series diverges, it grows very slowly. The partial sum through 1/n1/n1/n is approximately

Hn=∑k=1n1k≈ln⁡n.H_n=\sum_{k=1}^{n}\frac{1}{k}\approx \ln n.Hn​=∑k=1n​k1​≈lnn.

A more accurate approximation includes a constant:

Hn≈ln⁡n+γ,H_n\approx \ln n+\gamma,Hn​≈lnn+γ,

where γ\gammaγ is the Euler–Mascheroni constant, approximately 0.5770.5770.577. Equivalently, the difference between the harmonic sum and ln⁡n\ln nlnn approaches γ\gammaγ as nnn becomes large.

This logarithmic growth explains why an enormous number of terms is needed for the harmonic sum to reach a large target. If the sum is to exceed approximately one million, the estimate Hn≈ln⁡nH_n\approx\ln nHn​≈lnn suggests

ln⁡n≈1,000,000,\ln n\approx 1{,}000{,}000,lnn≈1,000,000,

and therefore

n≈e1,000,000.n\approx e^{1{,}000{,}000}.n≈e1,000,000.

Expressed as a power of 101010,

e1,000,000=101,000,000/ln⁡(10)≈10434,294.e^{1{,}000{,}000} = 10^{1{,}000{,}000/\ln(10)} \approx 10^{434{,}294}.e1,000,000=101,000,000/ln(10)≈10434,294.

A rough estimate using ln⁡(10)≈2\ln(10)\approx 2ln(10)≈2 gives a value near 10500,00010^{500{,}000}10500,000; using the more accurate value ln⁡(10)≈2.3\ln(10)\approx 2.3ln(10)≈2.3 gives an exponent near 434,000434{,}000434,000. Either way, the required nnn is vastly larger than the estimated number of atoms in the universe, around 108010^{80}1080.


Why calculus explains the harmonic-series estimates

The natural logarithm has a particularly useful derivative:

ddxln⁡x=1x.\frac{d}{dx}\ln x=\frac{1}{x}.dxd​lnx=x1​.

Consequently, the area under the curve y=1/xy=1/xy=1/x from 111 to nnn is

∫1n1x dx=ln⁡n.\int_1^n \frac{1}{x}\,dx = \ln n.∫1n​x1​dx=lnn.

The harmonic sum and this integral are closely related. Each term 1/k1/k1/k can be pictured as the area of a rectangle of width 111 and height 1/k1/k1/k. The rectangles approximate the area under 1/x1/x1/x. With the standard placement of these rectangles, their total area is greater than the integral, because some rectangle area lies above the curve.

Thus,

∑k=1n1kis close to∫1n1x dx=ln⁡n.\sum_{k=1}^{n}\frac{1}{k} \quad\text{is close to}\quad \int_1^n\frac{1}{x}\,dx=\ln n.∑k=1n​k1​is close to∫1n​x1​dx=lnn.

The gap between the two quantities approaches the Euler–Mascheroni constant. This comparison connects a sum of discrete terms with the continuous area described by an integral.


Why exponentials are usually written using eee

Different bases describe the same exponential families

A family of exponential functions can be written in several equivalent ways. For example,

ax=exln⁡a.a^x=e^{x\ln a}.ax=exlna.

The base aaa can be expressed using eee because eln⁡a=ae^{\ln a}=aelna=a. Thus, varying aaa in axa^xax is equivalent to varying the coefficient of xxx in erxe^{rx}erx.

There is nothing inherently special about writing an exponential with base eee if the only goal is to describe its shape. The same family of curves could be written with another positive base, such as π\piπ. The advantage of using eee becomes clear when studying rates of change.

The derivative of an exponential

The exponential function with base eee satisfies

ddtet=et.\frac{d}{dt}e^t=e^t.dtd​et=et.

It is the function whose rate of change at each point is equal to its current value. More generally, by the chain rule,

ddtert=rert.\frac{d}{dt}e^{rt}=r e^{rt}.dtd​ert=rert.

The value rrr is the proportionality constant between the function’s current size and its rate of change. For example, if erte^{rt}ert represents an investment’s value over time, its instantaneous rate of growth is rrr times its current value.

For an exponential with a different base,

ddtat=(ln⁡a)at.\frac{d}{dt}a^t=(\ln a)a^t.dtd​at=(lna)at.

Writing the function as etln⁡ae^{t\ln a}etlna makes the rate-of-change constant explicit. This is why eee is the standard choice in calculus, physics, and engineering: it keeps the relationship between a changing quantity and its rate of change especially simple.


The exponential function as a power series

The exponential function can be represented by the infinite series

exp⁡(x)=1+x+x22!+x33!+x44!+⋯=∑n=0∞xnn!.\exp(x)=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\cdots = \sum_{n=0}^{\infty}\frac{x^n}{n!}.exp(x)=1+x+2!x2​+3!x3​+4!x4​+⋯=∑n=0∞​n!xn​.

Here, n!n!n! is the factorial of nnn. The notation exp⁡(x)\exp(x)exp(x) emphasizes that the function can be defined by this series, including when xxx is complex.

Term-by-term differentiation shows why the exponential is its own derivative:

ddx(1+x+x22!+x33!+⋯ )=1+x+x22!+⋯ .\frac{d}{dx}\left(1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots\right) = 1+x+\frac{x^2}{2!}+\cdots.dxd​(1+x+2!x2​+3!x3​+⋯)=1+x+2!x2​+⋯.

Each power comes down as a multiplier, canceling one factor in the factorial denominator. Differentiation therefore reproduces the same series.

The function also has the addition property

exp⁡(a+b)=exp⁡(a)exp⁡(b).\exp(a+b)=\exp(a)\exp(b).exp(a+b)=exp(a)exp(b).

If eee is defined as exp⁡(1)\exp(1)exp(1), this property leads to the usual exponential notation exp⁡(x)=ex\exp(x)=e^xexp(x)=ex. Thus, exe^xex can be viewed either as an exponential function or as shorthand for the power series.

A different route to the same function is to define eee through the derivative property: it is the base for which the derivative of exe^xex equals exe^xex. Either viewpoint highlights the same central relationship between exponentials and rates of change.


Exponentials in probability and statistics

A bell-shaped curve can be built from an exponential involving a negative square, such as

e−x2.e^{-x^2}.e−x2.

As xxx becomes large in either the positive or negative direction, x2x^2x2 becomes large, so −x2-x^2−x2 becomes strongly negative and the exponential approaches zero. The curve therefore decays on both sides of its center.

Using ∣x∣|x|∣x∣ instead would also make an expression decay in both directions, but it would create a sharp cusp at x=0x=0x=0. The square produces a smooth bell shape.

A normal distribution uses a shifted and rescaled version of this form. Its parameters control the location and width of the distribution: the mean determines its center, and the standard deviation determines its spread. The particular constants in the exponent are chosen so that these parameters have their standard statistical meanings.

The shape is not unique to the base eee: powers of another suitable base can describe the same family of bell curves after adjusting the parameters. Again, eee is especially convenient because it simplifies calculus and makes the parameters easier to work with.


Complex exponentials and rotation

Complex exponentials describe oscillation and rotation. The expression

eite^{it}eit

moves around the unit circle in the complex plane as ttt changes. It can be written as

eit=cos⁡t+isin⁡t.e^{it}=\cos t+i\sin t.eit=cost+isint.

As ttt increases, the point travels around the circle, with ttt measuring the angle in radians. This relationship makes complex exponentials useful for describing sine waves, cosine waves, and oscillating signals in fields such as electrical engineering.

However, the rotational behavior is not exclusive to base eee. Since

ait=eitln⁡a,a^{it}=e^{it\ln a},ait=eitlna,

a complex exponential with another base also rotates around the unit circle; it simply changes the rate at which the angle advances.

The special convenience of eite^{it}eit can be understood through differentiation:

ddteit=ieit.\frac{d}{dt}e^{it}=i e^{it}.dtd​eit=ieit.

Multiplication by iii rotates a complex vector by 90∘90^\circ90∘. Thus, the rate of change of the position vector is always perpendicular to the vector itself. Because the vector has length 111, the velocity also has length 111, giving motion around the unit circle at a constant rate. For a different base, the factor ln⁡a\ln alna changes that rate.


Directly deriving the derivative of an exponential

The rate of change of axa^xax can be derived using the definition of the derivative. A small change hhh in the input gives the difference quotient

ax+h−axh.\frac{a^{x+h}-a^x}{h}.hax+h−ax​.

Using ax+h=axaha^{x+h}=a^x a^hax+h=axah, this becomes

axah−1h.a^x\frac{a^h-1}{h}.axhah−1​.

As hhh approaches zero, the factor axa^xax remains fixed. Therefore, the derivative is

ddxax=axlim⁡h→0ah−1h.\frac{d}{dx}a^x = a^x\lim_{h\to 0}\frac{a^h-1}{h}.dxd​ax=axlimh→0​hah−1​.

The limit is a constant determined by the base aaa; that constant is ln⁡a\ln alna. Hence,

ddxax=(ln⁡a)ax.\frac{d}{dx}a^x=(\ln a)a^x.dxd​ax=(lna)ax.

For example, when a=2a=2a=2, the constant is

ln⁡2≈0.693.\ln 2\approx 0.693.ln2≈0.693.

So the rate of change of 2x2^x2x is approximately 0.6930.6930.693 times the current value of 2x2^x2x.

The base eee is distinguished by satisfying ln⁡e=1\ln e=1lne=1. Therefore,

ddxex=ex.\frac{d}{dx}e^x=e^x.dxd​ex=ex.

The derivative of the natural logarithm

The natural logarithm is the inverse of the exponential function. If

y=ln⁡x,y=\ln x,y=lnx,

then equivalently

ey=x.e^y=x.ey=x.

Differentiating this relationship gives

eydydx=1.e^y\frac{dy}{dx}=1.eydxdy​=1.

Since ey=xe^y=xey=x, this can be rearranged to obtain

dydx=1x.\frac{dy}{dx}=\frac{1}{x}.dxdy​=x1​.

Thus,

ddxln⁡x=1x.\frac{d}{dx}\ln x=\frac{1}{x}.dxd​lnx=x1​.

This derivative also gives a useful qualitative check: as xxx increases, 1/x1/x1/x decreases, so the graph of ln⁡x\ln xlnx becomes progressively less steep.


Deriving the alternating harmonic sum with calculus

Consider the function defined by the power series

F(x)=x−x22+x33−x44+⋯ .F(x)=x-\frac{x^2}{2}+\frac{x^3}{3}-\frac{x^4}{4}+\cdots.F(x)=x−2x2​+3x3​−4x4​+⋯.

For values of xxx with ∣x∣<1|x|<1∣x∣<1, differentiating term by term yields

F′(x)=1−x+x2−x3+⋯ .F'(x)=1-x+x^2-x^3+\cdots.F′(x)=1−x+x2−x3+⋯.

This is a geometric series with first term 111 and common ratio −x-x−x, so

F′(x)=11+x.F'(x)=\frac{1}{1+x}.F′(x)=1+x1​.

An antiderivative of 1/(1+x)1/(1+x)1/(1+x) is ln⁡(1+x)\ln(1+x)ln(1+x). Since F(0)=0F(0)=0F(0)=0, it follows that

F(x)=ln⁡(1+x).F(x)=\ln(1+x).F(x)=ln(1+x).

Setting x=1x=1x=1 gives

1−12+13−14+⋯=ln⁡2.1-\frac{1}{2}+\frac{1}{3}-\frac{1}{4}+\cdots=\ln 2.1−21​+31​−41​+⋯=ln2.

The result depends on recognizing several connected patterns: differentiating the powers cancels their denominators, the remaining terms form a geometric series, and integrating the geometric-series expression produces a natural logarithm.


Key connections

  • Prime density: Near a large number xxx, the proportion of integers that are prime is approximately 1/ln⁡x1/\ln x1/lnx.

  • Prime powers and logarithms: Euler products built from primes become sums over prime powers when logarithms are taken.

  • Harmonic growth: The partial sum ∑k=1n1/k\sum_{k=1}^{n}1/k∑k=1n​1/k grows approximately like ln⁡n\ln nlnn, even though it diverges.

  • Natural logarithm and area: Since the derivative of ln⁡x\ln xlnx is 1/x1/x1/x, the area under 1/x1/x1/x from 111 to nnn is ln⁡n\ln nlnn.

  • Why base eee is useful: The derivative of exe^xex is itself, making exponential growth, logarithmic change, and calculus especially simple.

  • Alternating harmonic series: Alternating reciprocal terms converge to ln⁡2\ln 2ln2, a result obtained by connecting a power series, a geometric series, and an integral.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent