Skip to content

Vedic Maths Squaring — Advanced Sutras for Any Number

DodaTech Updated 2026-06-21 12 min read

In this tutorial, you'll learn about Vedic Maths Squaring. We cover key concepts, practical examples, and best practices.

Vedic mathematics offers multiple sutras for squaring numbers — each optimized for a specific pattern. The Duplex method (Dwanda Yoga) is the most general, working for any number using a vertical and crosswise pattern similar to Urdhva Tiryagbhyam.

ℹ️ Info

What you'll learn: The Duplex squaring method (general purpose), Yavadunam for near-base squaring, and how to choose the fastest sutra for any number.
Why it matters: Squaring appears everywhere — area calculations, physics equations, statistics (variance), and computer graphics. Vedic methods reduce squaring to simple addition and single-digit multiplication.
Real-world use: Graphics programmers compute squares for distance calculations; financial analysts square deviations for variance; competitive exam takers solve 5 problems per minute using pattern-matched sutras.

Choosing the Right Sutra

Number Pattern Best Sutra Example
Ends in 5 Ekadhikena Purvena 35² = 1225
Near power of 10 Yavadunam 98² = 9604
Near a working base Nikhilam (working base) 198² = 39204
Any number Duplex (Dwanda Yoga) 57² = 3249

The Duplex Method (Dwanda Yoga)

The Duplex D of a number is computed digit by digit:

  • For 1 digit (a): D = a²
  • For 2 digits (ab): D = 2 × a × b
  • For 3 digits (abc): D = 2 × a × c + b²
  • For 4 digits (abcd): D = 2 × a × d + 2 × b × c

The square is found by computing Duplex values for each position and combining with carries.

The Squaring Decision Tree

