This week I updated my PR#11277 to find the period of a general function.
Periodicity Link to heading
In the past few weeks, I dedicated a lot of my time reading about the property of periodicity of a function. Earlier, I had implemented a trivial(and restricted) functionality for this task. This motivated me to study this topic as I planned to generalise the function.
Here are my notes on periodicity which were the literature reference for the development of the method:
Note that
2π
is a period ofsin(x)
. Butsin(x)
has many other periods, such as4π
,6π
, and so on. However,sin(x)
has no (positive) period shorter than2π
.If
p
is a period off(x)
, andH
is any function, thenp
is a period ofH(f(x))
.For sums and products, the general situation is complicated.
Let
p
be a period off(x)
and letq
be a period ofg(x)
. Suppose that there are positive integersa
andb
such thatap=bq=r
.
Thenr
is a period off(x)+g(x)
, and also off(x)g(x)
.
However, the point to note here is thatr
need not be the shortest period off(x)+g(x)
orf(x)g(x)
.For example: The shortest period of
sin(x)
is2π
, while the shortest period of(sinx)**2
isπ
.Another example: Let
f(x)=sin(x)
, andg(x)=−sin(x)
. Each function has smallest period2π
. But their sum is the0
-function, which has every positive numberp
as a period!If
p
andq
are periods off(x)
andg(x)
respectively, then any common multiple ofp
andq
is a period ofH(f(x),g(x))
for any functionH(u,v)
, in particular whenH
is addition, multiplication or division. However, it need not be the smallest period.The sum of two periodic functions need not be periodic.
For example: Let
f(x)=sin(x)+cos(2πx)
. The function is not periodic.
The problem is that1
and2π
are incommensurable. There do not exist positive integersa
andb
such that(a)(1)=(b)(2π)
.
Issues Link to heading
I am abstracting the details of implementation so as not to make the post even further boring.
During the period of development, I faced few issues and had a lot of queries to make.
The new implementation returns a value which might not be the fundamental period of the given function. The previous implementation, though limited, returned the fundamental period of the given function.
The ability to find the LCM of irrationals. We will be dealing with the iconic
π
(and its multiples) in many of our cases(as is evident from the example above). Currently, we donot have the functionality to find the LCM of irrational numbers. A method needs to be developed to handle this issue.Issue with automatic simplification while verifying the result.
After Thoughts
I am looking forward to addressing all these issues in tonight’s meeting. Apart from that, implementing this was a lot of fun. I got to learn about inheritance and abstraction while implementing instance methods for periodic functions.
Hopefully, all my effort doesn’t go in vain.
Till next time !