Skip to content

RahulSahOfficial/AncIndMatAst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

┬а

History

4 Commits
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а
┬а

Repository files navigation

Python Module for Ancient Indian Mathematics and Astronomy

  • 1. Aryabhata Cryptographic Calculator
    1. Calculate values from cryptographic words.
    2. Generate cryptographic words from numbers.
  • 2. Square Root When the Smaller Square Root is Known (Using Bodhaayana Approximation Method)
  • 3. Square Root (Bhaskara Method)
  • 4. Cube Root (Bhaskara Method)
  • 5. Solar Eclipse Calculator (Improved Siddhantic Procedure)
  • 6. Lunar Eclipse Calculator (Improved Siddhantic Procedure)

Module Link

Python Module for Ancient Indian Mathematics and Astronomy AncIndMatAst

Installation

pip install AncIndMatAst

Aryabhata Cryptographic Calculator

Aryabhata

Shlok
рд╡рд░реНрдЧрд╛рддреНрд░рд╛рдгрд┐ рд╡рд░реНрдЧреЗрд╜рд╡рд░реНрдЧреЗрд╜рд╡рд░реНрдЧрд╛рддрд╛рд░рд╛рдгреА рдХрд╛ рдореМ рдпрдГ ред
рдЦрджреНрд╡рд┐рдирд╡рдХреЗ рд╕реНрд╡рд░рд╛ рдирд╡ рд╡рд░реНрдЧреЗрд╜рд╡рд░реНрдЧреЗ рдирд╡рд╛рдиреНрддреНрдпрд╡рд░реНрдЧреЗ рд╡рд╛ рее
Table 1

Varg Consonants From рдХреН to рдореН denote from 1 to 25

рд╡рд░реНрдЧ: рдХ рдЦ рдЧ рдШреН рдЩреН рдЪреН рдЫреН рдЬреН рдЭреН рдЮреН рдЯреН рдареН рдбреН
рд╡реНрдпрдЮреНрдЬрди 1 2 3 4 5 6 7 8 9 10 11 12 13
рдвреН рдгреН рддреН рдереН рджреН рдзреН рдиреН рдкреН рдлреН рдмреН рднреН рдореН
14 15 16 17 18 19 20 21 22 23 24 25
Table 2

Awarg consonants from рдпреН to рд╣реН denote from 3 to 10

рдЕрд╡рд░реНрдЧрдГ рдпреН рд░реН рд▓реН рд╡реН рд╢реН рд╖ рд╕ рд╣
рд╡реНрдпрдЮреНрдЬрди 3 4 5 6 7 8 9 10
Table 3

Vowels from рдЕ to рдФ denote place-values from 100 to 1017

рд╕реНрд╡рд░рдГ рдЕ рдЗ рдЙ рдЛ рд▓реГ рдП рдР рдУ рдФ
рд╡рд░реНрдЧ: 10^0^ 10^2^ 10^4^ 10^6^ 10^8^ 10^10^ 10^12^ 10^14^ 10^16^
рдЕрд╡рд░реНрдЧрдГ 10^1^ 10^3^ 10^5^ 10^7^ 10^9^ 10^11^ 10^13^ 10^15^ 10^17^

рдвреБрд╡рд┐рдШреНрд╡ is the Aryabhatiya Alphabetical Numeral for the number of revolutions of Saturn in 43,20,000 years, and it is 1,46,564.

Explanation

рдвреБрдЩреНрд╡рд┐рдзреНрд╡ = ( рдв рдЙ ) + (рдЩреН рдЗ) + (рд╡реН рдЗ) + (рдШреН рдЕ) + (рд╡реН рдЕ)

= (14├Ч10^4^ ) + (5├Ч10^2^) + (6 ├Ч10^3^) + (4 x 1 ) + (6 x 10 ) =1,46,564.


Decode

Code
from AncIndMatAst import AC
word="рдЬрд╖рдмрд┐рдЦреБрдЫреГ"
value=AC.decode(word)
print(f"Value of {word} = {value}")
Output
Value of рдЬрд╖рдмрд┐рдЦреБрдЫреГ = 7022388

Encode

