So a while back I had stumbled upon the Prime number formula:
\(p_n = 1 + \sum_{i=1}^{2^n} {\lfloor (\tfrac{n}{\sum_{j=1}^i {\lfloor (\cos {\tfrac{(j-1)! + 1}{j}\pi})^2 \rfloor}})^{\tfrac{1}{n}} \rfloor}\)
but that was a long time ago. Anyways, here is a function that I stumbled upon:
Let \(s(x)\) denote the signum function
and let
\(f(x) = s(\log{(\sqrt{2}\cos{(\arctan{|x|})})}) * (s(\log{(\sqrt{2}\cos{(\arctan{|x|})})}) + 1) \)
\(g(x) = \tfrac{\sum_{n = 1}^{\infin} {n * f(x-n)} - 2}{4}\)
Then can you identify what kind of function \(g(x)\) could be?
So, \(g(x)\) is actually my own Greatest Integer function!
So I just wanted to create a function that would take an integer as input and output whether that integer is divisible by say, 5.
But I knew it would be very easy to do so if I could just use the Greatest integer function or straight up used the modulo operator.
So I thought, to make things fun, why not invent my own Greatest integer function, using 4 basic operators and fundamental functions like sine, cosine, logarithm, etc.
I was also inspired by the Prime number formula, so I thought to use some kind of summation to evaluate the integer part of the input.
So I want to create a function that works like some sort of fraction detector.
I mean I could just use some split functions but that would be so much easy, I wanna create a single function without specifying any condition.
Suppose we have a non fraction as an input (x),
since we have:
\(|x| \ge 1\),
\(\implies (\arctan |x|) \ge \tfrac{\pi}{4}\)
\(\implies \cos {(\arctan |x|)} \le \tfrac{1}{\sqrt{2}}\)
\(\implies \sqrt{2} \cos {(\arctan |x|)} \le 1\)
\(\implies \log{(\sqrt{2} \cos {(\arctan |x|)})} \le 0\)
If \(s(x)\) denotes the signum function, then,
\(\implies s(\log{(\sqrt{2} \cos {(\arctan |x|)})}) = -1, 0\)
and so for all other inputs, or, for \(|x| \lt 1\), the above expression would evaluate to \(1\)
Denote by \(\alpha = s(\log{(\sqrt{2} \cos {(\arctan |x|)})})\), then \(\alpha * (\alpha + 1)\) would be 2 when \(|x| \lt 1\) and would be 0 when \(|x| \ge 1\)
So let
\(f(x) = s(\log{(\sqrt{2} \cos {(\arctan |x|)})}) * (s(\log{(\sqrt{2} \cos {(\arctan |x|)})}) + 1)\)
Then f(x) returns 0 when \(|x| \ge 1\) and it returns 2 when \(|x| \lt 1\),
So now, say we have to evaluate the integer part of \(x = 3.93\), then we follow the following steps:
and so on...
Now consider the following summation:
\(\sum_{n = 1}^{\infin} {n * f(x-n)}\)
this sum returns \(2 * I + 2 * (I+1)\), where \(I\) is the integer part of \(x\).
So now we subtract \(2\) from this sum and divide it by \(4\) to get \(I\).
Thus we have:
\(g(x) = \tfrac{\sum_{n = 1}^{\infin} {n * f(x-n)} - 2}{4}\)
and \(g(x)\) denotes the greatest integer function of \(x\)
So this is basically my custom made Greatest Integer function.
Now to finish what I have started,
Let
\(r_k(x) = x - k*g(\tfrac{x}{k})\)
then \(r_k(x)\) basically denotes the remainder when \(x\) is divided by \(k\).
and
\(d_k(x) = 1 - s(\log_k{(1 + r_k(x))})\)
Then \(d_k(x)\) returns 1 when \(x\) is divisible by \(k\) and 0 when it is not.
Now there may be some issues with domain of \(f,g,r_k,d_k\), I have made the functions to work with positive integers, and haven't verified for larger domain, but maybe I would verify them or make some changes to the functions for them to hold in higher domains!
But right now I am satisfied with my work, and feel great to discover or maybe invent my own Greatest Integer function, a fraction detecter function and a divisibility function!
This is basically using Mathematics as a programming language, I mean instead of using split functions, I worked with a combination of functions to essentially make it work like an if-else statement like in a programming language.
Overall this was a really fun exercise for me, and maybe I'll work on similar problems in the future!
anonymous
The greatest greatest integer function to ever function