Implementation of all sutras in computer lab using C / Python / any other programming language

Sutras एक small Python toolkit बन जाते हैं: कुछ short functions multiplication और squaring shortcuts implement करते हैं, mental techniques को ऐसे code में बदलते हुए जिसे आप run, test, और reuse कर सकते हैं।

11 min read · 9 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

Techniques से एक Toolkit तक

इस पूरी unit में आप हर sutra से एक mental shortcut की तरह मिले और इसे अकेले code किया। आपका syllabus आपसे sutras को एक computer lab में implement करके, इन्हें working code में इकट्ठा करके finish करने के लिए कहता है। चूँकि यह Python subject है, आप एक small Python toolkit build करते हैं: कुछ short functions, एक per technique, जिन्हें आप run, test, और reuse कर सकते हैं।

यह closing lesson वह toolkit assemble करता है और, importantly, दिखाता है ordinary arithmetic के against हर function को कैसे test करें, तो आप code पर trust करें। यहाँ सारे outputs verified हैं।

Theory

Multiplication और Squaring Functions

Sutras में से तीन calculation shortcuts हैं जो functions में cleanly map होते हैं:

Nikhilam एक base के near दो numbers multiply करता है (deficiencies, cross-subtract, multiply)। Ekadhikena Purvena 5 पर end होने वाली एक number square करता है (front times one more, 25 append)। Yavadunam एक base के near एक number square करता है (number plus deficiency, फिर deficiency squared)।

हर एक बस कुछ lines का है, क्योंकि हर sutra एक compact rule है। साथ इकट्ठा किए, ये fast special-case calculators की एक tiny library बनाते हैं, exactly वह जो practice में 'sutras implement करना' का मतलब है।

Practical

Sutra Toolkit (verified outputs)

def nikhilam(a, b, base=100):        # multiply near a base
    da, db = base - a, base - b
    return (a - db) * base + da * db

def square_ending_in_5(n):           # Ekadhikena Purvena
    f = n // 10
    return f * (f + 1) * 100 + 25

def square_near_base(n, base=100):   # Yavadunam
    d = n - base
    return (n + d) * base + d * d

print(nikhilam(97, 96))         # 9312
print(square_ending_in_5(65))   # 4225
print(square_near_base(98))     # 9604
print(square_near_base(103))    # 10609

This example runs in Gri-Learn on the web, where you can edit it and see the output.

Theory

एक Equation-Solving Function भी

हर sutra arithmetic नहीं है। Sankalana-Vyavakalanabhyam adding और subtracting से simultaneous equations की एक pair solve करता है, और यह भी एक neat function बन जाता है।

Sum-and-difference form (x + y = s, x - y = d) के लिए, solution x = (s + d) / 2 और y = (s - d) / 2 है। तो solve_sum_diff(10, 4) (7, 3) return करता है, worked example से match करते हुए। Toolkit में एक equation-solver add करना दिखाता है sutras arithmetic और algebra दोनों span करते हैं, और दोनों directly code में translate होते हैं।

Practical

Ordinary Arithmetic के against Toolkit Testing करना

def solve_sum_diff(s, d):            # Sankalana-Vyavakalanabhyam
    return (s + d) // 2, (s - d) // 2

# TEST each function against Python's own arithmetic:
assert nikhilam(97, 96) == 97 * 96          # 9312
assert square_ending_in_5(65) == 65 ** 2    # 4225
assert square_near_base(98) == 98 ** 2      # 9604
assert solve_sum_diff(10, 4) == (7, 3)
print("All sutra functions match ordinary arithmetic.")

This example runs in Gri-Learn on the web, where you can edit it and see the output.

Quiz

Toolkit में, square_near_base(103) Yavadunam implement करता है। यह क्या return करता है?

  1. 10309, एक approximation
  2. 10609, क्योंकि 103 squared 10609 है (deficiency +3: 103+3=106, 3 squared = 09)
  3. 1069, एक digit drop करते हुए
  4. यह एक error raise करता है, क्योंकि 103, base से ऊपर है
Show the answer

10609, क्योंकि 103 squared 10609 है (deficiency +3: 103+3=106, 3 squared = 09)

square_near_base(103) excess d = 103 - 100 = 3 compute करता है, left part 103 + 3 = 106, और right part 3 squared = 9 (04 09 तक padded), 106 | 09 = 10609 देते हुए, जो exactly 103 squared है। Option A एक vague wrong value है; method exact है, approximate नहीं। Option C faulty place-value से एक digit drop करता है। Option D wrong है: Yavadunam base से ABOVE की numbers fine handle करता है, deficiency बस positive है (एक excess), और same formula apply होता है। Toolkit function 10609 return करता है, और assert square_near_base(103) == 103 ** 2 से इसे test करना इसे confirm करता है।

Think first

हर Sutra Function को Ordinary Multiplication के against assert से क्यों Test करें?

Sutras को correct होना चाहिए, तो हर function को normal arithmetic के बराबर assert करने की तकलीफ़ क्यों उठाएँ? फिर tap कीजिए।

Show the answer

क्योंकि एक correct METHOD implement करना correct CODE guarantee नहीं करता, और एक automatic test इनके बीच gap तुरंत catch करता है। Sutra खुद sound हो सकता है, पर आपके function में अभी भी एक bug हो सकता है: front digit में एक off-by-one, right part की wrong padding, एक integer-division slip, deficiency में एक sign error। assert nikhilam(97, 96) == 97 * 96 लिखना function को Python के अपने reliable multiplication के against pin करता है, तो अगर आपका implementation थोड़ा भी off है, assert loudly fail होता है और आप code पर trust करने से पहले इसे fix करते हैं। यही exactly वजह है earlier lessons ने हर shortcut को ordinary arithmetic के against CHECK करते रहे (पूरी 'verify by execution' habit): ordinary calculation ground truth है, और fast method को इससे match करना पड़ता है। उस check को एक assert में बदलना इसे automatic और repeatable बनाता है, आप code change करते समय कभी भी सारे tests फिर से run कर सकते हैं, और ये silently confirm करते हैं कुछ नहीं टूटा। यह real software में unit testing जैसी same discipline है: एक function सिर्फ़ तब trustworthy है जब यह known-correct results के against tested है। यह intent भी document करता है (assert बताता है function को क्या produce करना चाहिए) और future edits के against guard करता है। तो tests sutras की correctness के साथ redundant नहीं हैं; ये verify करते हैं कि sutra का code में आपका TRANSLATION faithful है। Method plus tested implementation equals code जिस पर आप rely कर सकते हैं। Trust कीजिए, पर verify कीजिए, एक assert के साथ।

Theory

BCA602 Complete

आपने एक real dataset को end to end analyse किया है, इसे explore करते हुए, इसके types और shape समझते हुए, pandas से EDA automate करते हुए, और regression और machine learning में step करते हुए, और आपने classical calculation techniques का एक toolkit Python में implement किया है। यही Data Analytics using Python का पूरा arc है। इस unit के लिए अपने institute के निर्देश follow कीजिए; हर technique को उस method की तरह present कीजिए जो यह encode करता है, prescribed text से, और अपना source cite कीजिए। Subject का एक strong finish।

Summary

Key takeaways

  • Syllabus आपसे sutras को code में implement करने के लिए कहता है; यह Python subject एक small Python toolkit build करता है।
  • nikhilam एक base के near multiply करता है: nikhilam(97, 96) = 9312।
  • square_ending_in_5 (Ekadhikena) 5 पर end होने वाली numbers square करता है: square_ending_in_5(65) = 4225।
  • square_near_base (Yavadunam) एक base के near square करता है: square_near_base(98) = 9604 और (103) = 10609।
  • solve_sum_diff (Sankalana-Vyavakalanabhyam) sum-and-difference system solve करता है: solve_sum_diff(10, 4) = (7, 3)।
  • हर function को ordinary arithmetic के against assert से test कीजिए, तो आप सिर्फ़ method नहीं बल्कि implementation पर trust करें।
  • Memory hook: हर sutra एक short tested function बनता है; code को plain arithmetic के against verify कीजिए।

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Vedic Mathematics Sutras

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Implementation of all sutras in computer lab using C / Python / any other programming language · Data Analytics using Python (Major-14) · Gri-Learn