def fibonacci(n):
    """
    Calculate nth Fibonacci number efficiently using matrix exponentiation.

    Args:
        n (int): The position of the Fibonacci number to calculate.

    Returns:
        int: The nth Fibonacci number.
    """
    if n <= 1:
        return n
    
    # Initialize the base matrix [[1, 1], [1, 0]]
    a, b = 1, 1
    c, d = 1, 0
    
    for _ in range(2, n + 1):
        # Update the matrix using the recurrence relation
        a, b, c, d = (a * a + c * b, a * b + c * d,
                      b * a + d * b, b * c + d * a)
    
    return a