
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(let* ((t_1 (* (* x PI) tau)))
(* (/ (sin t_1) t_1) (/ (sin (* x PI)) (* x PI)))))float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (sinf((x * ((float) M_PI))) / (x * ((float) M_PI)));
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi)))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (sin((x * single(pi))) / (x * single(pi))); end
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(let* ((t_1 (* (* x PI) tau)))
(* (/ (sin t_1) t_1) (/ (sin (* x PI)) (* x PI)))))float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (sinf((x * ((float) M_PI))) / (x * ((float) M_PI)));
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi)))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (sin((x * single(pi))) / (x * single(pi))); end
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(let* ((t_1 (* tau (* PI x))))
(/ (* (sin (* PI x)) (sin t_1)) (* t_1 (* PI x)))))float code(float x, float tau) {
float t_1 = tau * (((float) M_PI) * x);
return (sinf((((float) M_PI) * x)) * sinf(t_1)) / (t_1 * (((float) M_PI) * x));
}
function code(x, tau) t_1 = Float32(tau * Float32(Float32(pi) * x)) return Float32(Float32(sin(Float32(Float32(pi) * x)) * sin(t_1)) / Float32(t_1 * Float32(Float32(pi) * x))) end
function tmp = code(x, tau) t_1 = tau * (single(pi) * x); tmp = (sin((single(pi) * x)) * sin(t_1)) / (t_1 * (single(pi) * x)); end
\begin{array}{l}
t_1 := tau \cdot \left(\pi \cdot x\right)\\
\frac{\sin \left(\pi \cdot x\right) \cdot \sin t\_1}{t\_1 \cdot \left(\pi \cdot x\right)}
\end{array}
Initial program 97.9%
Applied rewrites97.7%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(let* ((t_1 (* tau (* PI x))))
(* (sin t_1) (/ (sin (* PI x)) (* t_1 (* PI x))))))float code(float x, float tau) {
float t_1 = tau * (((float) M_PI) * x);
return sinf(t_1) * (sinf((((float) M_PI) * x)) / (t_1 * (((float) M_PI) * x)));
}
function code(x, tau) t_1 = Float32(tau * Float32(Float32(pi) * x)) return Float32(sin(t_1) * Float32(sin(Float32(Float32(pi) * x)) / Float32(t_1 * Float32(Float32(pi) * x)))) end
function tmp = code(x, tau) t_1 = tau * (single(pi) * x); tmp = sin(t_1) * (sin((single(pi) * x)) / (t_1 * (single(pi) * x))); end
\begin{array}{l}
t_1 := tau \cdot \left(\pi \cdot x\right)\\
\sin t\_1 \cdot \frac{\sin \left(\pi \cdot x\right)}{t\_1 \cdot \left(\pi \cdot x\right)}
\end{array}
Initial program 97.9%
Applied rewrites97.6%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(*
(sin (* tau (* PI x)))
(/ (sin (* PI x)) (* tau (* (* PI x) (* PI x))))))float code(float x, float tau) {
return sinf((tau * (((float) M_PI) * x))) * (sinf((((float) M_PI) * x)) / (tau * ((((float) M_PI) * x) * (((float) M_PI) * x))));
}
function code(x, tau) return Float32(sin(Float32(tau * Float32(Float32(pi) * x))) * Float32(sin(Float32(Float32(pi) * x)) / Float32(tau * Float32(Float32(Float32(pi) * x) * Float32(Float32(pi) * x))))) end
function tmp = code(x, tau) tmp = sin((tau * (single(pi) * x))) * (sin((single(pi) * x)) / (tau * ((single(pi) * x) * (single(pi) * x)))); end
\sin \left(tau \cdot \left(\pi \cdot x\right)\right) \cdot \frac{\sin \left(\pi \cdot x\right)}{tau \cdot \left(\left(\pi \cdot x\right) \cdot \left(\pi \cdot x\right)\right)}
Initial program 97.9%
Applied rewrites97.6%
Applied rewrites97.3%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(/
(* (sin (* PI x)) (sin (* tau (* PI x))))
(* tau (* (* x x) 9.869604110717773))))float code(float x, float tau) {
return (sinf((((float) M_PI) * x)) * sinf((tau * (((float) M_PI) * x)))) / (tau * ((x * x) * 9.869604110717773f));
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(pi) * x)) * sin(Float32(tau * Float32(Float32(pi) * x)))) / Float32(tau * Float32(Float32(x * x) * Float32(9.869604110717773)))) end
function tmp = code(x, tau) tmp = (sin((single(pi) * x)) * sin((tau * (single(pi) * x)))) / (tau * ((x * x) * single(9.869604110717773))); end
\frac{\sin \left(\pi \cdot x\right) \cdot \sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{tau \cdot \left(\left(x \cdot x\right) \cdot 9.869604110717773\right)}
Initial program 97.9%
Applied rewrites97.7%
Applied rewrites97.3%
Applied rewrites96.8%
Evaluated real constant96.1%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(let* ((t_1 (* (* x PI) tau)))
(*
(/ (sin t_1) t_1)
(fma
(fma
(* PI PI)
-0.16666666666666666
(* 0.8117424249649048 (* x x)))
(* x x)
1.0))))float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * fmaf(fmaf((((float) M_PI) * ((float) M_PI)), -0.16666666666666666f, (0.8117424249649048f * (x * x))), (x * x), 1.0f);
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * fma(fma(Float32(Float32(pi) * Float32(pi)), Float32(-0.16666666666666666), Float32(Float32(0.8117424249649048) * Float32(x * x))), Float32(x * x), Float32(1.0))) end
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t\_1}{t\_1} \cdot \mathsf{fma}\left(\mathsf{fma}\left(\pi \cdot \pi, -0.16666666666666666, 0.8117424249649048 \cdot \left(x \cdot x\right)\right), x \cdot x, 1\right)
\end{array}
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites94.3%
Applied rewrites94.3%
Taylor expanded in x around 0
Applied rewrites91.5%
Evaluated real constant91.5%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(let* ((t_1 (* (* x PI) tau)))
(*
(/ (sin t_1) t_1)
(+ 1.0 (* (* (* x x) -0.16666666666666666) 9.869604110717773)))))float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (1.0f + (((x * x) * -0.16666666666666666f) * 9.869604110717773f));
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * Float32(Float32(1.0) + Float32(Float32(Float32(x * x) * Float32(-0.16666666666666666)) * Float32(9.869604110717773)))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (single(1.0) + (((x * x) * single(-0.16666666666666666)) * single(9.869604110717773))); end
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t\_1}{t\_1} \cdot \left(1 + \left(\left(x \cdot x\right) \cdot -0.16666666666666666\right) \cdot 9.869604110717773\right)
\end{array}
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites85.4%
Evaluated real constant85.4%
Applied rewrites85.4%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(let* ((t_1 (* (* x PI) tau)))
(*
(/ (sin t_1) t_1)
(fma (* (* x x) -0.16666666666666666) 9.869604110717773 1.0))))float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * fmaf(((x * x) * -0.16666666666666666f), 9.869604110717773f, 1.0f);
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * fma(Float32(Float32(x * x) * Float32(-0.16666666666666666)), Float32(9.869604110717773), Float32(1.0))) end
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t\_1}{t\_1} \cdot \mathsf{fma}\left(\left(x \cdot x\right) \cdot -0.16666666666666666, 9.869604110717773, 1\right)
\end{array}
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites85.4%
Evaluated real constant85.4%
Applied rewrites85.4%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(let* ((t_1 (* (* tau x) PI)))
(*
(fma (* -0.16666666666666666 (* x x)) 9.869604110717773 1.0)
(/ (sin t_1) t_1))))float code(float x, float tau) {
float t_1 = (tau * x) * ((float) M_PI);
return fmaf((-0.16666666666666666f * (x * x)), 9.869604110717773f, 1.0f) * (sinf(t_1) / t_1);
}
function code(x, tau) t_1 = Float32(Float32(tau * x) * Float32(pi)) return Float32(fma(Float32(Float32(-0.16666666666666666) * Float32(x * x)), Float32(9.869604110717773), Float32(1.0)) * Float32(sin(t_1) / t_1)) end
\begin{array}{l}
t_1 := \left(tau \cdot x\right) \cdot \pi\\
\mathsf{fma}\left(-0.16666666666666666 \cdot \left(x \cdot x\right), 9.869604110717773, 1\right) \cdot \frac{\sin t\_1}{t\_1}
\end{array}
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites85.4%
Applied rewrites85.4%
Evaluated real constant85.4%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(*
(sin (* tau (* PI x)))
(/ (fma -0.16666666666666666 (* x PI) (/ 1.0 (* x PI))) tau)))float code(float x, float tau) {
return sinf((tau * (((float) M_PI) * x))) * (fmaf(-0.16666666666666666f, (x * ((float) M_PI)), (1.0f / (x * ((float) M_PI)))) / tau);
}
function code(x, tau) return Float32(sin(Float32(tau * Float32(Float32(pi) * x))) * Float32(fma(Float32(-0.16666666666666666), Float32(x * Float32(pi)), Float32(Float32(1.0) / Float32(x * Float32(pi)))) / tau)) end
\sin \left(tau \cdot \left(\pi \cdot x\right)\right) \cdot \frac{\mathsf{fma}\left(-0.16666666666666666, x \cdot \pi, \frac{1}{x \cdot \pi}\right)}{tau}
Initial program 97.9%
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites84.7%
Applied rewrites84.7%
Taylor expanded in tau around 0
Applied rewrites84.9%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(+
1.0
(*
(*
-0.16666666666666666
(fma 9.869604110717773 (* tau tau) 9.869604110717773))
(* x x))))float code(float x, float tau) {
return 1.0f + ((-0.16666666666666666f * fmaf(9.869604110717773f, (tau * tau), 9.869604110717773f)) * (x * x));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(Float32(-0.16666666666666666) * fma(Float32(9.869604110717773), Float32(tau * tau), Float32(9.869604110717773))) * Float32(x * x))) end
1 + \left(-0.16666666666666666 \cdot \mathsf{fma}\left(9.869604110717773, tau \cdot tau, 9.869604110717773\right)\right) \cdot \left(x \cdot x\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Applied rewrites78.8%
Evaluated real constant78.8%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(fma
(*
-0.16666666666666666
(fma 9.869604110717773 (* tau tau) 9.869604110717773))
(* x x)
1.0))float code(float x, float tau) {
return fmaf((-0.16666666666666666f * fmaf(9.869604110717773f, (tau * tau), 9.869604110717773f)), (x * x), 1.0f);
}
function code(x, tau) return fma(Float32(Float32(-0.16666666666666666) * fma(Float32(9.869604110717773), Float32(tau * tau), Float32(9.869604110717773))), Float32(x * x), Float32(1.0)) end
\mathsf{fma}\left(-0.16666666666666666 \cdot \mathsf{fma}\left(9.869604110717773, tau \cdot tau, 9.869604110717773\right), x \cdot x, 1\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Applied rewrites78.8%
Evaluated real constant78.8%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(fma
(fma
(* (* tau tau) 9.869604110717773)
-0.16666666666666666
-1.6449340184529622)
(* x x)
1.0))float code(float x, float tau) {
return fmaf(fmaf(((tau * tau) * 9.869604110717773f), -0.16666666666666666f, -1.6449340184529622f), (x * x), 1.0f);
}
function code(x, tau) return fma(fma(Float32(Float32(tau * tau) * Float32(9.869604110717773)), Float32(-0.16666666666666666), Float32(-1.6449340184529622)), Float32(x * x), Float32(1.0)) end
\mathsf{fma}\left(\mathsf{fma}\left(\left(tau \cdot tau\right) \cdot 9.869604110717773, -0.16666666666666666, -1.6449340184529622\right), x \cdot x, 1\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Evaluated real constant78.8%
Applied rewrites78.8%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(fma
(* (* 9.869604110717773 (* tau tau)) -0.16666666666666666)
(* x x)
1.0))float code(float x, float tau) {
return fmaf(((9.869604110717773f * (tau * tau)) * -0.16666666666666666f), (x * x), 1.0f);
}
function code(x, tau) return fma(Float32(Float32(Float32(9.869604110717773) * Float32(tau * tau)) * Float32(-0.16666666666666666)), Float32(x * x), Float32(1.0)) end
\mathsf{fma}\left(\left(9.869604110717773 \cdot \left(tau \cdot tau\right)\right) \cdot -0.16666666666666666, x \cdot x, 1\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Taylor expanded in tau around inf
Applied rewrites69.8%
Applied rewrites69.8%
Evaluated real constant69.8%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(+ 1.0 (* -1.6449340184529622 (* (* tau tau) (* x x)))))float code(float x, float tau) {
return 1.0f + (-1.6449340184529622f * ((tau * tau) * (x * x)));
}
real(4) function code(x, tau)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: tau
code = 1.0e0 + ((-1.6449340184529622e0) * ((tau * tau) * (x * x)))
end function
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-1.6449340184529622) * Float32(Float32(tau * tau) * Float32(x * x)))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-1.6449340184529622) * ((tau * tau) * (x * x))); end
1 + -1.6449340184529622 \cdot \left(\left(tau \cdot tau\right) \cdot \left(x \cdot x\right)\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Evaluated real constant78.8%
Taylor expanded in tau around inf
Applied rewrites69.8%
Applied rewrites69.8%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(* 1.0 (fma (* x x) -1.644934058189392 1.0)))float code(float x, float tau) {
return 1.0f * fmaf((x * x), -1.644934058189392f, 1.0f);
}
function code(x, tau) return Float32(Float32(1.0) * fma(Float32(x * x), Float32(-1.644934058189392), Float32(1.0))) end
1 \cdot \mathsf{fma}\left(x \cdot x, -1.644934058189392, 1\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites64.4%
Taylor expanded in x around 0
Applied rewrites64.5%
Applied rewrites64.5%
Evaluated real constant64.5%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(+ 1.0 (* (* x x) -1.6449340184529622)))float code(float x, float tau) {
return 1.0f + ((x * x) * -1.6449340184529622f);
}
real(4) function code(x, tau)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: tau
code = 1.0e0 + ((x * x) * (-1.6449340184529622e0))
end function
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-1.6449340184529622))) end
function tmp = code(x, tau) tmp = single(1.0) + ((x * x) * single(-1.6449340184529622)); end
1 + \left(x \cdot x\right) \cdot -1.6449340184529622
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Evaluated real constant78.8%
Taylor expanded in tau around 0
Applied rewrites64.5%
Applied rewrites64.5%
herbie shell --seed 2026084
(FPCore (x tau)
:name "Lanczos kernel"
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0)) (and (<= 1.0 tau) (<= tau 5.0)))
(* (/ (sin (* (* x PI) tau)) (* (* x PI) tau)) (/ (sin (* x PI)) (* x PI))))