Approximate e^x

前端 未结 10 2150
一向
一向 2020-12-13 16:28

I\'d like to approximate the ex function.

Is it possible to do so using multiple splines type based approach? i.e between x1

10条回答
  •  生来不讨喜
    2020-12-13 16:35

    This is not the smooth spline interpolation you requested but its computationally efficient:

    float expf_fast(float x) {
       union { float f; int i; } y;
       y.i = (int)(x * 0xB5645F + 0x3F7893F5);
       return (y.f);
    }
    

    Plot Output image

提交回复
热议问题