Strictly Increasing Function

A strictly increasing function is one where f(x+1) > f(x) for all x in the domain. That is, the function output increases as the input increases.

Some examples of strictly increasing functions:

  • Linear: f(x) = x
  • Quadratic: f(x) = x^2
  • Exponential: f(x) = 2^x

Java example:

1
2
3
4
5
6
// Polynomial 
double f(double x) {
  return 3*x*x + 2*x + 1;
} 

// Output strictly increases as x increases

C++ example:

1
2
3
4
5
6
// Exponential
double f(double x) {
  return exp(0.5*x); 
}

// Always strictly increasing

Python example:

1
2
3
4
5
6
7
# Logarithm
import math

def f(x):
  return math.log2(x)

# Strictly increasing function  

Key properties:

  • Output always increases with increased input
  • No flat or decreasing portions
  • Useful for modeling growth

Strictly increasing functions appear in physics, statistics, economics to model quantities that grow consistently.

In mathematics, a function ( f(x) ) is said to be “strictly increasing” if for every ( x_1 < x_2 ), ( f(x_1) < f(x_2) ). In simpler terms, as you move from left to right on the graph, the function always rises; it never stays flat or decreases. In programming, when dealing with sequences or arrays, a strictly increasing array is an array in which each element is larger than the one before it.

In a strictly increasing sequence, no duplicates are allowed. Each element must be larger than the preceding element. If a sequence has duplicates, it can’t be classified as strictly increasing.

If duplicates are allowed, the sequence would be considered monotonically increasing, not strictly increasing. In a monotonically increasing sequence, each element is greater than or equal to the preceding element.

Java

Here’s how you can check if an array is strictly increasing in Java:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
public class Main {
    public static boolean isStrictlyIncreasing(int[] arr) {
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] <= arr[i - 1]) {
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println(isStrictlyIncreasing(arr));  // Output will be true
    }
}

C++

In C++, you can use the following code to check if a vector is strictly increasing:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <iostream>
#include <vector>
using namespace std;

bool isStrictlyIncreasing(vector<int> arr) {
    for (int i = 1; i < arr.size(); i++) {
        if (arr[i] <= arr[i - 1]) {
            return false;
        }
    }
    return true;
}

int main() {
    vector<int> arr = {1, 2, 3, 4, 5};
    cout << isStrictlyIncreasing(arr);  // Output will be 1 (true)
}

Python

In Python, you can check if a list is strictly increasing like this:

1
2
3
4
5
6
7
8
def is_strictly_increasing(arr):
    for i in range(1, len(arr)):
        if arr[i] <= arr[i - 1]:
            return False
    return True

arr = [1, 2, 3, 4, 5]
print(is_strictly_increasing(arr))  # Output will be True

In each of these code examples, we start iterating from the second element and compare it with the previous one. If we find any element that is smaller than or equal to its predecessor, we return false; otherwise, we return true.