Code
from AncIndMatAst import AC
data=AC.encode(364224)
print(data.get("sabd"))
print(data.get("length"))
print(data.get("allSabd"))
Output
рднрдЦрд┐рд░рд┐рдЪреБрдпреБ
120
['рднрдЦрд┐рд░рд┐рдЪреБрдпреБ', 'рднрдЦрд┐рд░рд┐рдпреБрдЪреБ', 'рднрдЦрд┐рдЪреБрд░рд┐рдпреБ', 'рднрдЦрд┐рдЪреБрдпреБрд░рд┐', 'рднрдЦрд┐рдпреБрд░рд┐рдЪреБ', 'рднрдЦрд┐рдпреБрдЪреБрд░рд┐', 'рднрд░рд┐рдЦрд┐рдЪреБрдпреБ', 'рднрд░рд┐рдЦрд┐рдпреБрдЪреБ', 'рднрд░рд┐рдЪреБрдЦрд┐рдпреБ', 'рднрд░рд┐рдЪреБрдпреБрдЦрд┐', 'рднрд░рд┐рдпреБрдЦрд┐рдЪреБ', 'рднрд░рд┐рдпреБрдЪреБрдЦрд┐', 'рднрдЪреБрдЦрд┐рд░рд┐рдпреБ', 'рднрдЪреБрдЦрд┐рдпреБрд░рд┐', 'рднрдЪреБрд░рд┐рдЦрд┐рдпреБ', 'рднрдЪреБрд░рд┐рдпреБрдЦрд┐', 'рднрдЪреБрдпреБрдЦрд┐рд░рд┐', 'рднрдЪреБрдпреБрд░рд┐рдЦрд┐', 'рднрдпреБрдЦрд┐рд░рд┐рдЪреБ', 'рднрдпреБрдЦрд┐рдЪреБрд░рд┐', 'рднрдпреБрд░рд┐рдЦрд┐рдЪреБ', 'рднрдпреБрд░рд┐рдЪреБрдЦрд┐', 'рднрдпреБрдЪреБрдЦрд┐рд░рд┐', 'рднрдпреБрдЪреБрд░рд┐рдЦрд┐', 'рдЦрд┐рднрд░рд┐рдЪреБрдпреБ', 'рдЦрд┐рднрд░рд┐рдпреБрдЪреБ', 'рдЦрд┐рднрдЪреБрд░рд┐рдпреБ', 'рдЦрд┐рднрдЪреБрдпреБрд░рд┐', 'рдЦрд┐рднрдпреБрд░рд┐рдЪреБ', 'рдЦрд┐рднрдпреБрдЪреБрд░рд┐', 'рдЦрд┐рд░рд┐рднрдЪреБрдпреБ', 'рдЦрд┐рд░рд┐рднрдпреБрдЪреБ', 'рдЦрд┐рд░рд┐рдЪреБрднрдпреБ', 'рдЦрд┐рд░рд┐рдЪреБрдпреБрдн', 'рдЦрд┐рд░рд┐рдпреБрднрдЪреБ', 'рдЦрд┐рд░рд┐рдпреБрдЪреБрдн', 'рдЦрд┐рдЪреБрднрд░рд┐рдпреБ', 'рдЦрд┐рдЪреБрднрдпреБрд░рд┐', 'рдЦрд┐рдЪреБрд░рд┐рднрдпреБ', 'рдЦрд┐рдЪреБрд░рд┐рдпреБрдн', 'рдЦрд┐рдЪреБрдпреБрднрд░рд┐', 'рдЦрд┐рдЪреБрдпреБрд░рд┐рдн', 'рдЦрд┐рдпреБрднрд░рд┐рдЪреБ', 'рдЦрд┐рдпреБрднрдЪреБрд░рд┐', 'рдЦрд┐рдпреБрд░рд┐рднрдЪреБ', 'рдЦрд┐рдпреБрд░рд┐рдЪреБрдн', 'рдЦрд┐рдпреБрдЪреБрднрд░рд┐', 'рдЦрд┐рдпреБрдЪреБрд░рд┐рдн', 'рд░рд┐рднрдЦрд┐рдЪреБрдпреБ', 'рд░рд┐рднрдЦрд┐рдпреБрдЪреБ', 'рд░рд┐рднрдЪреБрдЦрд┐рдпреБ', 'рд░рд┐рднрдЪреБрдпреБрдЦрд┐', 'рд░рд┐рднрдпреБрдЦрд┐рдЪреБ', 'рд░рд┐рднрдпреБрдЪреБрдЦрд┐', 'рд░рд┐рдЦрд┐рднрдЪреБрдпреБ', 'рд░рд┐рдЦрд┐рднрдпреБрдЪреБ', 'рд░рд┐рдЦрд┐рдЪреБрднрдпреБ', 'рд░рд┐рдЦрд┐рдЪреБрдпреБрдн', 'рд░рд┐рдЦрд┐рдпреБрднрдЪреБ', 'рд░рд┐рдЦрд┐рдпреБрдЪреБрдн', 'рд░рд┐рдЪреБрднрдЦрд┐рдпреБ', 'рд░рд┐рдЪреБрднрдпреБрдЦрд┐', 'рд░рд┐рдЪреБрдЦрд┐рднрдпреБ', 'рд░рд┐рдЪреБрдЦрд┐рдпреБрдн', 'рд░рд┐рдЪреБрдпреБрднрдЦрд┐', 'рд░рд┐рдЪреБрдпреБрдЦрд┐рдн', 'рд░рд┐рдпреБрднрдЦрд┐рдЪреБ', 'рд░рд┐рдпреБрднрдЪреБрдЦрд┐', 'рд░рд┐рдпреБрдЦрд┐рднрдЪреБ', 'рд░рд┐рдпреБрдЦрд┐рдЪреБрдн', 'рд░рд┐рдпреБрдЪреБрднрдЦрд┐', 'рд░рд┐рдпреБрдЪреБрдЦрд┐рдн', 'рдЪреБрднрдЦрд┐рд░рд┐рдпреБ', 'рдЪреБрднрдЦрд┐рдпреБрд░рд┐', 'рдЪреБрднрд░рд┐рдЦрд┐рдпреБ', 'рдЪреБрднрд░рд┐рдпреБрдЦрд┐', 'рдЪреБрднрдпреБрдЦрд┐рд░рд┐', 'рдЪреБрднрдпреБрд░рд┐рдЦрд┐', 'рдЪреБрдЦрд┐рднрд░рд┐рдпреБ', 'рдЪреБрдЦрд┐рднрдпреБрд░рд┐', 'рдЪреБрдЦрд┐рд░рд┐рднрдпреБ', 'рдЪреБрдЦрд┐рд░рд┐рдпреБрдн', 'рдЪреБрдЦрд┐рдпреБрднрд░рд┐', 'рдЪреБрдЦрд┐рдпреБрд░рд┐рдн', 'рдЪреБрд░рд┐рднрдЦрд┐рдпреБ', 'рдЪреБрд░рд┐рднрдпреБрдЦрд┐', 'рдЪреБрд░рд┐рдЦрд┐рднрдпреБ', 'рдЪреБрд░рд┐рдЦрд┐рдпреБрдн', 'рдЪреБрд░рд┐рдпреБрднрдЦрд┐', 'рдЪреБрд░рд┐рдпреБрдЦрд┐рдн', 'рдЪреБрдпреБрднрдЦрд┐рд░рд┐', 'рдЪреБрдпреБрднрд░рд┐рдЦрд┐', 'рдЪреБрдпреБрдЦрд┐рднрд░рд┐', 'рдЪреБрдпреБрдЦрд┐рд░рд┐рдн', 'рдЪреБрдпреБрд░рд┐рднрдЦрд┐', 'рдЪреБрдпреБрд░рд┐рдЦрд┐рдн', 'рдпреБрднрдЦрд┐рд░рд┐рдЪреБ', 'рдпреБрднрдЦрд┐рдЪреБрд░рд┐', 'рдпреБрднрд░рд┐рдЦрд┐рдЪреБ', 'рдпреБрднрд░рд┐рдЪреБрдЦрд┐', 'рдпреБрднрдЪреБрдЦрд┐рд░рд┐', 'рдпреБрднрдЪреБрд░рд┐рдЦрд┐', 'рдпреБрдЦрд┐рднрд░рд┐рдЪреБ', 'рдпреБрдЦрд┐рднрдЪреБрд░рд┐', 'рдпреБрдЦрд┐рд░рд┐рднрдЪреБ', 'рдпреБрдЦрд┐рд░рд┐рдЪреБрдн', 'рдпреБрдЦрд┐рдЪреБрднрд░рд┐', 'рдпреБрдЦрд┐рдЪреБрд░рд┐рдн', 'рдпреБрд░рд┐рднрдЦрд┐рдЪреБ', 'рдпреБрд░рд┐рднрдЪреБрдЦрд┐', 'рдпреБрд░рд┐рдЦрд┐рднрдЪреБ', 'рдпреБрд░рд┐рдЦрд┐рдЪреБрдн', 'рдпреБрд░рд┐рдЪреБрднрдЦрд┐', 'рдпреБрд░рд┐рдЪреБрдЦрд┐рдн', 'рдпреБрдЪреБрднрдЦрд┐рд░рд┐', 'рдпреБрдЪреБрднрд░рд┐рдЦрд┐', 'рдпреБрдЪреБрдЦрд┐рднрд░рд┐', 'рдпреБрдЪреБрдЦрд┐рд░рд┐рдн', 'рдпреБрдЪреБрд░рд┐рднрдЦрд┐', 'рдпреБрдЪреБрд░рд┐рдЦрд┐рдн']
Value of рдЬрд╖рдмрд┐рдЦреБрдЫреГ = 7022388

