liveBook · Manning

Exp function

As explained in Math for Web Design

Math.exp() is a JavaScript function that returns e raised to a specified power.

To make an element appear to grow faster as an animation progresses, use exponential scale values. CSS exp(x) returns e raised to x, where e is approximately 2.71828. Its JavaScript equivalent is Math.exp(x). section 3.2.4

Listing 3.8 Simulating exponential growth with exp()
@keyframes exponential-growth {
    0% { transform: scale(1); }
    50% { transform: scale(exp(1)); }    #1
    100% { transform: scale(exp(2)); }    #2
}
.grow {
    animation: exponential-growth 2s linear infinite;
}

The animation scales from 1 to exp(1) halfway through, then to exp(2) at the end. The corresponding JavaScript calculations are Math.exp(1) and Math.exp(2). section 3.2.4

Use Math.exp() when the same calculation needs to run in JavaScript, including when supporting browsers without CSS exp(). section 3.2.4

How Math for Web Design covers it

How deep it goes
Defines e raised to x and identifies Math.exp() as its equivalent, but works through the animation in CSS rather than JavaScript.
Examples
Uses an animation with scale values of 1, exp(1), and exp(2).
What it assumes
Introduces e from its approximate value and relationship to logarithms; assumes familiarity with CSS keyframe animation syntax for the example.
What you can do after
Apply it via Math.exp() to calculate the JavaScript equivalent of a CSS exp() value.
How it connects
Connects exponential growth to CSS animations, transform scaling, and the natural logarithm.

This explainer was generated by Manning's knowledge graph from the text of Math for Web Design. The section links point to the parts of the book it draws on.