Header Ads Widget

⚡ Premium Tools Hub • EXE Apps + Full Python Source Code
Lite • Pro • Bundle Packs • Instant Download

NumPy Exponential Functions Explained – Python exp, log, power with Examples

NumPy – Exponential Functions 

Exponential functions are fundamental in mathematics, science, and machine learning.

NumPy provides fast and efficient exponential and logarithmic functions for array-based computation.

These functions are widely used in:

  • Machine learning
  • Data science
  • Physics simulations
  • Financial modeling
  • Growth and decay systems

Import NumPy

import numpy as np

1. Exponential Function (np.exp)

import numpy as np

data = np.array([1, 2, 3])

print(np.exp(data))

Meaning:

  • Computes e^x for each element
  • Used in growth models

2. Base-2 Exponential (np.exp2)

import numpy as np

data = np.array([1, 2, 3])

print(np.exp2(data))

Meaning:

  • Computes 2^x
  • Useful in computer science

3. Power Function (np.power)

import numpy as np

base = np.array([1, 2, 3])
exponent = 2

print(np.power(base, exponent))

Meaning:

  • Raises numbers to a power
  • Element-wise operation

4. Natural Logarithm (np.log)

import numpy as np

data = np.array([1, 2, 3, 10])

print(np.log(data))

Meaning:

  • ln(x) calculation
  • Used in growth and probability

5. Log Base 10 (np.log10)

import numpy as np

data = np.array([1, 10, 100, 1000])

print(np.log10(data))

Meaning:

  • Common in scientific calculations
  • Used in scale measurements

6. Log Base 2 (np.log2)

import numpy as np

data = np.array([1, 2, 4, 8, 16])

print(np.log2(data))

Meaning:

  • Used in computer science
  • Binary system analysis

7. Exponential Growth Example

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0, 5, 0.1)
y = np.exp(x)

plt.plot(x, y)
plt.title("Exponential Growth Curve")
plt.show()

Use case:

  • Population growth
  • Compound interest
  • Machine learning activations

8. Exponential Decay Example

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0, 5, 0.1)
y = np.exp(-x)

plt.plot(x, y)
plt.title("Exponential Decay Curve")
plt.show()

Use case:

  • Radioactive decay
  • Cooling systems
  • Signal attenuation

Real-World Applications

1. Data Science

  • Feature scaling
  • Probability models

2. Machine Learning

  • Activation functions (ReLU, sigmoid base)
  • Loss optimization

3. Finance

  • Compound interest
  • Investment growth

4. Physics

  • Decay processes
  • Wave attenuation

Why Use NumPy Exponential Functions?

Using NumPy provides:

  • Fast vectorized computation
  • Efficient mathematical operations
  • High-performance scientific computing
  • Easy integration with ML workflows

Combined with Python, it becomes essential for AI, data science, and engineering.


Summary

NumPy exponential functions include:

np.exp()
np.exp2()
np.power()
np.log()
np.log10()
np.log2()

Conclusion

Exponential functions in NumPy are essential for modeling growth, decay, and logarithmic relationships in science, finance, and machine learning.




Post a Comment

0 Comments