Library contents

C++ std::exp

The natural exponential turns a continuous growth exponent into a multiplier.

A simple example

std::exp

  1. Start with 0
  2. Do this Raise e to the power 0
  3. Result 1
Any positive base raised to zero is one.
lesson.cpp
#include <iostream>
#include <cmath>

int main() {
    std::cout << (std::exp(0.0)) << '\n';
}
Output
1

Syntax

C++ syntax
std::exp(rate)
Run these examples in C++

Save one example at a time as lesson.cpp. Use C++17 and a Unix-style shell.

c++ -std=c++17 -Wall -Wextra lesson.cpp -o lesson
./lesson

Check the baseline of a growth model

A growth simulator starts at zero elapsed change. Evaluate its baseline to determine what multiplier should preserve the initial population before any growth has occurred.

From the programconst double rate = 0.0
Result1.000
lesson.cpp
#include <cmath>
#include <cstdio>

int main() {
    const double rate = 0.0;

    std::printf("%.3f\n", std::exp(rate));
    return 0;
}
Output
1.000

A zero exponent produces a multiplier of one, so an initial population remains the same.

Advertisements

Project a continuous growth multiplier

A class is comparing growth against an unchanged starting amount. Examine the multiplier at the reference point so a later increase can be interpreted relative to the original quantity.

From the programconst double exponent = 1.0
Result2.718
lesson.cpp
#include <cmath>
#include <cstdio>

int main() {
    const double exponent = 1.0;

    std::printf("%.3f\n", std::exp(exponent));
    return 0;
}
Output
2.718

A unit exponent corresponds to a multiplier near 2.718. Multiply the initial level by this factor.

Model a cooling signal

A normalized sensor model has a decay exponent of minus one over a test interval. The instrument needs the fraction of its original signal remaining.

Given-1
Worked result0.368 ×

Using -1 gives 0.368 × for this measurement.

What to watch for

The exponent is dimensionless. Convert rates and time to matching units first.

Documentation for std::exp