Sum of series with alternate signed squares of AP

An arithmetic progression (AP) is a series of numbers in which the difference between two consecutive terms is the same. The difference is calculated by subtracting the first term from the second.

Let's take a sample sequence to understand AP −

5, 7, 9, 11, 13, 15, . . . The common difference (d) of this arithmetic progression is 2. This means every succeeding element differs from the former one by 2. The first term (a) of this series is 5.

The general formula for finding the nth term is an = a + (n-1) × d

In this problem, we are given an AP and we need to find the sum of series with alternate signed squares. The series will look like −

a12 - a22 + a32 - a42 + a52 - ...

Syntax

sum = a1² - a2² + a3² - a4² + ...
where ai = a + (i-1) × d

Example 1: Simple Case

Let's calculate the sum for the first 4 terms of AP starting with 1 and common difference 1 −

#include <stdio.h>

int main() {
    int a = 1;  // First term
    int d = 1;  // Common difference
    int n = 4;  // Number of terms
    int sum = 0;
    
    printf("AP terms: ");
    for (int i = 0; i < n; i++) {
        int term = a + i * d;
        printf("%d ", term);
        
        if (i % 2 == 0) {
            sum += term * term;  // Add square for even positions (0, 2, 4...)
        } else {
            sum -= term * term;  // Subtract square for odd positions (1, 3, 5...)
        }
    }
    
    printf("\nSum with alternate signs: %d<br>", sum);
    printf("Calculation: 1² - 2² + 3² - 4² = 1 - 4 + 9 - 16 = %d<br>", sum);
    
    return 0;
}
AP terms: 1 2 3 4 
Sum with alternate signs: -10
Calculation: 1² - 2² + 3² - 4² = 1 - 4 + 9 - 16 = -10

Example 2: General Formula Implementation

Here's a more general approach using the AP formula −

#include <stdio.h>

int calculateAlternateSquareSum(int firstTerm, int commonDiff, int numTerms) {
    int sum = 0;
    
    for (int i = 0; i < numTerms; i++) {
        int term = firstTerm + i * commonDiff;
        int square = term * term;
        
        if (i % 2 == 0) {
            sum += square;
        } else {
            sum -= square;
        }
    }
    
    return sum;
}

int main() {
    int a = 5;   // First term
    int d = 3;   // Common difference  
    int n = 6;   // Number of terms
    
    printf("AP with first term = %d, common difference = %d<br>", a, d);
    printf("Terms: ");
    
    for (int i = 0; i < n; i++) {
        int term = a + i * d;
        printf("%d ", term);
    }
    
    int result = calculateAlternateSquareSum(a, d, n);
    printf("\nSum of alternate signed squares: %d<br>", result);
    
    return 0;
}
AP with first term = 5, common difference = 3
Terms: 5 8 11 14 17 20 
Sum of alternate signed squares: -234

Key Points

  • The sign alternates starting with positive for the first term (index 0).
  • For even indices (0, 2, 4...), we add the square; for odd indices (1, 3, 5...), we subtract.
  • The formula can be optimized mathematically, but the iterative approach is clearer.

Conclusion

The sum of alternate signed squares in an AP follows the pattern a?² - a?² + a?² - a?² + ... This can be computed iteratively by generating AP terms and applying alternating signs to their squares.

Updated on: 2026-03-15T11:33:46+05:30

427 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements