শ্লোক থেকে অ্যালগরিদম: সূর্যসিদ্ধান্তের বর্ণনামূলক নিয়মকে গণিতের সূত্রে রূপান্তর

সূর্যসিদ্ধান্তের শ্লোক ও বর্ণনামূলক নিয়মকে source-awareভাবে quantity, unit, algebra, numerical algorithm, C# এবং validation trace-এ রূপান্তরের পূর্ণ পদ্ধতি।

“শ্লোকে যা লেখা আছে, সেটাই সরাসরি code”—এই ধারণা আকর্ষণীয়, কিন্তু ঐতিহাসিক গাণিতিক গ্রন্থের ক্ষেত্রে নিরাপদ নয়। শ্লোক স্মরণযোগ্য সংক্ষিপ্ত ভাষায় একটি নিয়ম ধরে রাখে; executable algorithm বানাতে source context, technical vocabulary, implied operands, units, direction, epoch, remainder এবং rounding policy পুনর্গঠন করতে হয়।

সূর্যসিদ্ধান্তের শ্লোক কেন Pseudocode নয়?

শ্লোকের উদ্দেশ্য ছিল সংক্ষিপ্ততা, ছন্দ ও স্মরণযোগ্যতা। ফলে আধুনিক programmer যে বিষয়গুলো function signature-এ আশা করেন, সেগুলো প্রায়ই implicit:

  • input quantity আগের দুই বা তিন শ্লোকে সংজ্ঞায়িত;
  • একক পুনরায় বলা হয় না;
  • “multiply” বা “divide”-এর subject context থেকে ধরতে হয়;
  • পূর্ণ revolution বাদ দিয়ে remainder নেওয়া implicit হতে পারে;
  • direct ও retrograde motion-এর sign আলাদা শ্লোকে আসে;
  • sexagesimal output—rāśi, degree, kalā, vikalā—modern decimal degree নয়;
  • verse data, computational rule এবং cosmological explanation পাশাপাশি থাকে;
  • commentator বা translator কোনো missing computational bridge ব্যাখ্যা করতে পারেন।

অতএব শ্লোক থেকে code বানানোর সময় আমাদের কাজ “অনুবাদ” মাত্র নয়; একটি documented mathematical reconstruction। Reconstruction মানে ইচ্ছেমতো নতুন নিয়ম যোগ করা নয়—কোন অংশ পাঠে, কোন অংশ commentary-তে, কোন অংশ software engineering-এ এসেছে তা আলাদা রাখা।

এই Project-এর ছয়টি Source Layer

LayerউদাহরণভূমিকাLabel
S1: মূল/সম্পাদিত পাঠসংস্কৃত শ্লোক, chapter–verseপ্রাথমিক textual evidenceVERSE
S2: অনুবাদBurgess, Bāpū Deva ŚāstrīTechnical meaning-এর ভাষান্তরTRANSLATION
S3: CommentaryBurgess notes, traditional commentaryEllipsis, constants, historical interpretationCOMMENTARY
S4: Reference implementationYano–Fushimi pancanga3.14একটি executable interpretationREFERENCE_CODE
S5: Project implementationSuryaSiddhantaEngine.cs.NET port, types, precision, APIPROJECT_CODE
S6: Empirical fit1947+ Sankranti star-correction tablePrinted Panjika alignmentCALIBRATION

S4 code-এ কোনো constant থাকলেই সেটি S1 শ্লোকে আছে—এ দাবি করা যাবে না। আবার S6 correction ভালো modern match দিলেও সেটি ancient text-এর “lost formula” হয়ে যায় না। Publication-এ layer label রাখলে পাঠক মূল সূত্র ও প্রকল্পের adjustment আলাদা করতে পারেন।

শ্লোক থেকে Code: দশ ধাপের Workflow

  1. Edition, chapter, verse এবং variant নির্ধারণ;
  2. শ্লোকটি data, operation, definition না description—শ্রেণিবদ্ধ করা;
  3. সংখ্যা ও technical terms উদ্ধার;
  4. একক ও sexagesimal scale স্বাভাবিক করা;
  5. variables, inputs, outputs এবং valid domain লেখা;
  6. শব্দ-নিয়মকে algebraic equation-এ রূপান্তর;
  7. modulo, direction, interpolation ও rounding policy নির্ধারণ;
  8. exact/intermediate-preserving code লেখা;
  9. প্রতিটি intermediate value trace করা;
  10. textual, arithmetic ও regression validation করা।

ধাপ ১: Edition ও Verse Identity স্থির করা

একটি citation শুধু “Surya Siddhanta” হলে যথেষ্ট নয়। অন্তত লিখুন:

  • chapter ও verse range;
  • ব্যবহৃত Sanskrit edition/e-text;
  • translation edition এবং publication year;
  • variant reading থাকলে নির্বাচিত পাঠ;
  • verse numbering কোন edition অনুসরণ করে;
  • commentary-র বক্তব্য original verse থেকে আলাদা কি না।

Burgess-এর public-domain অনুবাদে Chapter I-এর বিষয় “Mean Motions of the Planets”; Chapter II “True Places of the Planets।” এই chapter separation-ই একটি গুরুত্বপূর্ণ design boundary: Chapter I থেকে পাওয়া mean place-কে সরাসরি final true longitude বলা যাবে না।

একটি Formula record-এর ন্যূনতম citation

Formula ID: SS-I-53-MEAN-PLACE
Text: Sūrya Siddhānta I.53
Sanskrit edition: ...
Translation: Burgess, 1860, Chapter I, verse 53
Commentary used: yes/no; exact note
Reference code: pancanga3.14 function/line
Project code: SuryaSiddhantaEngine.MeanLongitude()
Rule version: 1

ধাপ ২: শ্লোকটি কী ধরনের?

TypeকাজChapter I example
Definitionএকক বা ধারণা সংজ্ঞায়িতI.28: vikalā → kalā → degree → rāśi → revolution
Constant/dataRevolution বা cycle count দেয়I.29–34, I.37–39
AlgorithmOperands ও operation দেয়I.53: days × revolutions ÷ cycle-days
Direction ruleSign/orientation নির্ধারণI.54: node-এর reverse motion
Time adjustmentFractional day correctionI.67: nāḍī-ভিত্তিক adjustment
DescriptionConceptual/cosmological contextI.25, I.27-এর motion description

একটি algorithm verse একা যথেষ্ট নাও হতে পারে। I.53 বুঝতে I.28-এর units, I.29–34-এর revolutions এবং I.37-এর day count দরকার। তাই “source range” অনেক সময় single verse-এর চেয়ে বড়।

ধাপ ৩: শব্দে লুকানো সংখ্যা উদ্ধার

সংস্কৃত astronomical verse-এ সংখ্যা সরাসরি decimal digits-এ না এসে object-word বা bhūta-saṃkhyā পদ্ধতিতে প্রকাশিত হতে পারে। যেমন একটি পরিচিত বস্তু তার conventional count নির্দেশ করে। Compound-এর reading order, manuscript variant এবং editor-এর supplied numeral যাচাই না করে constant code করবেন না।

Chapter I.29–34-এ গ্রহের revolutions এবং I.37-এ cycle-day count verse-এর মধ্যে encoded। আধুনিক edition বা commentary প্রায়ই পাশে decoded integer দেয়। নিরাপদ process:

  1. compound শব্দ আলাদা করা;
  2. প্রতিটি number-word-এর conventional digit লেখা;
  3. reading order যাচাই;
  4. edition-এর printed number/table-এর সঙ্গে মিল;
  5. অন্য independent translation-এ cross-check;
  6. code constant-এর পাশে verse citation রাখা।

ধাপ ৪: একক স্বাভাবিকীকরণ

Chapter I.28 sexagesimal angular chain দেয়:

৬০ vikalā = ১ kalā

৬০ kalā = ১ bhāga বা degree

৩০ degree = ১ rāśi

১২ rāśi = ১ bhagaṇa বা revolution

Traditional unitModern representationInternal recommendation
Bhagaṇa১ turn = ৩৬০°Integer/fractional turns or normalized degree
Rāśi৩০°Index 0–11; display label separate
Bhāga১°Decimal/rational degree
Kalā১ arcminute1/60 degree
Vikalā১ arcsecond1/3600 degree
Nāḍī/Ghaṭīদিনের 1/60Duration; ২৪ modern minutes
Vināḍī/PalaNāḍī-এর 1/60২৪ modern seconds

