# Proposal: \`Math.lerp\` (Linear Interpolate)

**URL:** <https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [June 17, 2025, 6:51pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386 "2025-06-17T18:51:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghost](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@ghost](https://es.discourse.group/u/ghost)\
**Post date:** [June 17, 2025, 6:51pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/1 "2025-06-17T18:51:49Z")

</div>

Linear interpolation (`lerp` ) is a widely used operation in many domains, including graphics, animation, simulations, and numeric computations. In JavaScript, it is commonly implemented by developers manually. The large number of implementations are found in public repositories on GitHub ([Code search results · GitHub](https://github.com/search?q=lerp+language%3AJavaScript+&type=code)),

Despite it is simple appearance, `lerp` can be subtle in practice. A naive implementation may not always behave as expected, particularly when dealing with values of `t` outside the range `[0, 1]` . Sometimes extrapolation is desired (e.g., animations that overshoot), while in other cases it is not (e.g., UI values). Developers often find themselves reimplementing variants of `lerp` to address these different needs.

For example, in C++, `lerp` looks like this.

```cpp
int main() {
    std::cout << std::lerp(0, 10, 0.5) << std::endl; // 5
    std::cout << std::lerp(0, 10, 1.5) << std::endl; // 15 (extrapolation)
    std::cout << std::lerp(10, 0, 1.5) << std::endl; // -5
}

```

To improve consistency and reduce repetitive boilerplate code, it would be highly beneficial to introduce a standardized version such as `Math.lerp(a, b, t)`.

Optionally, we could consider an additional parameter to clamp the result within the `[a, b]` range when desired, which could cover a common use case:

```js
Math.lerp(0, 10, 1.5, true)

```

Or even adding the base for `t`

```js
Math.lerp(0, 100, 10, false, 10) // 100

```

---

<div class="post-metadata">

**Author:** ![bakkot](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/bakkot/32/22_2.png) [@bakkot](https://es.discourse.group/u/bakkot)\
**Post date:** [June 17, 2025, 8:04pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/2 "2025-06-17T20:04:17Z")

</div>

You may be interested in the [Range proposal](https://github.com/tc39/proposal-iterator.range), although it provides a fixed sequence rather than allowing you to choose an arbitrary point.

---

<div class="post-metadata">

**Author:** ![ghost](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@ghost](https://es.discourse.group/u/ghost)\
**Post date:** [June 17, 2025, 10:55pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/3 "2025-06-17T22:55:12Z")

</div>

Thank you for the info. I still believe `lerp` has its own value. The Range proposal doesn’t necessarily cover the same use cases.

---

<div class="post-metadata">

**Author:** ![tabatkins](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/tabatkins/32/170_2.png) [@tabatkins](https://es.discourse.group/u/tabatkins)\
**Post date:** [June 18, 2025, 4:41pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/4 "2025-06-18T16:41:09Z")

</div>

`lerp` is unrelated to `Range`, yeah. There's just some conceptual linkages, but in every practical concern they're completely unconnected.

I think lerping is a pretty useful little utility, yeah. Note CSS's recent addition of [`calc-interpolate()`](https://drafts.csswg.org/css-values-5/#calc-interpolate), which is lerping (but in a more complicated fashion) - in the minimal form you would write `calc-interpolate(.5, 0, 10)` and get `5` back.

---

<div class="post-metadata">

**Author:** ![jschoi](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jschoi/32/917_2.png) [@jschoi](https://es.discourse.group/u/jschoi)\
**Post date:** [June 27, 2025, 12:44am UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/5 "2025-06-27T00:44:30Z")

</div>

I agree that linear interpolation would be useful to standardize, although it fits into the category of “proposals that are easy to reimplement in userland so someone could ask whether there’s a big benefit to standardizing it”.

I don’t have the bandwidth to champion this, but I would voice support for it if a committee champion did propose it.

---

<div class="post-metadata">

**Author:** ![ghost](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@ghost](https://es.discourse.group/u/ghost)\
**Post date:** [June 27, 2025, 12:42pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/6 "2025-06-27T12:42:28Z")

</div>

How do we usually find a champion?  
And the original proposer also need to do some work for the official proposal?

---

<div class="post-metadata">

**Author:** ![jschoi](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jschoi/32/917_2.png) [@jschoi](https://es.discourse.group/u/jschoi)\
**Post date:** [August 5, 2025, 10:20pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/7 "2025-08-05T22:20:07Z")

</div>

Unfortunately, there is no reliable way for people to find a champion, because the Committee is small and has limited time and resources. Everyone has a lot on their plate.

But this thread is still useful for registering that there is interest in making a standard linear interpolation function from outside developers.

(Maybe someday, a champion might find this thread and decide to formally propose it. But there’s no reliable way to guarantee it or speed it up, sorry. Thanks for proposing it, though.)

---

<div class="post-metadata">

**Author:** ![jschoi](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jschoi/32/917_2.png) [@jschoi](https://es.discourse.group/u/jschoi)\
**Post date:** [August 5, 2025, 10:22pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/8 "2025-08-05T22:22:47Z")

</div>

Well, one thing you can do does occur to me. You can try to find evidence of developer demand for this function—evidence from real-world open-source codebases. Here are some examples:

- The [real-world examples from proposal-array-from-async’s explainer](https://github.com/tc39/proposal-array-from-async/blob/main/README.md#real-world-examples).
- The [real-world code statistics from proposal-call-this’s explainer](https://github.com/tc39/proposal-call-this/blob/main/README.md#call-is-very-common).

Compiling evidence of real-world demand, like in those examples above, would probably be the most helpful thing you could do. (Please keep in mind that compiling such evidence of demand is still not a guarantee that a champion will have the time to champion the proposal.)

---

<div class="post-metadata">

**Author:** ![claudiameadows](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/claudiameadows/32/126_2.png) [@claudiameadows](https://es.discourse.group/u/claudiameadows)\
**Post date:** [October 9, 2025, 1:31pm UTC](https://es.discourse.group/t/proposal-math-lerp-linear-interpolate/2386/9 "2025-10-09T13:31:34Z")

</div>

I’ll caution that this may be a bit awkward to search for, since it’s very common to just write lerp out explicitly as `weight * a + (1 - weight) * b`, or, if inaccuracy at `weight = 1` is tolerable, `weight * (a - b) + b`.
