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

Lilavati के methods code बनते हैं: Python की कुछ lines part-by-part multiplication और right-triangle check implement करती हैं, classical arithmetic को एक running program में बदलते हुए।

10 min read · 9 cards · 2 checks

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


Theory

Verse से Code तक

पिछले दो topics ने Lilavati की documented mathematics cover की: numbers को parts में तोड़ने वाला एक multiplication method, और right-triangle relationship। आपका syllabus आपसे इनके साथ कुछ satisfying करने को कहता है: इन्हें code में implement करना।

यह एक normal programming exercise है, exactly वैसी जो आपने BCA104 से किया है: एक well-defined method लीजिए और इसे एक function की तरह express कीजिए। यह लगभग-900-साल पुराने एक mathematical text को उन coding skills से connect करता है जो आपने अपने पूरे BCA के across build की हैं। यह lesson दोनों methods short Python programs की तरह दिखाता है, इनके outputs के साथ, ताकि आप classical arithmetic को एक modern machine पर चलते देख सकें।

Theory

Multiplication Method Implement करना

Lilavati की part-by-part multiplication (topic 1 से) multiplier को place-value parts में तोड़ती है और partial products sum करती है, जो distributive law है। Code में, सबसे simple faithful version multiplier को digit by digit (place value से) split करता है, multiply करता है, और add करता है।

Worked example 125 × 12 के लिए, 12 को 10 + 2 में split करना 125×10 + 125×2 = 1250 + 250 = 1500 देता है। एक program इसे generalise कर सकता है। (बेशक Python का * directly multiply करता है; exercise का point documented METHOD को EXPRESS करना है, दिखाते हुए historical technique code में कैसे map होती है, operator को replace करना नहीं।)

Practical

Part-By-Part Multiplication (Documented Method)

# Multiply by breaking the multiplier into place-value parts,
# summing partial products (the Lilavati's distributive method).
def multiply_by_parts(a, b):
    total = 0
    place = 1                 # 1, 10, 100, ... (place values)
    for digit in reversed(str(b)):   # process b digit by digit
        total += a * int(digit) * place
        place *= 10
    return total

print(multiply_by_parts(125, 12))   # 1500
# 125*2*1 + 125*1*10 = 250 + 1250 = 1500

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

Practical

Code में Right-Triangle Relationship

import math

# Check the right-triangle relationship: a^2 + b^2 == c^2
def is_right_triangle(a, b, c):
    return a*a + b*b == c*c

# Or compute the hypotenuse from the two shorter sides:
def hypotenuse(a, b):
    return math.sqrt(a*a + b*b)

print(is_right_triangle(3, 4, 5))   # True  (9 + 16 = 25)
print(hypotenuse(3, 4))             # 5.0
print(is_right_triangle(3, 4, 6))   # False (9 + 16 = 25, not 36)

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

Quiz

Function is_right_triangle(a, b, c) return करता है a*a + b*b == c*c। is_right_triangle(3, 4, 5) क्या return करता है, और क्यों?

  1. False, क्योंकि 3 + 4, 5 नहीं है
  2. True, क्योंकि 3*3 + 4*4 = 9 + 16 = 25, और 5*5 = 25, तो equality hold होती है
  3. एक error
  4. True, पर सिर्फ़ coincidence से
Show the answer

True, क्योंकि 3*3 + 4*4 = 9 + 16 = 25, और 5*5 = 25, तो equality hold होती है

Function check करता है aa + bb == cc: 3, 4, 5 के लिए वह left पर 9 + 16 = 25 है और right पर 55 = 25, तो equality hold होती है और यह True return करता है। यह documented right-triangle relationship (वह theorem जो West में Pythagorean के नाम से जाना जाता है) correctly implement करता है। Option A sides को square करने की बजाय add करता है (एक common confusion जो code avoid करता है)। Option C ग़लत है: code बिल्कुल fine चलता है। Option D इसे undersell करता है: 3-4-5 का relationship satisfy करना coincidence नहीं है, यह एक genuine right triangle है, और method इसे correctly identify करता है। यह exercise दिखाता है documented historical mathematics कैसे code की कुछ clean lines में directly और cleanly map होती है।

Think first

जिसे Python * से कर सकता है, उस Method को Implement क्यों करें?

Python एक simple * से multiply करता है, तो Lilavati के part-by-part method को code करने की जहमत क्यों उठाएँ? Educational value क्या है? फिर tap कीजिए।

Show the answer

Value * operator को REPLACE करना नहीं है बल्कि historical method को UNDERSTAND और EXPRESS करना है, और दो चीज़ों को connect करना जो आपने सीखी हैं: classical mathematics और programming। Part-by-part multiplication implement करना आपको FORCE करता है समझने के लिए method कैसे काम करता है (place value से split करना, partial products sum करना), जो historical technique AND नीचे वाले distributive principle दोनों की आपकी grasp को deepen करता है। यह same educational reason है जिससे आपने कभी sorting या searching को हाथ से implement किया एक library call करने की बजाय: एक method को code करना method सिखाता है। यह यह भी demonstrate करता है कि सदियों पहले की documented mathematics modern code पर cleanly map होती है, समय के across एक nice bridge। तो यह exercise comprehension और connection के बारे में है, efficiency नहीं। Insight transfer होता है: एक algorithm genuinely समझने के लिए, इसे implement कीजिए।

Watch out

Implementation Traps

Squaring की बजाय Sides Add करना: right-triangle check aa + bb == c*c है, a + b नहीं।

c Squared बनाम c: c*c एक 5-side के लिए 25 है; c खुद 5 है (length के लिए square root लीजिए)।

Floating-Point Comparison: math.sqrt एक float return करता है; exact equality के लिए floats compare करना fragile हो सकता है, integers के साथ squared-form check (aa + bb == c*c) prefer कीजिए।

Comments में Verse Text Fabricate करना: code comments factual रखिए; method cite कीजिए, invented shlokas नहीं।

Overcomplicating: एक faithful, simple implementation एक clever obscure वाले से बेहतर है।

Theory

Methods Coded; अब Capstone Project

आपने Lilavati के documented methods Python में implement किए हैं, historical mathematics और modern code को bridge करते हुए। पूरे subject का final topic capstone PROJECT है: Units 1 से 3 (MongoDB, React, Angular) पर based एक छोटा application बनाना। अगला lesson इसे अच्छी तरह scope और build करने पर guidance देता है, आपने Advance Web Designing में जो कुछ सीखा उसे साथ tie करते हुए।

Summary

Key takeaways

  • Syllabus आपसे Lilavati के documented methods code (Python/C) में implement करने कहता है: एक normal programming exercise।
  • Part-by-part multiplication (distributive method) को multiplier को place value से split करके और partial products sum करके code किया जा सकता है: multiply_by_parts(125, 12) = 1500।
  • Right-triangle relationship aa + bb == c*c की तरह coded होता है: is_right_triangle(3, 4, 5) True है (9 + 16 = 25)।
  • Hypotenuse को math.sqrt(aa + bb) की तरह compute कीजिए: hypotenuse(3, 4) = 5.0।
  • Value historical method को समझना और code से connect करना है, built-in operators को replace करना नहीं।
  • Float comparison पर integer squared-form check prefer कीजिए; comments factual रखिए (कोई fabricated verses नहीं)।
  • Memory hook: documented math code की कुछ clean lines में map होती है।

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 Indian knowledge system of Mathematics

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 · Advance Web Designing (Major-11-01) · Gri-Learn