Code-এ unit suffix দিন: longitudeDegrees, elapsedDays, timeNadis। শুধু x বা motion লিখলে degree/day, arcminute/day এবং revolution/cycle মিশে যায়।

ধাপ ৫: Variables, Domain ও Reference লিখুন

Mean-place rule-এর জন্য:

  • D: নির্বাচিত epoch থেকে elapsed terrestrial/civil days;
  • R: একই cycle-এ target-এর revolutions;
  • N: সেই cycle-এর terrestrial days;
  • Q: elapsed whole revolutions;
  • r: division remainder;
  • λ̄: normalized mean longitude।

R এবং N একই reference cycle-এর হতে হবে। Mahāyuga revolution count-এর সঙ্গে Kalpa day count সরাসরি মেশানো যাবে না—যদিও consistent scaling করলে ratio একই হতে পারে। Epoch definition-ও formula-র অংশ; D ভুল হলে arithmetic নিখুঁত হলেও longitude ভুল।

ধাপ ৬: বর্ণনামূলক Rule থেকে Algebra

Chapter I.53-এর operational অর্থ: elapsed days-কে target-এর revolution count দিয়ে গুণ করে cycle-day count দিয়ে ভাগ করলে elapsed mean revolutions এবং বর্তমান revolution-এর অংশ পাওয়া যায়।

T = D × R / N

Q = floor(T)

Fraction = T − Q

λ̄ = 360° × Fraction

Integer arithmetic-এ আরও স্পষ্ট:

P = D × R

Q = P div N

r = P mod N

λ̄ = r × 360° / N

Verse I.54 retrograde node-এর জন্য direction বদলায়। Direct result x হলে normalized reverse result:

λ̄node = Normalize(360° − x)

I.67 fractional day-এর জন্য daily motion-কে elapsed nāḍī/60 দিয়ে scale করে appropriate sign-এ midnight place-এর সঙ্গে যোগ/বিয়োগ করে। অর্থাৎ “date-এর planet” বললেই reference midnight, sunrise না noon—তা ঘোষণা করা জরুরি।

ধাপ ৭: Algebra থেকে Numerical Algorithm

Mathematical equation এক হলেও software-এ কয়েকটি policy দরকার:

  1. Overflow: D × R 64-bit ছাড়াতে পারে—BigInteger ব্যবহার;
  2. Euclidean remainder: negative historical D-এর remainder ০…N−১ করা;
  3. Precision: product/division-এর আগে floating-point conversion নয়;
  4. Normalization: longitude সর্বদা ০° ≤ λ < ৩৬০°;
  5. Rounding: classification full precision-এ; rounding শুধু display-এ;
  6. Epoch: D integer না fractional তা স্পষ্ট;
  7. Direction: retrograde constant sign/transform একবারই প্রয়োগ;
  8. Trace: product, quotient, remainder ও final degree সংরক্ষণ।

Worked Example: I.53 থেকে Mean Sun

এটি method demonstration—কোনো নির্দিষ্ট historical date-এর published Sun position নয়। ধরা যাক epoch-এর ১,০০০ terrestrial day পরে mean Sun চাই। Chapter I-এর traditional cycle values:

  • D = ১,০০০ days;
  • R = ৪,৩২০,০০০ solar revolutions per Mahāyuga;
  • N = ১,৫৭৭,৯১৭,৮২৮ terrestrial days per Mahāyuga।

প্রথমে integer product:

P = ১,০০০ × ৪,৩২০,০০০ = ৪,৩২০,০০০,০০০

তারপর division:

Q = ২ whole revolutions

r = ১,১৬৪,১৬৪,৩৪৪

বর্তমান revolution-এর angle:

λ̄ = ১,১৬৪,১৬৪,৩৪৪ × ৩৬০° ÷ ১,৫৭৭,৯১৭,৮২৮

λ̄ ≈ ২৬৫° ৩৬′ ০৯.৫৬″

