Calculating Value of Zeta function using Julia - Part1

Author: Kazi Abu Rousan

Where are the zeros of zeta of s?

G.F.B. Riemann has made a good guess;

They're all on the critical line, saith he,

And their density's one over 2 p log t.

Source https://www.physicsforums.com/threads/a-poem-on-the-zeta-function.16280/

If you are a person who loves to read maths related stuff then sure you have came across the words Riemann Zeta function and Riemann Hypothesis at least once. But today we are not going into the Riemann Hypothesis, rather we are going into the Zeta Function. To be more specific, we will see how to calculate the value of zeta function using a simple Julia Program only for $Re(input)>1$.

What is Zeta Function?

What is the Zeta Function?

The Riemann zeta function $\zeta (s)$ is a function of a complex variables $z = \sigma + i t $. When $Re(z) = \sigma >1$, we can define this as a converging summation given by,

$$ \zeta(z) = \sum_{n = 1}^{\infty} \frac{1}{n^z} = \frac{1}{1^z} + \frac{1}{2^z} + \frac{1}{3^z} +\cdots $$

This definition is so simple right?, Here $z$ is a complex number. If it is taken as real, then we will get many famous series like,

Harmonic Series(Diverge as $Re(z)=1$): $H = \zeta(1) = \frac{1}{1} + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \cdots$

Basel problem Series(Converges): $ \zeta(2) = \frac{1}{1^2} + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \cdots = \frac{\pi^2}{6}$

and many more.

There are many methods to calculate the values of this function for each value of $n$. You can surely do this by hand although I can't suggest that. The easiest way will be to utilize program.

Code to find the value of zeta for Re(z)>1

Before writing the code, you should remember that the sum is actually infinite. Hence, our function will give us more and more fine result as we include more and more terms.

function ζ(z,limit=1000)
    result = 0
    for i in 1:limit
        result += (1/i)^z
    end
    return result
end

This is the function. How simple!!.. and If we use julia as you can see, we can actually use $\zeta $ symbol. Pretty cool right?

ζ(2,10_0000_000)
#Output: 1.644934057834575
#where pi^2/6 = 1.6449340668482264
#pretty close

It's not all. We can actually apply this function to find the value of zeta function for complex inputs too.

ζ(2+5im)
#Output: 0.8510045028264933 + 0.09880538410302253im

When we use complex inputs, there is a beautiful hidden beauty. Let's see that using a plotting library called Plots and we also have to rewrite our function a little bit.

function ζ(z,limit=1000;point_ar = false)
    points = ComplexF64[0]
    result = 0
    for i in 1:limit
        result += (1/i)^z
        if point_ar
            push!(points,result)
        end
    end
    return result, points
end

Now, we can use this to plot.

z = 2+5im
result, points = ζ(z;point_ar = true)
plot((points),color=:blue,width=3, title="Zeta function spiral",framestyle= :origin,label="$z")
scatter!((points),color=:red, label="Points")S

The output is:

The complex power rotates each point.
Zoomed Image of the spiral

Who would have thought that there will be something like this hidden.

Now, If we apply this function to all possible points of the NumberPlane, then we will get a mesmerizing pattern.

Beautiful!!! But why is it feels like incomplete?

Looking at the image it feels like It's begging to be extended to the other portion. This extension is done using something we called Analytic Continuation. We will not go into much detail here.

If you want to know about the remaining story visit by lecture here:

This is all for today. Why not try to extend the idea to the other side?

Hope you learnt something new.

ISI MStat PSB 2012 Problem 2 | Dealing with Polynomials using Calculus

This is a very beautiful sample problem from ISI MStat PSB 2012 Problem 2 based on calculus . Let's give it a try !!

Problem- ISI MStat PSB 2012 Problem 2


Let \(f\) be a polynomial. Assume that \( f(0)=1, \lim _{x \rightarrow \infty} f''(x)=4\) and \( f(x) \geq f(1) \) for all \( x \in \mathbb{R} .\) Find \( f(2)\) .

Prerequisites


Limit

Derivative

Polynomials

Solution :

Here given \(f(x) \) is a polynomial and \( \lim _{x \rightarrow \infty} f''(x)=4\)

So, Case 1: If f(x) is a polynomial of degree 1 then f''(x)=0 hence limit can't be 4.

Case 2: If f(x) is a polynomial of degree 2 ,say \( f(x) = ax^2+bx+c \) then \( f''(x)= 2a \) .Hence taking limit we get \( 2a=4 \Rightarrow a=2 \)

Case 3: If f(x) is a polynomial of degree >2 then \( f''(x) = O(x) \) . So, it tends to infinity or - infinity as x tends to infinity .

Therefore the only case that satisfies the condition is Case 2 .

So , f(x) = \( 2x^2+bx+c \) ,say . Now given that \( f(0)=1 \Rightarrow c=1 \) .

Again , it is given that \( f(x) \geq f(1) \) for all \( x \in \mathbb{R} \) which implies that f(x) has minimum at x=1 .

That is f'(x)=0 at x=1 . Here we have \( f'(x)=4x+b=0 \Rightarrow x=\frac{-b}{4}=1 \Rightarrow b=-4 \)

Thus we get \( f(x)=2x^2-4x+1 \) . Putting x=2 , we get \( f(2)=1 \) .


Food For Thought

Assume f is differentiable on \( (a, b)\) and is continuous on \( [a, b]\) with \( f(a)=f(b)=0\). Prove that for every real \( \lambda\) there is some c in \( (a, b)\) such that \( f'(c)=\lambda f(c) \).


Similar Problems and Solutions



ISI MStat PSB 2008 Problem 10
Outstanding Statistics Program with Applications

Outstanding Statistics Program with Applications

Subscribe to Cheenta at Youtube


Function Problem | AIME I, 1988 | Question 2

Try this beautiful problem from the American Invitational Mathematics Examination I, AIME I, 1988 based on function.

Function Problem - AIME I, 1988


For any positive integer k, let \(f_1(k)\) denote the square of the sum of the digits of k. For \(n \geq 2\), let \(f_n(k)=f_1(f_{n-1}(k))\), find \(f_{1988}(11)\).

  • is 107
  • is 169
  • is 634
  • cannot be determined from the given information

Key Concepts


Functions

Equations

Algebra

Check the Answer


Answer: is 169.

AIME I, 1988, Question 2

Functional Equation by Venkatchala

Try with Hints


\(f_1(11)=4\)

or, \(f_2(11)=f_1(4)=16\)

or, \(f_3(11)=f_1(16)=49\)

or, \(f_4(11)=f_1(49)=169\)

or, \(f_5(11)=f_1(169)=256\)

or, \(f_6(11)=f_1(256)=169\)

or, \(f_7(11)=f_1(169)=256\)

This goes on between two numbers with this pattern, here 1988 is even,

or, \(f_1988(11)=f_4(11)=169\).

Subscribe to Cheenta at Youtube


Arranging in column | AIME I, 1990 | Question 8

Try this beautiful problem from the American Invitational Mathematics Examination I, AIME I, 1990 based on Arranging in column.

Arranging in column - AIME I, 1990


In a shooting match, eight clay targets are arranged in two hanging columns of three targets each and one column of two targets. A marks man is to break all the targets according to the following rules

1 ) The marksman first chooses a column from which a target is to be broken,

2 ) the marksman must then break the lowest remaining target in the chosen column. If the rules are followed, in how many different orders can the eight targets be broken?

  • is 107
  • is 560
  • is 840
  • cannot be determined from the given information

Key Concepts


Integers

Arrangement

Algebra

Check the Answer


Answer: is 560.

AIME I, 1990, Question 8

Combinatorics by Brualdi

Try with Hints


Let the columns be labelled A,B and C such that first three targets are A, A and A the next three being B, B and B and the next being C and C in which we consider the string AAABBBCC.

Since the arrangement of the strings is one-one correspondence and onto to the order of shooting for example first A is shot first, second A is shot second, third A is shot third, first B is shot fourth, second B is shot fifth, third B is shot sixth, first C is shot seventh, second C is shot eighth,

or, here arrangement of the strings is bijective to the order of the shots taken

the required answer is the number of ways to arrange the letters which is \(\frac{8!}{3!3!2!}\)=560.

Subscribe to Cheenta at Youtube


Problem on Function | TOMATO BStat Objective 720

Try this problem from I.S.I. B.Stat Entrance Objective Problem based on Function.

Problem on Function (B.Stat Objective Question )


Consider the function f(x)=\(tan^{-1}(2tan(\frac{x}{2}))\), where \(\frac{-\pi}{2} \leq f(x) \leq \frac{\pi}{2}\) Then

  • \(\lim\limits_{x \to \pi-0}f(x)=\frac{\pi}{2}\), \(\lim\limits_{x \to \pi+0}f(x)=\frac{-\pi}{2}\)
  • \(\lim\limits_{x \to \pi}f(x)=\frac{\pi}{2}\)
  • \(\lim\limits_{x \to \pi-0}f(x)=\frac{-\pi}{2}\), \(\lim\limits_{x \to \pi+0}f(x)=\frac{\pi}{2}\)
  • \(\lim\limits_{x \to \pi}f(x)=\frac{-\pi}{2}\)

Key Concepts


Equation

Roots

Algebra

Check the Answer


Answer:\(\lim\limits_{x \to \pi}f(x)=\frac{\pi}{2}\)

B.Stat Objective Problem 720

Challenges and Thrills of Pre-College Mathematics by University Press

Try with Hints


f(x)=\(tan^{-1}(2tan{\frac{x}{2}})\)

\(\lim\limits_{x \to \pi}f(x)\)

\(=\lim\limits_{x \to \pi}tan^{-1}(2tan{\frac{x}{2}})=\frac{\pi}{2}\)

\(\lim\limits_{x \to \pi-0}f(x)\)

\(=\lim\limits_{x \to \pi-0}tan^{-1}(2tan{\frac{x}{2}})=\frac{\pi}{2}\)

\(\lim\limits_{x \to \pi+0}f(x)\)

\(=\lim\limits_{x \to \pi+0}tan^{-1}(2tan{\frac{x}{2}})=\frac{\pi}{2}\)

So \(\lim\limits_{x \to \pi}f(x)=\frac{\pi}{2}\)

Subscribe to Cheenta at Youtube


Roots of Equation | TOMATO B.Stat Objective 711

Try this problem from I.S.I. B.Stat Entrance Objective Problem based on Roots of Equation.

Roots of Equations (B.Stat Objective Question )


The number of roots of the equation \(x^2+sin^2{x}-1\) in the closed interval \([0,\frac{\pi}{2}]\) is

  • 0
  • 2
  • 53361
  • 5082

Key Concepts


Equation

Roots

Algebra

Check the Answer


Answer:2

B.Stat Objective Problem 711

Challenges and Thrills of Pre-College Mathematics by University Press

Try with Hints


\(x^2+sin^2{x}-1=0\)

\(\Rightarrow x^{2}=cos^{2}x\)

we draw two graphs \(y=x^{2} and y=cos^{2}x\)

where intersecting point gives solution now we look for intersecting points

we get two intersecting points

so number of roots is 2.

Subscribe to Cheenta at Youtube


Periodic Function | TOMATO B.Stat Objective 710

Try this problem from I.S.I. B.Stat Entrance Objective Problem based on Periodic Function.

Periodic Function (B.Stat Objective Question )


If f(x) = \(a_0+a_1cosx+a_2cos2x+....+a_ncosnx\) where \(a_0,a_1,....,a_n\) are non zero real numbers and \(a_n > |a_0|+|a_1|+....+|a_{n-1}|\), then number of roots of f(x)=0 in \( 0 \leq x \leq 2\pi\), is

  • 0
  • at least 2n
  • 53361
  • 5082

Key Concepts


Periodic

Real Numbers

Inequality

Check the Answer


Answer:at least 2n

B.Stat Objective Problem 710

Challenges and Thrills of Pre-College Mathematics by University Press

Try with Hints


f is periodic with period \(2\pi\)

here \(0 <|\displaystyle\sum_{k=0}^{n-1}a_kcos(kx)| \leq \displaystyle\sum_{k=0}^{n-1}|a_k|<a_n, x\in\)set of reals

for points \(x_k=\frac{k\pi}{n}\) \(1 \leq k \leq 2n\)

\(f(x_k)=a_n[cos(k\pi)+\theta], |\theta|<1 for 1 \leq k \leq 2n\)

[ since cos \(\theta\) is periodic and f(x) is expressed for every point x=\(x_k\)]

f has at least 2n points in such a period interval where f has alternating sign.

Subscribe to Cheenta at Youtube


Equations and Roots | TOMATO B.Stat Objective 123

Try this problem from I.S.I. B.Stat Entrance Objective Problem based on Equations and Roots.

Equation and Roots ( B.Stat Objective Question )


Consider the equation of the form \(x^{2}+bx+c=0\). The number of such equations that have real roots and have coefficients b and c in the set {1,2,3,4,5,6}, (b may be equal to c), is

  • 1113
  • 18
  • 53361
  • 5082

Key Concepts


Equation

Integers

Roots

Check the Answer


Answer: 18.

B.Stat Objective Problem 123

Challenges and Thrills of Pre-College Mathematics by University Press

Try with Hints


We know that if a quadratic equations have real roots then it's discriminant is >=0 so here \( b^{2}-4c \geq 0\). Now we will go casewise . First we will choose a particular Value for b then check what are the values of c that satisfies the above inequality.

for b=2, c=1

for b=3, c=1,2

for b=4, c=1,2,3,4

for b=5, c=1,2,3,4,5

for b=6, c=1,2,3,4,5,6

we get required number =18.

Subscribe to Cheenta at Youtube


Digits and Order | AIME I, 1992 | Question 2

Try this beautiful problem from the American Invitational Mathematics Examination I, AIME I, 1992 based on Digits and Order.

Digits and order - AIME I, 1992


A positive integer is called ascending if, in its decimal representation, there are at least two digits and each digit is less than any digit to its right. Find number of ascending positive integers are there.

  • is 107
  • is 502
  • is 840
  • cannot be determined from the given information

Key Concepts


Integers

Digits

Order

Check the Answer


Answer: is 502.

AIME I, 1992, Question 2

Elementary Number Theory by David Burton

Try with Hints


There are nine digits that we use 1,2,3,4,5,6,7,8,9.

Here each digit may or may not be present.

\(\Rightarrow 2^{9}\)=512 potential ascending numbers, one for subset of {1,2,3,4,5,6,7,8,9}

Subtracting empty set and single digit set

=512-10

=502.

Subscribe to Cheenta at Youtube


Remainders and Functions | AIME I, 1994 | Question 7

Try this beautiful problem from the American Invitational Mathematics Examination I, AIME I, 1994 based on Remainders and Functions.

Remainders and Functions - AIME I, 1994


The function f has the property that, for each real number x, \(f(x)+f(x-1)=x^{2}\) if f(19)=94, find the remainder when f(94) is divided by 1000.

  • is 107
  • is 561
  • is 840
  • cannot be determined from the given information

Key Concepts


Integers

Remainder

Functions

Check the Answer


Answer: is 561.

AIME I, 1994, Question 7

Elementary Number Theory by David Burton

Try with Hints


f(94)=\(94^{2}-f(93)=94^{2}-93^{2}+f(92)\)

=\(94^{2}-93^{2}+92^{2}-f(91)\)

=\((94^{2}-93^{2})+(92^{2}-91^{2})\)

\(+....+(22^{2}-21^{2})+20^{2}-f(19)\)

=94+93+.....+21+400-94

=4561

\(\Rightarrow\) remainder =561.

Subscribe to Cheenta at Youtube