Try this beautiful Problem based on simple Arithmetic appeared in Math Kangaroo (Kadett) 2021 Problem 17.
Math Kangaroo 2021 Problem 17 | Kadett
There are 20 questions in a quiz. Each correct answer scores 7 points, each wrong answer scores $-4$ points, and each question left blank scores 0 points. Eric took the quiz and scored 100 points. How many questions did he leave blank?
0
1
2
3
4
Key Concepts
Arithmetic
Divisibility
Logic Question
Suggested Book | Source | Answer
Algebra by Gelfand
Math Kangaroo (Kadett), 2021
$1$
Try with Hints
Here given that,
Total number of questions $=20$ Score of correct answer $=7$ points Score of wrong answer $=-4$ Eric scored $=100$ points
So that mean, the score for all of the correct answers is greater than $100$.
Now we know $7\times 16 = 112$.
Now we have to count how many wrong answers are there if the score is $100$.
Remaining question $=20-(16+3)$ So, $1$ is the correct answer.
Try this beautiful Problem based on simple Divisibility Rules appeared in Math Kangaroo (Ecolier) 2021 Problem 21.
Math Kangaroo 2021 Problem No 21 | Ecolier
A box has fewer than 50 cookies in. The cookies can be divided evenly between 2,3 , or 4 children. However, they cannot be divided evenly between 7 children because 6 more cookies would be needed. How many cookies are there in the box?
12
24
30
36
48
Key Concepts
Arithmetic
Divisibility
Algebra
Suggested Book | Source | Answer
Algebra by Gelfand
Math Kangaroo (Ecolier), 2021
$36$
Try with Hints
Here
The box contain less than 50 cookies.
Cookies are distributed among 2, 3 or 4 children.
So, all of the options are correct.
Now apply the second condition in the question.
They cannot be divided evenly between 7 children because 6 more cookies would be needed.
Apply the condition and check which option is satisfying the condition.
Try this beautiful Problem based on simple Algebra appeared in Math Kangaroo (Benjamin) 2014 Problem 24.
Math Kangaroo (Benjamin) 2014 | Problem No 24
Grandma gives 180 marbles to her ten grandchildren. No two children get the same amount of marbles. Anna gets the most. What is the minimum number of marbles that Anna could get?
19
20
21
22
23
Key Concepts
Arithmetic
Equation solving
Algebra
Suggested Book | Source | Answer
Algebra by Gelfand
Math Kangaroo (Benjamin), 2014
$23$
Try with Hints
Here
Number of children is $10$. Number of marbles is $180$. And Anna gets the most and no 2 children gets the same number of marbles.
Let us assume that Anna could get $x$ marbles and also the other 9 children receiving 1 less each step. Apply the condition to construct the equation
Math Kangaroo Benjamin 2014 Problem 11 | Arithmetic
Try this beautiful Problem based on Simple Arithmetic from Math Kangraoo Benjamin 2014 Problem 11.
Arithmetic | Math Kangaroo Benjamin 2014 Problem 11
In a holiday camp 7 children eat ice cream every day, 9 eat ice cream every other day. The remaining children don't eat ice cream at all. Yesterday 13 children ate ice cream. How many children will eat ice cream today?
7
8
9
10
11
Key Concepts
Substraction
Arithmetic
Suggested Book | Source | Answer
Mathematics Can Be Fun by Perelman
Math Kangraoo Benjamin 2014 Problem number 11
10
Try with Hints
Find the number of the ones who eat on alternative days.
Now find for today how many participants are there.
Try this beautiful Problem based on simple Arithmetic appeared in Math Kangaroo (Benjamin) - 2021.
Math Kangaroo (Benjamin) 2021 | Problem No 22
Maurice asked the canteen chef for the recipe for his pancakes. Maurice has 6 eggs, $400 \mathrm{~g}$ flour, 0,5 liters of milk and $200 \mathrm{~g}$ butter. What is the largest number of pancakes he can make using this recipe?
Math Kangaroo (Benjamin) 2020 Problem 26 | Divisibility Rule
Try this beautiful Problem based on Divisibility Rule from Math Kangaroo (Benjamin) 2020.
Math Kangaroo (Benjamin), 2020 | Problem No 26
We say that a three-digit number is balanced if the middle digit is the arithmetic mean of the other two digits. How many balanced numbers are divisible by 18 ?
2
3
6
9
18
Key Concepts
Arithmetic
Divisibility Rule
Arithmetic Mean
Suggested Book | Source | Answer
Algebra by Gelfand
Math Kangaroo (Benjamin), 2020
6
Try with Hints
Let the number be $abc.$
By the given condition of arithmetic mean we get,
$$\frac{a+c}{2}=b$$.
Now from here can I conclude $a, c$ are of the same parity?
Given that the number is divisible by $18$
$\Rightarrow$ Given number must be divisible by both $2$ and $9$.
Apply divisibility rule of $9$ to guess the values of $a, b, c$.
Here the values of $3b$ are $9, 18, 27$.
$\Rightarrow$ the values of $2b$ are $6, 12, 18$.
Now guess the values of $a+c$?
And then find the possible pair of $(a, c)$?
The possible values of $(a, c)$ are $(2,4)$, $(4,2)$, $(6,0)$, $(4,8)$, $(6,6)$, $(8,4)$.
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,
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.
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.
Partition Numbers and a code to generate one in Python
Author: Kazi Abu Rousan
The pure mathematician, like the musician, is a free creator of his world of ordered beauty.
Bertrand Russell
Today we will be discussing one of the most fascinating idea of number theory, which is very simple to understand but very complex to get into. Today we will see how to find the Partition Number of any positive integer $n$.
Like every blog, our main focus will be to write a program to find the partition using python. But today we will use a very special thing, we will be usingMath Inspector - A visual programming environment. It uses normal python code, but it can show you visual (block representation) of the code using something called Node Editor. Here is a video to show it's feature.
Beautiful isn't it? Let's start our discussion.
What are Partition Numbers?
In number theory, aPartition of a positive integer $n$, also called an Integer Partition, is a way of writing $n$ as a sum of positive integers (two sums that differ only in the order of their summands are considered the same partition, i.e., $2+4 = 4+ 2$). The partition number of $n$ is written as $p(n)$
As an example let's take the number $5$. It's partitions are;
Hence, $p(5) = 7$. Easy right?, Let's see partitions of all numbers from $0$ to $6$.
Note: The partition number of $0$ is taken as $1$.
Partition of numbers from $0$ to $6$.
See how easy it is not understand the meaning of this and you can very easily find the partitions of small numbers by hand. But what about big numbers?, like $p(200)$?
Finding the Partition Number
There is no simple formula for Partition Number. We normally use recursion but if you want just a formula which generate partition number of any integer $n$, then you have to use this horrifying formula:
Scary!!!-- Try using this to find $p(2)$
Just looking at this can give you nightmare. So, are there any other method?, well yes.
Although, there are not any closed form expression for the partition function up until now, but it has both asymptotic expansions(Ramanujan's work) that accurately approximate it and recurrence relations(euler's work) by which it can be calculated exactly.
Generating Function
One method can be to use a generating function. In simple terms we want a polynomial whose coefficient of $x^n$ will give us $p(n)$. It is actually quite easy to find the generating function.
Each of these $(1+x^k+x^{2k}+\cdots+x^{rk}+\cdots)$ are called sub-series.
We can use this to find the partition number of any $n$. Let's see an example for $n=7$. There are 2 simple steps.
First write the polynomial such that each sub-series's maximum power is smaller or equals to $n$. As an example, if $n=7$, then the polynomial is $(1+x+x^2+x^3+x^4+x^5+x^6+x^7)(1+x^2+x^4+x^6)(1+x^3+x^6)(1+x^4)(1+x^5)(1+x^6)(1+x^7)$.
Now, we simplify this and find coefficient of $x^n$. In this process we find the partition numbers for all $r<n$.
So, for our example, we can just expand the polynomial given in point-1. You can do that by hand. But I have used sympy library.
The coefficients of $x^k$ gives $p(k)$ correctly up to $k = 7$. So, from this $p(7) = 15$, $p(6)=11$ and so on. But for $n>7$, the coefficients will be less than $p(n)$, as an example $p(8)=22$ but here the coefficient is $18$. To calculate $p(8)$, we need to take sub-series with power $8$ or less.
Although this method is nice, it is quite lengthy. But this method can be modified to generate a recurrence relation.
Euler's Pentagonal Number Theorem
Euler's Pentagonal Theorem gives us a relation to find the polynomial of the product of sub-series. The relation is:
The numbers $0, 1, 2, 5, 7, 12, 15, 22, 26, 35, 40,\cdots $ , are called pentagonal numbers. We generate these numbers by $\frac{k(3k+1)}{2}$ and $\frac{k(3k-1)}{2}$.
Let's try to find $p(7)$, using this.
Using this simple algorithm, we can write a code to get partition number.
def par(n):
summ = 0
if n == 0 or n == 1:
result = 1
else:
for k in range(1,n+1):
d1 = n - int((k*(3*k-1))/2)
d2 = n - int((k*(3*k+1))/2)
sign = pow(-1,k+1)
summ = summ + sign*(par(d1) + par(d2))
result = summ
return result
This is the code to generate partition number. This is not that efficient as it uses recurrence. For big numbers it will take huge amount of time. In math-inspector, we can see it's block diagram.
Here the par block represent the function par(n). Whenever i creates a variable $n1=6$ or $n3=10$, it creates a circle. To apply par on $n3$, i just need to connect their nodes. And to show the output, add the other node to output node.
So, we have seen this simple function. Now, let's define one using the euler's formula but in a different manner. To understand the used algorithm watch this: Explanation
def partition(n):
odd_pos = []; even_pos= []; pos_d = []
for i in range(1,n+1):
even_pos.append(i)
odd_pos.append(2*i+1)
m = 0; k = 0
for i in range(n-1):
if i % 2 == 0:
pos_d.append(even_pos[m])
m += 1
else:
pos_d.append(odd_pos[k])
k += 1
initial = 1; pos_index = [initial]; count = 1
for i in pos_d:
d = initial + i
pos_index.append(d)
initial = d
count += 1
if count > n:
break
sign = []
for i in range(n):
if i % 4 == 2 or i % 4 == 3:
sign.append(-1)
else:
sign.append(1)
pos_sign = []; k = 0
for i in range(1,n+1):
if i in pos_index:
ps = (i,sign[k])
k = k + 1
pos_sign.append(ps)
else:
pos_sign.append(0)
if len(pos_sign) != n:
print("Error in position and sign list.")
partition = [1]
f_pos = []
for i in range(n):
if pos_sign[i]:
f_pos.append(pos_sign[i])
partition.append(sum(partition[-p]*s for p,s in f_pos))
return partition
This is the code. This is very efficient. Let's try running this function.
Note: This function returns a list which contains all $p(n)$ in the range $0$ to $n$.
As you can see in the program, In[3] gives a list $[p(0),p(1),p(2),p(3),p(4),p(5)]$. Hence, to get the $p(n)$ using this function, just add $[-1]$ as it gives the last element of the list.
We can use a simple program to plot the graph.
import matplotlib.pyplot as plt
n = 5
x_vals = [i for i in range(n+1)]
y_vals = partition(n)
plt.grid(color='purple',linestyle='--')
plt.ylabel("Partition Number")
plt.xlabel("Numbers")
plt.step(x_vals,y_vals,c="Black")
plt.savefig("Parti_5.png",bbox_inches = 'tight',dpi = 300)
plt.show()
Output is given below. The output is a step function as it should be.
This is all for today. I hope you have learnt something new. If you find it useful, then share.
Best algorithm to calculate Pi - Part1
Author: Kazi Abu Rousan
$\pi$ is not just a collection of random digits. $\pi$ is a journey; an experience; unless you try to see the natural poetry that exists in $\pi$, you will find it very difficult to learn.
Today we will see a python code to find the value of $\pi $ up to $1,00,000$ within $3$ to $4$ second. We will be using Chudnovsky Algorithm, which is one of the fastest method to calculate the value of $\pi $. Using this in 14th August, 2021 $62.8$ trillion digits of $\pi $ was calculated. Can you imagine this?
This is based on Ramanujan's $\pi $ formula and was discovered in $1988$. Let's see the formula and how we are going to use that.
Let's just take the first term of this series and see what it gives us.
Just the first term is this much accurate. Just thinking about it surprises me.
So, how are we going to write the code?, well for this blog, we are directly going to use above expression. In some later blog, we will see how to make this much more efficient. We are doing so, to show you guys how powerful this method is.
Let's Code
Let's start our coding. Note one thing. Normally, when we perform this sort of algorithm, mostly the error comes from the fractional part. To reduce this error, we have to increase the precision of our calculation. For this we will be using a special python library.
There are many libraries which can help us in this. Some of them are;
Decimal
mpmath
gmpy2
Our good old math library cannot do that as it mostly returns IEEE-$754$ $64$-bit result, which is roughly $17$ digits only.
Here we will be using Decimal library.
Let's now begin our code:
import math as mp
from decimal import *
def pi_chudn(n):
getcontext().prec = n+50
k=0
pi_chud = 0
while k<n:
pi_chud+=(((Decimal(-1))**k ) * (Decimal(mp.factorial(6*k)))*(13591409 + 545140134*k))/Decimal((mp.factorial(3*k)*((mp.factorial(k))**3)*(640320**((3*k)+(Decimal(1.5))))))
k+=1
pi_chud = (Decimal(pi_chud) * 12)
pi_chud = (Decimal(pi_chud**(-1)))
return int(pi_chud*10**n)
exact_pi_val = str(31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989)
for n in range(1,1000):
print(int(exact_pi_val[:n+1]))
print(pi_chudn(n))
is_true = (pi_chudn(n) == int(exact_pi_val[:n+1]))
print("for n = ",n, " It is ",is_true)
if is_true == False:
break
This have run this program up to $413$ terms of $\pi $ and belief we, each and every digit was correct (most chudnovsky's programs you will find in internet gives wrong value after $14-15$ digit).
The string exact_pi_val contains $1001$ correct digit of $\pi $. So, The program will itself check if the calculated $\pi $ value is right or wrong up to $1000$ digit.
Although it's slow. To calculate $400$ digits of $\pi $, it needs $4.177294731140137$ sec.
We can plot the number of digits and calculation time.
This is all for today. I have you have learnt something new.