Bodhaayana Square Root (Approximation Method)

Bodhaayana

Shlok
рдкреНрд░рдорд╛рдгрдВ рддреГрддреНрддреАрдпреЗрди рд╡рд░реНрдзрдпреЗрддреН рддрдЪреНрдЪ рдЪрддреБрд░реНрдереЗрдирд╛рддреНрдо рдЪрддреБрд╕реНрддреНрд░рд┐рдореНрд╢реЛрдиреЗрди рд╕рд╡рд┐рд╢реЗрд╖:
Explanation

The measure is to be increased by its third and this (third) again by its own fourth less the thirty fourth part (of that fourth); this is (the value of) the diagonal of a square (whole side is the measure).

Code
from AncIndMatAst import BA
num=200
sq=BA.squareRoot(num)
print("Square Root By Bodhaayana Approximation Method = ",sq)
Output
Square Root By Bodhaayana Approximation Method =  14.1421356237469

Roots (Bhaskara Method)

Bhaskara

Square Root

Shlok
Tyaktvaamtyaat Vishamaat kritim
    Dvigunayenmulam same taddhrite 
Tyaktvaa labdhakritim tadaadya vishamaat 
    Labdham dvinighnam nyaset

Panktyaam panktihrite samenyavishamaat 
    Tyaktvaptavargam phalam 
Panktyaam taddvigumam nyasediti muhuh 
    Pankterdalam syaatpadam
Explanation
  1. Start observing the given number from RHS
  2. Put dots on the digits appearing at all the odd places (that is, 1, 3, 5, 7 etc. places) starting from RHS
  3. Start processing the given number from LHS.
  4. Remember that the terms of (a+b)=a┬▓+2ab+b┬▓ formula will be used to find the square root
  5. Select the leftmost set of digits having the dot and call it X1.
  6. Identify a value of a (where a=1,2,3,4,5,6,7,8,9) which is the biggest value that can be subtracted from XI.
  7. Keep the corresponding value of 'a' in the result location.
  8. Subtract that a from XI and call the resultant value X2.
  9. Append the next digit of the given number to X2 for continuing the processing. Call it as X3.
  10. Divide X3 by 2*a. Identify the quotient as 'b' (Maximum value of b can be 9).
  11. Subtract 2ab from X3 and call the resultant value X4
  12. Append the next digit of the given number to X4 for continuing the processing. Call it as X5.
  13. Subtract b┬│ from X5 and call the resultant value X6,
  14. If any of the above two subtractions give negative value, reduce the value of bby one and revert back to step 11.
  15. Concatenate the values of 'a' and 'b'. Call it as 'ab'.
  16. This value is the square root of the group of digits processed so far.
  17. If some more digits are still pending for processing in the given number, take the present value of ab as new 'a'. Take the value of X6 as X2. Repeat the process from step 9.
Code
from AncIndMatAst import BM
num=144
sq=BM.squareRoot(num)
print("Square Root By Bhaskara Method = ",sq)
Output
Square Root By Bhaskara Method =  12

Cube Root

Shlok
Adyam ghanasthanamathaaghane dve 
    Punastathantyaat ghanto visodhya
Ghanam prithakstham padamasya krityan
    Trighnyaa tadaadyam vibhajet phalam tu

Panktyaam nyaset tatkritimantyanighneem
    Trighneem tyajet tatprathamaat phalasya
Ghanam tadaadyaat ghanamulamevam
Panktirbhavedevamatah punasca