flowchart TD
    A["Number to square"] --> B{"Ends in 5?"}
    B -- Yes --> C["Ekadhikena Purvena
a × (a+1) + 25"] B -- No --> D{"Near a base?"} D -- Yes --> E["Yavadunam / Nikhilam
base² + deviation adjustment"] D -- No --> F["Duplex Method
(Dwanda Yoga)"] F --> G["Compute D for each
position, merge with carries"] G --> H["Final square ✓"] style A fill:#1a73e8,color:#fff,stroke:none style B fill:#34a853,color:#fff,stroke:none style C fill:#fbbc04,color:#333,stroke:none style D fill:#ea4335,color:#fff,stroke:none style E fill:#ab47bc,color:#fff,stroke:none style F fill:#46bdc6,color:#fff,stroke:none style G fill:#1a73e8,color:#fff,stroke:none style H fill:#34a853,color:#fff,stroke:none

Worked Examples: Duplex Method

Example 1: 34² (2-digit)

Digits: a = 3, b = 4.

Duplex values:

  • D(b) = 4² = 16. Write 6, carry 1.
  • D(ab) = 2 × 3 × 4 = 24. Add carry 1 = 25. Write 5, carry 2.
  • D(a) = 3² = 9. Add carry 2 = 11.

Answer: 1156

Check: 34² = 1156 ✓

Example 2: 57² (2-digit)

Digits: a = 5, b = 7.

  • D(b) = 7² = 49. Write 9, carry 4.
  • D(ab) = 2 × 5 × 7 = 70. Add carry 4 = 74. Write 4, carry 7.
  • D(a) = 5² = 25. Add carry 7 = 32.

Answer: 3249

Check: 57² = 3249 ✓

Example 3: 123² (3-digit)

Digits: a = 1, b = 2, c = 3.

Duplex values:

  • D(c) = 3² = 9. Write 9, carry 0.
  • D(bc) = 2 × 2 × 3 = 12. Write 2, carry 1.
  • D(abc) = 2 × 1 × 3 + 2² = 6 + 4 = 10. Add carry 1 = 11. Write 1, carry 1.
  • D(ab) = 2 × 1 × 2 = 4. Add carry 1 = 5. Write 5, carry 0.
  • D(a) = 1² = 1. Write 1.

Answer: 15129

Check: 123² = 15129 ✓

Example 4: 2345² (4-digit)

Digits: a = 2, b = 3, c = 4, d = 5.

Duplex values:

  • D(d) = 5² = 25. Write 5, carry 2.
  • D(cd) = 2 × 4 × 5 = 40. Add carry 2 = 42. Write 2, carry 4.
  • D(bcd) = 2 × 3 × 5 + 4² = 30 + 16 = 46. Add carry 4 = 50. Write 0, carry 5.
  • D(abcd) = 2 × 2 × 5 + 2 × 3 × 4 = 20 + 24 = 44. Add carry 5 = 49. Write 9, carry 4.
  • D(abc) = 2 × 2 × 4 + 3² = 16 + 9 = 25. Add carry 4 = 29. Write 9, carry 2.
  • D(ab) = 2 × 2 × 3 = 12. Add carry 2 = 14. Write 4, carry 1.
  • D(a) = 2² = 4. Add carry 1 = 5.

Reading: 5 4 9 9 0 2 5 → 5499025.

Check: 2345² = 5499025 ✓

Example 5: 98² using Yavadunam (near 100)

Yavadunam Sutra: For a number near a base: n² = (n − d)(n + d) + d², where d = deviation from base.

For 98 near 100:

  • Deviation d = 98 − 100 = −2
  • 98² = (98 − 2)(98 + 2) + 4 = 96 × 100 + 4 = 9600 + 4 = 9604

Check: 98² = 9604 ✓

Much faster than the Duplex method for near-base numbers!

Example 6: 1003² using Yavadunam

  • Deviation d = 1003 − 1000 = 3
  • 1003² = (1003 + 3)(1003 − 3) + 9 = 1006 × 1000 + 9 = 1,006,000 + 9 = 1,006,009

Check: 1003² = 1006009 ✓

Code Snippet: Python Implementation

def duplex_square(n):
    """Square any integer using the Duplex (Dwanda Yoga) method."""
    digits = [int(d) for d in str(n)]
    length = len(digits)

    # Compute duplex values for each position
    duplex_values = []
    for pos in range(2 * length - 1):
        d = 0
        # For each diagonal position, compute the duplex
        # Position corresponds to the line from leftmost to rightmost
        left = max(0, pos - length + 1)
        right = min(pos, length - 1)

        count = 0
        for i in range(left, right + 1):
            j = pos - i
            if 0 <= j < length:
                if i == j:
                    d += digits[i] ** 2
                    count += 1
                elif i < j:
                    d += 2 * digits[i] * digits[j]

        duplex_values.append(d)

    # Combine with carries
    result = []
    carry = 0
    for val in reversed(duplex_values):
        total = val + carry
        result.append(str(total % 10))
        carry = total // 10

    while carry > 0:
        result.append(str(carry % 10))
        carry //= 10

    return int(''.join(reversed(result)))


def yavadunam_square(n):
    """Square using Yavadunam (near a power-of-10 base)."""
    base = 10 ** len(str(n))
    deviation = n - base
    # (n - d)(n + d) + d² = (n - deviation)(n + deviation) + deviation²
    # Wait: let's use n ± deviation from base
    # n = base + d where d = n - base
    # n² = (base + d)² = base² + 2*base*d + d²
    # The Yavadunam method: (n + d) × base + d²... no.
    # Actually n - d = base (if n = base + d)
    # and n + d = base + 2d
    # So (n - d)(n + d) + d² = base(base + 2d) + d² = base² + 2*base*d + d² = (base + d)² = n² ✓

    # For deviation d where n = base + d:
    # n - d = base
    # (n - d)(n + d) = base × (n + d)
    # base × (n + d) is just (n + d) shifted left (multiplied by base)
    # Then add d²

    left = n + deviation  # = base + 2d
    right = deviation ** 2

    # left gets multiplied by base and right is added
    result = left * base + right
    return result


def smart_square(n):
    """Choose the best squaring method based on the number pattern."""
    if n % 10 == 5:
        # Ekadhikena Purvena
        a = n // 10
        return int(str(a * (a + 1)) + "25")

    base = 10 ** len(str(n))
    deviation = n - base

    if abs(deviation) < base * 0.15:
        return yavadunam_square(n)

    return duplex_square(n)


# Test
tests = [34, 57, 98, 123, 2345, 1003, 85]
for n in tests:
    result = smart_square(n)
    print(f"{n}² = {result} (expected: {n**2})")

Expected output:

34² = 1156 (expected: 1156)
57² = 3249 (expected: 3249)
98² = 9604 (expected: 9604)
123² = 15129 (expected: 15129)
2345² = 5499025 (expected: 5499025)
1003² = 1006009 (expected: 1006009)
85² = 7225 (expected: 7225)

Code Snippet: JavaScript Implementation

function duplexSquare(n) {
    const digits = String(n).split('').map(Number);
    const len = digits.length;

    const duplexValues = [];
    for (let pos = 0; pos < 2 * len - 1; pos++) {
        let d = 0;
        const left = Math.max(0, pos - len + 1);
        const right = Math.min(pos, len - 1);

        for (let i = left; i <= right; i++) {
            const j = pos - i;
            if (j >= 0 && j < len) {
                if (i === j) d += digits[i] ** 2;
                else if (i < j) d += 2 * digits[i] * digits[j];
            }
        }
        duplexValues.push(d);
    }

    const result = [];
    let carry = 0;
    for (const val of duplexValues.reverse()) {
        const total = val + carry;
        result.push(total % 10);
        carry = Math.floor(total / 10);
    }
    while (carry > 0) {
        result.push(carry % 10);
        carry = Math.floor(carry / 10);
    }

    return parseInt(result.reverse().join(''));
}

function smartSquare(n) {
    if (n % 10 === 5) {
        const a = Math.floor(n / 10);
        return parseInt((a * (a + 1)) + '25');
    }

    const base = Math.pow(10, String(n).length);
    const deviation = n - base;

    if (Math.abs(deviation) < base * 0.15) {
        const left = n + deviation;
        return left * base + deviation ** 2;
    }

    return duplexSquare(n);
}

[34, 57, 98, 123, 2345, 1003, 85].forEach(n => {
    console.log(`${n}² = ${smartSquare(n)} (expected: ${n ** 2})`);
});

Code Snippet: Duplex Benchmark

import time


def benchmark_squaring():
    """Compare Duplex method against standard Python multiplication."""
    import random
    numbers = [random.randint(10, 10**6) for _ in range(1000)]

    # Standard squaring
    start = time.perf_counter()
    for n in numbers:
        n ** 2
    std_time = time.perf_counter() - start

    # Duplex squaring (through our function)
    start = time.perf_counter()
    for n in numbers:
        duplex_square(n)
    duplex_time = time.perf_counter() - start

    print(f"Standard squaring: {std_time:.4f}s")
    print(f"Duplex squaring: {duplex_time:.4f}s")
    print(f"Ratio: {duplex_time / std_time:.2f}x")
    print("(Duplex is Python emulation — actual mental calculation is faster!)")


benchmark_squaring()

Common Errors

  1. Mixing up duplex positions. For a 3-digit number, there are 5 duplex positions. Position 1 (rightmost) is just last-digit squared. Position 2 uses last two digits crosswise. Position 3 uses outer cross + middle squared. A common mistake is computing all positions as pure crosswise without the middle square term.

  2. Forgetting the carry in Duplex. The duplex values are computed independently, but they must be merged with right-to-left carry propagation. Without carries, a 2-digit square like 57² would give [25, 70, 49] instead of the correct 3249.

  3. Using Yavadunam for numbers far from the base. 57² with base 100: deviation = −43, d² = 1849, left = 57 + (−43) = 14, result = 14 × 100 + 1849 = 3249. This works but isn't any faster than Duplex. The method thrives when |d| is small.

  4. Confusing Yavadunam with Nikhilam squaring. Yavadunam uses (n + d) × base + d². Some sources call this Nikhilam squaring. Either way, the algebraic identity is: (base + d)² = base(base + 2d) + d².

  5. Skipping the Ekadhikena pattern for numbers ending in 5. 85² should use Ekadhikena (8×9=72, append 25 → 7225), not Duplex. Recognizing patterns is faster than computing carries.

  6. Applying Duplex to decimals directly. For 3.4², square 34² = 1156, then place decimal: 2 decimal places → 11.56. Alternatively, treat 3 and 4 as separate digits in 3.4.

  7. Miscomputing D for 4-digit numbers. For abcd: D = 2×a×d + 2×b×c (no middle square term). The pattern alternates: for odd-length groups, the middle digit squares itself; for even-length groups, it's all cross pairs.

Practice Questions

  1. 63² = ? (use Duplex)
  2. 87² = ? (use Duplex)
  3. 996² = ? (use Yavadunam)
  4. 1012² = ? (use Yavadunam)
  5. 3456² = ? (use Duplex)

Answers:

  1. 63² = 3969 (D(3)=9, D(63)=2×6×3=36→6c3, D(6)=36+3=39)
  2. 87² = 7569 (D(7)=49→9c4, D(87)=2×8×7=112+4=116→6c11, D(8)=64+11=75)
  3. 996² = 992016 (deviation = −4, left = 996−4=992, d²=16, result=992×1000+16=992016)
  4. 1012² = 1024144 (deviation=12, left=1012+12=1024, d²=144, result=1024×1000+144=1024144)
  5. 3456² = 11943936

Mini Project: Squaring Practice Game

import random
import time


def squaring_practice():
    """Interactive squaring practice with timer and score."""
    score = 0
    total = 0

    print("Vedic Squaring Practice")
    print("Choose your method wisely!")
    print()

    while True:
        # Generate an appropriate number
        pattern = random.choice(['five', 'near_base', 'general'])
        if pattern == 'five':
            a = random.randint(1, 100)
            n = a * 10 + 5
            hint = "Ends in 5 — use Ekadhikena!"
        elif pattern == 'near_base':
            base = 10 ** random.randint(2, 3)
            offset = random.randint(1, 20)
            n = base + random.choice([-offset, offset])
            hint = f"Near {base} — use Yavadunam!"
        else:
            n = random.randint(11, 999)
            hint = "Use Duplex method!"

        correct = n ** 2
        total += 1

        start = time.perf_counter()
        try:
            answer = int(input(f"{n}² = ? "))
            elapsed = time.perf_counter() - start

            if answer == correct:
                score += 1
                print(f"✓ Correct! ({elapsed:.1f}s)")
            else:
                print(f"✗ Wrong. Answer: {correct}")
        except ValueError:
            print(f"Game over! Score: {score}/{total}")
            break

        if total >= 10:
            print(f"\nFinal score: {score}/{total}")
            break


squaring_practice()

FAQ

Which Vedic squaring method should I learn first?

Start with Duplex (Dwanda Yoga) — it works for any number without special cases. Then learn pattern-specific methods (Ekadhikena for numbers ending in 5, Yavadunam for near-base numbers). Pattern recognition comes with practice.

How does the Duplex method compare to standard squaring?

Standard squaring of 57² = (50 + 7)² = 2500 + 700 + 49 = 3249. Duplex achieves the same with 3 single-digit computations and carries. The difference is marginal for 2-digit numbers but significant for 3+ digit numbers.

Can I square decimal numbers using these methods?

Yes. Square the number as an integer (ignore the decimal), then place the decimal point. For 3.45², compute 345² = 119025, then place decimal: 3.45 has 2 decimal places, so square has 4: 11.9025.

What is the fastest method for 3-digit squaring?

For general 3-digit numbers, Duplex is fastest. For 3-digit numbers ending in 5 (like 125), Ekadhikena is instant. For 3-digit numbers near 100 (like 97, 104), Yavadunam is fastest.

How is squaring used in Doda Browser?

Distance calculations in browser rendering use thousands of squares per frame. While the browser uses hardware multiplication, the Vedic squaring patterns inspired the layout engine's optimized arithmetic for viewport calculations and element positioning.

What's the largest number I can square mentally?

With practice, 3-digit squaring is achievable entirely mentally. For 4-digit numbers, most people need to write intermediate steps. The Duplex method scales linearly — each additional digit adds 2 more duplex positions to compute.

Next Steps

Continue with Vedic Maths Cube Roots — Advanced Root Extraction to learn how Vedic sutras extract cube roots of perfect cubes in seconds.

Related tutorials:

  • Ekadhikena Purvena — squaring numbers ending in 5
  • Nikhilam — multiplication near powers of 10
  • Urdhva Tiryagbhyam — vertically and crosswise multiplication

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro