
(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 18 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 (* (- (- x)) (* tau PI))))
(* (/ (sin t_1) t_1) (/ (sin (* x PI)) (* x PI)))))float code(float x, float tau) {
float t_1 = -(-x) * (tau * ((float) M_PI));
return (sinf(t_1) / t_1) * (sinf((x * ((float) M_PI))) / (x * ((float) M_PI)));
}
function code(x, tau) t_1 = Float32(Float32(-Float32(-x)) * Float32(tau * Float32(pi))) 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) * (tau * single(pi)); tmp = (sin(t_1) / t_1) * (sin((x * single(pi))) / (x * single(pi))); end
\begin{array}{l}
t_1 := \left(-\left(-x\right)\right) \cdot \left(tau \cdot \pi\right)\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
Initial program 97.9%
Applied rewrites97.9%
(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)))
(* (/ (sin t_1) t_1) (/ (sin (* x PI)) (* x PI)))))float code(float x, float tau) {
float t_1 = (tau * x) * ((float) M_PI);
return (sinf(t_1) / t_1) * (sinf((x * ((float) M_PI))) / (x * ((float) M_PI)));
}
function code(x, tau) t_1 = Float32(Float32(tau * x) * Float32(pi)) 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 = (tau * x) * single(pi); tmp = (sin(t_1) / t_1) * (sin((x * single(pi))) / (x * single(pi))); end
\begin{array}{l}
t_1 := \left(tau \cdot x\right) \cdot \pi\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
Initial program 97.9%
Applied rewrites97.9%
(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) (* t_1 (* PI x))) (sin (* PI x)))))float code(float x, float tau) {
float t_1 = (tau * ((float) M_PI)) * x;
return (sinf(t_1) / (t_1 * (((float) M_PI) * x))) * sinf((((float) M_PI) * x));
}
function code(x, tau) t_1 = Float32(Float32(tau * Float32(pi)) * x) return Float32(Float32(sin(t_1) / Float32(t_1 * Float32(Float32(pi) * x))) * sin(Float32(Float32(pi) * x))) end
function tmp = code(x, tau) t_1 = (tau * single(pi)) * x; tmp = (sin(t_1) / (t_1 * (single(pi) * x))) * sin((single(pi) * x)); end
\begin{array}{l}
t_1 := \left(tau \cdot \pi\right) \cdot x\\
\frac{\sin t\_1}{t\_1 \cdot \left(\pi \cdot x\right)} \cdot \sin \left(\pi \cdot x\right)
\end{array}
Initial program 97.9%
Applied rewrites97.7%
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) (* t_1 (* PI x))) (sin (* PI x)))))float code(float x, float tau) {
float t_1 = tau * (((float) M_PI) * x);
return (sinf(t_1) / (t_1 * (((float) M_PI) * x))) * sinf((((float) M_PI) * x));
}
function code(x, tau) t_1 = Float32(tau * Float32(Float32(pi) * x)) return Float32(Float32(sin(t_1) / Float32(t_1 * Float32(Float32(pi) * x))) * sin(Float32(Float32(pi) * x))) end
function tmp = code(x, tau) t_1 = tau * (single(pi) * x); tmp = (sin(t_1) / (t_1 * (single(pi) * x))) * sin((single(pi) * x)); end
\begin{array}{l}
t_1 := tau \cdot \left(\pi \cdot x\right)\\
\frac{\sin t\_1}{t\_1 \cdot \left(\pi \cdot x\right)} \cdot \sin \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)))
(*
(/ (sin (* tau (* PI x))) (* tau (* (* PI x) (* PI x))))
(sin (* PI x))))float code(float x, float tau) {
return (sinf((tau * (((float) M_PI) * x))) / (tau * ((((float) M_PI) * x) * (((float) M_PI) * x)))) * sinf((((float) M_PI) * x));
}
function code(x, tau) return Float32(Float32(sin(Float32(tau * Float32(Float32(pi) * x))) / Float32(tau * Float32(Float32(Float32(pi) * x) * Float32(Float32(pi) * x)))) * sin(Float32(Float32(pi) * x))) end
function tmp = code(x, tau) tmp = (sin((tau * (single(pi) * x))) / (tau * ((single(pi) * x) * (single(pi) * x)))) * sin((single(pi) * x)); end
\frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{tau \cdot \left(\left(\pi \cdot x\right) \cdot \left(\pi \cdot x\right)\right)} \cdot \sin \left(\pi \cdot x\right)
Initial program 97.9%
Applied rewrites97.7%
Applied rewrites97.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))) (* tau (* PI (* (* PI x) x))))
(sin (* PI x))))float code(float x, float tau) {
return (sinf((tau * (((float) M_PI) * x))) / (tau * (((float) M_PI) * ((((float) M_PI) * x) * x)))) * sinf((((float) M_PI) * x));
}
function code(x, tau) return Float32(Float32(sin(Float32(tau * Float32(Float32(pi) * x))) / Float32(tau * Float32(Float32(pi) * Float32(Float32(Float32(pi) * x) * x)))) * sin(Float32(Float32(pi) * x))) end
function tmp = code(x, tau) tmp = (sin((tau * (single(pi) * x))) / (tau * (single(pi) * ((single(pi) * x) * x)))) * sin((single(pi) * x)); end
\frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{tau \cdot \left(\pi \cdot \left(\left(\pi \cdot x\right) \cdot x\right)\right)} \cdot \sin \left(\pi \cdot x\right)
Initial program 97.9%
Applied rewrites97.7%
Applied rewrites97.4%
Applied rewrites97.2%
(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))) (* tau (* 9.869604110717773 (* x x))))
(sin (* PI x))))float code(float x, float tau) {
return (sinf((tau * (((float) M_PI) * x))) / (tau * (9.869604110717773f * (x * x)))) * sinf((((float) M_PI) * x));
}
function code(x, tau) return Float32(Float32(sin(Float32(tau * Float32(Float32(pi) * x))) / Float32(tau * Float32(Float32(9.869604110717773) * Float32(x * x)))) * sin(Float32(Float32(pi) * x))) end
function tmp = code(x, tau) tmp = (sin((tau * (single(pi) * x))) / (tau * (single(9.869604110717773) * (x * x)))) * sin((single(pi) * x)); end
\frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{tau \cdot \left(9.869604110717773 \cdot \left(x \cdot x\right)\right)} \cdot \sin \left(\pi \cdot x\right)
Initial program 97.9%
Applied rewrites97.7%
Applied rewrites97.4%
Applied rewrites96.9%
Evaluated real constant96.2%
(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)))
(* (/ (sin t_1) t_1) (fma -1.6449340184529622 (* x x) 1.0))))float code(float x, float tau) {
float t_1 = (tau * x) * ((float) M_PI);
return (sinf(t_1) / t_1) * fmaf(-1.6449340184529622f, (x * x), 1.0f);
}
function code(x, tau) t_1 = Float32(Float32(tau * x) * Float32(pi)) return Float32(Float32(sin(t_1) / t_1) * fma(Float32(-1.6449340184529622), Float32(x * x), Float32(1.0))) end
\begin{array}{l}
t_1 := \left(tau \cdot x\right) \cdot \pi\\
\frac{\sin t\_1}{t\_1} \cdot \mathsf{fma}\left(-1.6449340184529622, x \cdot x, 1\right)
\end{array}
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites85.3%
Evaluated real constant85.3%
Applied rewrites85.3%
Applied rewrites85.3%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(*
(fma -0.16666666666666666 (* (* (* tau tau) x) PI) (/ 1.0 (* x PI)))
(sin (* PI x))))float code(float x, float tau) {
return fmaf(-0.16666666666666666f, (((tau * tau) * x) * ((float) M_PI)), (1.0f / (x * ((float) M_PI)))) * sinf((((float) M_PI) * x));
}
function code(x, tau) return Float32(fma(Float32(-0.16666666666666666), Float32(Float32(Float32(tau * tau) * x) * Float32(pi)), Float32(Float32(1.0) / Float32(x * Float32(pi)))) * sin(Float32(Float32(pi) * x))) end
\mathsf{fma}\left(-0.16666666666666666, \left(\left(tau \cdot tau\right) \cdot x\right) \cdot \pi, \frac{1}{x \cdot \pi}\right) \cdot \sin \left(\pi \cdot x\right)
Initial program 97.9%
Applied rewrites97.7%
Taylor expanded in tau around 0
Applied rewrites79.3%
Applied rewrites79.3%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(fma
(fma
(* 9.869604110717773 (* tau tau))
-0.16666666666666666
-1.6449340184529622)
(* x x)
1.0))float code(float x, float tau) {
return fmaf(fmaf((9.869604110717773f * (tau * tau)), -0.16666666666666666f, -1.6449340184529622f), (x * x), 1.0f);
}
function code(x, tau) return fma(fma(Float32(Float32(9.869604110717773) * Float32(tau * tau)), Float32(-0.16666666666666666), Float32(-1.6449340184529622)), Float32(x * x), Float32(1.0)) end
\mathsf{fma}\left(\mathsf{fma}\left(9.869604110717773 \cdot \left(tau \cdot tau\right), -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
(*
-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
-0.16666666666666666
(* (fma (* tau tau) 9.869604110717773 9.869604110717773) (* x x))
1.0))float code(float x, float tau) {
return fmaf(-0.16666666666666666f, (fmaf((tau * tau), 9.869604110717773f, 9.869604110717773f) * (x * x)), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), Float32(fma(Float32(tau * tau), Float32(9.869604110717773), Float32(9.869604110717773)) * Float32(x * x)), Float32(1.0)) end
\mathsf{fma}\left(-0.16666666666666666, \mathsf{fma}\left(tau \cdot tau, 9.869604110717773, 9.869604110717773\right) \cdot \left(x \cdot x\right), 1\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Evaluated real constant78.8%
Applied rewrites78.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 (* -1.6449340184529622 (* tau tau)) (* x x) 1.0))float code(float x, float tau) {
return fmaf((-1.6449340184529622f * (tau * tau)), (x * x), 1.0f);
}
function code(x, tau) return fma(Float32(Float32(-1.6449340184529622) * Float32(tau * tau)), Float32(x * x), Float32(1.0)) end
\mathsf{fma}\left(-1.6449340184529622 \cdot \left(tau \cdot tau\right), x \cdot x, 1\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 (* -1.644934058189392 (* x x))))float code(float x, float tau) {
return 1.0f + (-1.644934058189392f * (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.644934058189392e0) * (x * x))
end function
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-1.644934058189392) * Float32(x * x))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-1.644934058189392) * (x * x)); end
1 + -1.644934058189392 \cdot \left(x \cdot x\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Taylor expanded in tau around 0
Applied rewrites64.6%
Applied rewrites64.6%
Evaluated real constant64.6%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(fma -1.644934058189392 (* x x) 1.0))float code(float x, float tau) {
return fmaf(-1.644934058189392f, (x * x), 1.0f);
}
function code(x, tau) return fma(Float32(-1.644934058189392), Float32(x * x), Float32(1.0)) end
\mathsf{fma}\left(-1.644934058189392, x \cdot x, 1\right)
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites78.8%
Taylor expanded in tau around 0
Applied rewrites64.6%
Applied rewrites64.6%
Evaluated real constant64.6%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(/ (* -1.0 tau) (- tau)))float code(float x, float tau) {
return (-1.0f * tau) / -tau;
}
real(4) function code(x, tau)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: tau
code = ((-1.0e0) * tau) / -tau
end function
function code(x, tau) return Float32(Float32(Float32(-1.0) * tau) / Float32(-tau)) end
function tmp = code(x, tau) tmp = (single(-1.0) * tau) / -tau; end
\frac{-1 \cdot tau}{-tau}
Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites85.3%
Applied rewrites84.6%
Applied rewrites84.6%
Taylor expanded in x around 0
Applied rewrites63.6%
(FPCore (x tau)
:precision binary32
:pre (and (and (<= 1e-5 x) (<= x 1.0))
(and (<= 1.0 tau) (<= tau 5.0)))
(* (/ 1.0 tau) tau))float code(float x, float tau) {
return (1.0f / tau) * tau;
}
real(4) function code(x, tau)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: tau
code = (1.0e0 / tau) * tau
end function
function code(x, tau) return Float32(Float32(Float32(1.0) / tau) * tau) end
function tmp = code(x, tau) tmp = (single(1.0) / tau) * tau; end
\frac{1}{tau} \cdot tau
Initial program 97.9%
Applied rewrites97.7%
Taylor expanded in x around 0
Applied rewrites70.9%
Taylor expanded in x around 0
Applied rewrites63.6%
herbie shell --seed 2026070
(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))))