Explanation
  1. Start observing the given number from RHS
  2. Put dots on the digits appearing at 1st , 4th , 7th , 9th etc. places starting from RHS
  3. Start processing the given number from LHS
  4. Remember that the terms of (a + b)3 = a ^ 3 + 3a ^ 2 * b + 3a * b ^ 2 + b3 formula will be used to find the cube root
  5. Select the leftmost set of digits having the dot and call it XI.
  6. Identify a value of a ^ 3 where a (1,2,3,4,5,6,7,8,9) which is the biggest value that can be subtracted from XI.
  7. keep the corresponding value of 'a' in the result location. 8. Subtract that a ^ 2 from X1 and call the resultant value X2.
  8. Append the next digit of the given number to X2 for continuing the processing. Call it as X3.
  9. Divide X3 by 3^ * a ^ 2 Identify the quotient as "b.(Maximum value of b can be 9).
  10. Subtract 3 a^ 2 b from X3 and call the resultant value X4
  11. Append the next digit of the given number to X4 for continuing the processing. Call it as XS.
  12. Subtract 3 a b from X5 and call the resultant value X6.
  13. Append the next digit of the given number to X6 for continuing the processing. Call it as X7.
  14. Subtract b' from X7 and call the resultant value X8.
  15. If any of the above three subtractions give negative value, reduce the value of b by one and revert back to step 11.
  16. Concatenate the values of "a" and "b". Call it as 'ab'.
  17. This value will be the cube root of the group of digits processed so far.
  18. If some more digits are still pending for processing in the given number, take the present value of ab as new 'a' Take the value of X8 as X2. Repeat the process from step 9
Illustration
To Find the cube root of 9261:
1. Start observing the given number from RHS
2. Put dots on the digits appearing at 1st and 4th places starting from RHS, viz., or 1 and 9.
3. Start processing the given number from LHS
4. Remember that the terms of (a + b)^3 = a ^ 3 + 3a ^ 2 * b + 3a * b ^ 2 + b ^ 1 formula will be used in find the cube root
5. Select the leftmost set of digits having the dot and call it XI.
6. X1=9
7. Identity a value of a ^ 3 * (- 8) which is the biggest value that can be subtracted from XI.
8. keep the corresponding value of ^ * a' (=2) in the result location.
9 Subtract that a from X1 and call the resultant value X2.
10. X2 = 9 - 8 = 1
11. Append the next digit of the given number to X2 for continuing the processing Call it as X3.
12. X3 = 12
13. Divide X3 by 3*a ^ 2 (=12)
14. Identify the quotient as "b".
15. b=1
16. Subtract 3 ab from X3 and call the resultant value X4
17. X4 = 12 - 12 = 0
18. Append the next digit of the given number to X4 for continuing the processing Cal it as X5.
19. X5 = 06
20. Subtract 3^ * a^ * b ^ 2 from X5 and call the resultant value X6.
21. X6=06-6-0
22. Append the next digit of the given minber to X6 for continuing the processing. Call it us XT.
23. X7=01
24. Subtract b' from X7 and call the resultant value X8
25. X8=01-1-0
26. Concatenate the values of 'a' and 'b. Call it as ab 27, ab21
28. This value 21 is the cube root of the given number 9261
Result = 21
Code
from AncIndMatAst import BM
num=175616
sq=BM.cubeRoot(num)
print("Cube Root By Bhaskara Method = ",sq)
Output
Cube Root By Bhaskara Method =  56

Siddhantic Procedure for Lunar and Solar Eclipse

Siddhantic

Lunar Eclipse

Lunar Eclipse

Code
from AncIndMatAst import Eclipse
date = (2006, 10, 7)
time = (24,12,0)
trueMoon=(321,3,27)
trueRahu=(331,21,11)
Eclipse.LunarEclipse(date,time,trueMoon,trueRahu)
Output
Lunar Eclipse Detail of 07 October 2006
Eclipse Type :  Partial
Magnitude of Eclipse :  0.18
Timings of Eclipse :
Beginnig of Eclipse :  23h 35m 23s
Middle of Eclipse :  24h 21m 24s
End of Eclipse :  25h 7m 25s

Solar Eclipse

Solar Eclipse

Code
from AncIndMatAst import Eclipse
date = (2008, 8, 1)
iONMoon=(15,42,0)
trueMoon=(105,33,0)
trueRahu=(294,37,26)
Eclipse.SolarEclipse(date,iONMoon,trueMoon,trueRahu)
Output
Solar Eclipse Detail of 01 August 2008
Eclipse Type :  Total
Magnitude of Eclipse :  1.34
Timings of Solar Eclipse :
Beginnig of Eclipse :  13h 31m 13s
Beginnig of Totality :  14h 45m 14s
Middle of Eclipse :  15h 50m 15s
End of Totality :  16h 55m 16s
End of Eclipse :  18h 8m 18s