এটি Dhanu ২৫° ৩৬′ ০৯.৫৬″ mean longitude। কিন্তু এখনো:

  • real calendar epoch/JD বসানো হয়নি;
  • fractional time-of-day adjustment করা হয়নি;
  • deśāntara correction নেই;
  • manda correction নেই;
  • Traditional Fit/Bīja নেই;
  • তাই এটি True Sun বা Saṅkrānti time নয়।

C#-এ Exact-first Mean-place Function

using System;
using System.Numerics;

public sealed class MeanPlaceTrace
{
    public BigInteger ElapsedDays { get; set; }
    public BigInteger RevolutionsPerCycle { get; set; }
    public BigInteger DaysPerCycle { get; set; }
    public BigInteger Product { get; set; }
    public BigInteger WholeRevolutions { get; set; }
    public BigInteger Remainder { get; set; }
    public double LongitudeDegrees { get; set; }
    public string FormulaId { get; set; }
}

public static MeanPlaceTrace MeanPlace(
    BigInteger elapsedDays,
    BigInteger revolutionsPerCycle,
    BigInteger daysPerCycle)
{
    if (daysPerCycle <= BigInteger.Zero)
        throw new ArgumentOutOfRangeException("daysPerCycle");

    BigInteger product = elapsedDays * revolutionsPerCycle;

    // Euclidean remainder: always 0 <= remainder < daysPerCycle.
    BigInteger remainder = product % daysPerCycle;
    if (remainder.Sign < 0)
        remainder += daysPerCycle;

    BigInteger wholeRevolutions =
        (product - remainder) / daysPerCycle;

    double longitude =
        (double)remainder * 360.0 / (double)daysPerCycle;

    return new MeanPlaceTrace
    {
        ElapsedDays = elapsedDays,
        RevolutionsPerCycle = revolutionsPerCycle,
        DaysPerCycle = daysPerCycle,
        Product = product,
        WholeRevolutions = wholeRevolutions,
        Remainder = remainder,
        LongitudeDegrees = Normalize(longitude),
        FormulaId = "SS-I-53-MEAN-PLACE"
    };
}

static double Normalize(double value)
{
    value %= 360.0;
    if (value < 0.0) value += 360.0;
    return value;
}

Remainder cycle-days-এর চেয়ে ছোট, তাই final conversion সাধারণ traditional constants-এ double-এ নিরাপদ range-এ থাকবে। তবু research-grade trace-এ rational form r/N রেখে দিলে অন্য language বা high-precision implementation-এর সঙ্গে exact comparison সহজ হয়।

Rāśi–degree–kalā–vikalā conversion

public sealed class TraditionalAngle
{
    public int Rasi { get; set; }
    public int Degree { get; set; }
    public int Kala { get; set; }
    public double Vikala { get; set; }
}

public static TraditionalAngle SplitAngle(double longitude)
{
    double x = Normalize(longitude);
    int rasi = (int)Math.Floor(x / 30.0);
    double inRasi = x - rasi * 30.0;
    int degree = (int)Math.Floor(inRasi);
    double minutes = (inRasi - degree) * 60.0;
    int kala = (int)Math.Floor(minutes);
    double vikala = (minutes - kala) * 60.0;

    return new TraditionalAngle
    {
        Rasi = rasi,
        Degree = degree,
        Kala = kala,
        Vikala = vikala
    };
}

Carry handling display formatter-এ করুন: vikalā rounding-এ 60 হলে kalā বাড়বে; kalā 60 হলে degree; degree 30 হলে rāśi। Classification-এর source value কখনো rounded structure থেকে পুনর্গঠন করবেন না।

Formula Provenance-কে Code-এর অংশ করুন

public sealed class FormulaProvenance
{
    public string FormulaId { get; set; }
    public string TextName { get; set; }
    public string ChapterVerse { get; set; }
    public string SanskritEdition { get; set; }
    public string TranslationEdition { get; set; }
    public string InterpretationNote { get; set; }
    public string ReferenceImplementation { get; set; }
    public string ProjectImplementation { get; set; }
    public string RuleVersion { get; set; }
    public bool UsesEmpiricalCalibration { get; set; }
}

