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