~1 min read • Updated Oct 12, 2025
Program Overview
This Python program reads values for a, x, and n from the user.
It computes the nth derivative of the exponential function e^{ax} using the recursive relation:
dⁿ/dxⁿ(e^{ax}) = aⁿ × e^{ax}
Python Code:
def recursive_derivative(a: float, x: float, n: int) -> float:
if n == 0:
return pow(2.718281828459045, a * x) # e^ax
return a * recursive_derivative(a, x, n - 1)
# Read inputs from user
a = float(input("Enter value for a: "))
x = float(input("Enter value for x: "))
n = int(input("Enter derivative order n: "))
result = recursive_derivative(a, x, n)
print(f"The {n}th derivative of e^({a}x) is: {result:.6f}")
Sample Output (input: a = 2, x = 1, n = 3):
The 3th derivative of e^(2x) is: 40.171944
Written & researched by Dr. Shahin Siami