উদাহরণ:

FormulaId: SS-I-53-MEAN-PLACE
ChapterVerse: I.53
Inputs from: I.29–34 and I.37
Units from: I.28
Direction supplement: I.54
Partial-day supplement: I.67
Reference implementation: pancanga3.14
Project implementation: SuryaSiddhantaEngine.MeanPlace
Empirical calibration: false

ModernFit Saṅkrānti function-এর provenance আলাদা হবে এবং UsesEmpiricalCalibration = true। তাতে ancient formula ও printed-Panjika fit audit report-এ গুলিয়ে যাবে না।

Validation Ladder: “ফল মিলেছে” যথেষ্ট নয়

Levelপ্রশ্নপরীক্ষা
V1 Textualসব term ও operation accounted?Verse-by-verse ledger
V2 DimensionalUnits cancel/convert সঠিক?days × rev/cycle-days → revolutions
V3 ArithmeticInteger quotient/remainder সঠিক?Hand example ও exact rational
V4 Boundary0/360, negative D, exact division?Unit tests
V5 Reference-codePerl implementation-এর intermediate মিলছে?Same constants/epoch comparison
V6 Independent implementationঅন্য language একই result দেয়?C#, Perl, spreadsheet
V7 Published tableHistorical worked values মিলছে?Burgess/commentary example
V8 Observation/modern ephemerisModel discrepancy কত?Comparison, silent replacement নয়

Modern Swiss value-এর সঙ্গে অমিল হলেই verse-to-code conversion ভুল—এ সিদ্ধান্ত দেওয়া যায় না। আগে V1–V7 পরীক্ষা করুন। V8 traditional model-এর accuracy ও accumulated drift মাপে; textual fidelity আলাদা প্রশ্ন।

Essential unit tests

  • D = 0 → longitude 0° অথবা declared epoch offset;
  • D = N → পূর্ণ cycle শেষে 0°;
  • D = N/2 এবং R compatible হলে expected half-cycle;
  • negative D → normalized 0°…360°;
  • direct ও retrograde node complementary;
  • exact 30° boundary-তে rāśi indexing;
  • vikalā rounding carry;
  • BigInteger path বনাম rational/spreadsheet result;
  • same formula C# ও pancanga3.14-এ intermediate comparison।

True Planet Position-এ যাওয়ার আগে কী যোগ হবে?

Mean place একটি uniform circular model-এর অবস্থান। Chapter II-এর true-place pipeline-এ গ্রহভেদে আরও quantity ও operation যুক্ত হয়। পরবর্তী প্রবন্ধগুলোতে আলাদাভাবে বিশ্লেষণ করা হবে:

  1. Mean planet ও relevant mean Sun/śīghrocca;
  2. Mandocca বা slow apsis;
  3. Manda anomaly/kendra;
  4. Manda epicycle measure;
  5. Bhujā, koṭi ও jyā interpolation;
  6. প্রথম manda correction;
  7. Śīghra anomaly এবং śīghra correction;
  8. planet class অনুযায়ী repeated/half corrections;
  9. final normalized true longitude;
  10. deśāntara, Bīja এবং project calibration-এর পৃথক স্তর।

Sun ও Moon, superior planets—Mars/Jupiter/Saturn—এবং Mercury/Venus একই dependency chain ব্যবহার করে না। তাই একটি generic “truePlanet(mean)” function দিয়ে শুরু না করে প্রথমে dependency graph ও formula ledger বানানো হবে।

সাধারণ ভুল

Translation-এর explanatory word-কে original শ্লোক ভাবা

Translator readability-এর জন্য operand বা context যোগ করতে পারেন। Sanskrit term, translation এবং commentary তিন column-এ রাখুন।

Decimal-এ খুব তাড়াতাড়ি যাওয়া

Large cycle counts প্রথমে exact integer ratio হিসেবে রাখুন। আগে floating-point করলে বহু যুগের multiplication-এ remainder বদলাতে পারে।

Remainder-এর বদলে total turns × 360 নেওয়া

Whole revolutions বাদ না দিলে huge angle তৈরি হয় এবং precision নষ্ট হয়। আগে Euclidean remainder, পরে degree conversion।

