# Linear Interpolation that is independent of frame rate

In this Tutorial (Linear Interpolation - Unity Learn)
, the last example is this:

``````> void Update () {
>     light.intensity = Mathf.Lerp(light.intensity, 8f, 0.5f *
> Time.deltaTime); }
``````

From what I understand, this code example does not do 50% interpolation per second.

How can I do a Linear Interpolation that is dependent on time (not frame rate) and is 50%?

Your use of lerp is not a linear interpolation over time. Time.deltaTime can only be used to compensate linear processes. Taking 50% of the remaining is not a linear process but an exponential process. This can not be compensated with a linear factor as each iteration has a different effect on the outcome. Linear functions have a constant derivative while exponential functions usually have an exponential derivative.

To actually calculate the factor needed every frame to achieve a 50% drop per second you would need to take the “n-th” root of “0.5” where n is the current framerate. For example at a framerate of 60 frames per second you would calculate the “60th” root of 0.5 which is about “0.988514”. If you multiply a value by this factor 60 times you effectively have multiplied it by 0.5. However calculating the "1/deltaTime"th root of your desired factor is a quite expensive operation. Specifically using `Mathf.Pow(0.5f, Time.deltaTime);`

The example given on the page you linked is actually a really bad example usage for lerp. If you want a gradually slowed down interpolation from the current value towards a target you want to use Mathf.SmoothDamp just like they mention at the very bottom of the page you linked.

``````private float speed = 0;
void Update()
{
light.intensity = Mathf.SmoothDamp(light.intensity, 8f, ref speed, 10f);
}
``````

Note that this will bring the intensity to the value of “8” within 10 seconds. Also note that the speed variable is controlled by the SmoothDamp function and is used to save the state of the velocity between frames. You shouldn’t set this value manually. Just make sure you have an actual variable that persists between two frames.