Negative historical date-এ language-এর % blindly ব্যবহার

C# remainder negative হতে পারে। Explicit Euclidean normalization করুন।

Mean result-কে true position বলা

I.53 mean place দেয়; Chapter II correction ছাড়া true planet নয়।

Reference implementation-কে infallible text ভাবা

pancanga3.14 অমূল্য computational reference, কিন্তু সেটিও একটি implementation। Text, comments, constants ও code path independently audit করুন।

ModernFit correction-কে ancient Bīja ঘোষণা করা

আপনার 1947+ table একটি documented empirical calibration। Ancient textual Bīja, later traditional correction এবং project fit আলাদা provenance-এ থাকবে।

Publication ও Research Checklist

  1. Chapter/verse এবং edition লেখা?
  2. Original text, translation ও commentary আলাদা?
  3. Encoded number independently verified?
  4. Input/output units স্পষ্ট?
  5. Epoch ও reference meridian লেখা?
  6. Direct/retrograde sign convention লেখা?
  7. Modulo ও negative-date policy স্পষ্ট?
  8. Integer arithmetic যতক্ষণ সম্ভব সংরক্ষিত?
  9. Rounding শুধু display-এ?
  10. Intermediate product/quotient/remainder export করা যায়?
  11. Reference Perl ও C# result একই constants-এ তুলনা করা?
  12. Mean ও true labels পৃথক?
  13. Textual constant ও empirical correction পৃথক?
  14. Formula version batch HTML/XML/API-তে সংরক্ষিত?

উপসংহার

সূর্যসিদ্ধান্তের শ্লোককে software-এ রূপান্তর মানে প্রাচীন ভাষাকে আধুনিক syntax-এ প্রতিস্থাপন নয়। এটি source criticism, technical translation, unit analysis, algebra, numerical computing এবং reproducibility-এর সম্মিলিত কাজ। একটি trustworthy formula-র সঙ্গে তার verse, edition, interpretation, units, epoch, direction, modulo ও rounding policy থাকতে হবে।

Chapter I.53 দেখায় এই পদ্ধতি কতটা পরিষ্কার হতে পারে: elapsed days × revolutions ÷ cycle-days থেকে quotient ও remainder; remainder থেকে normalized mean longitude। কিন্তু একই সঙ্গে এটি শেখায়—একটি সুন্দর mean longitude এখনো True Planet নয়। পরবর্তী ধাপে যুগ, মহাযুগ, ভগণ, অহর্গণ ও mean motion-এর ভিত্তি সম্পূর্ণভাবে নির্মাণ করে তারপর Chapter II-এর manda–śīghra correction pipeline-এ প্রবেশ করা হবে।

প্রাথমিক পাঠ ও তথ্যসূত্র

  1. Ebenezer Burgess, Translation of the Sûrya-Siddhânta: A Text-book of Hindu Astronomy, Journal of the American Oriental Society, 1858/1860; public-domain scan, translation, notes ও appendix।
  2. Sūrya Siddhānta, Chapter I—Sanskrit verse ledger; I.28 units, I.29–40 constants, I.53–54 mean-place/direction এবং I.67 time adjustment; source notes identify Michio Yano's GRETIL e-text and Burgess numbering।
  3. Bāpū Deva Śāstrī, English Translation of the Sūrya Siddhānta, 1861; independent public-domain translation witness।
  4. M. Yano and M. Fushimi, Pancanga version 3.14; Perl reference implementation description।
  5. pancanga3.14 source script; executable interpretation used as one comparison layer in this project।

পাঠকের কণ্ঠ

প্রশ্ন ও আলোচনা 0

যেকোনো মন্তব্য বা উত্তরে আবার উত্তর দিন। প্রতিটি উত্তর তার মূল আলোচনার সঙ্গে থাকবে।

আলোচনাটি আপনিই শুরু করুন

এই প্রবন্ধ নিয়ে আপনার প্রশ্ন বা মতামত লিখুন।

আলোচনায় যোগ দিন

আপনার প্রশ্ন বা মতামত

সম্পাদকের অনুমোদনের পর আপনার মন্তব্য প্রকাশিত হবে।