
(FPCore (x tau) :precision binary32 (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}
\\
\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}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x tau) :precision binary32 (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}
\\
\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}
\end{array}
(FPCore (x tau) :precision binary32 (let* ((t_1 (* PI (* x tau)))) (* (/ (sin t_1) t_1) (/ (sin (* PI x)) (* PI x)))))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
return (sinf(t_1) / t_1) * (sinf((((float) M_PI) * x)) / (((float) M_PI) * x));
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x))) end
function tmp = code(x, tau) t_1 = single(pi) * (x * tau); tmp = (sin(t_1) / t_1) * (sin((single(pi) * x)) / (single(pi) * x)); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
\frac{\sin t_1}{t_1} \cdot \frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x}
\end{array}
\end{array}
Initial program 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x tau) :precision binary32 (* (/ (sin (* PI x)) (* PI x)) (/ (sin (* tau (* PI x))) (* PI (* x tau)))))
float code(float x, float tau) {
return (sinf((((float) M_PI) * x)) / (((float) M_PI) * x)) * (sinf((tau * (((float) M_PI) * x))) / (((float) M_PI) * (x * tau)));
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x)) * Float32(sin(Float32(tau * Float32(Float32(pi) * x))) / Float32(Float32(pi) * Float32(x * tau)))) end
function tmp = code(x, tau) tmp = (sin((single(pi) * x)) / (single(pi) * x)) * (sin((tau * (single(pi) * x))) / (single(pi) * (x * tau))); end
\begin{array}{l}
\\
\frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin \left(tau \cdot \left(\pi \cdot x\right)\right)}{\pi \cdot \left(x \cdot tau\right)}
\end{array}
Initial program 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.0%
Simplified98.0%
Taylor expanded in x around inf 97.2%
Final simplification97.2%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (* PI tau)))) (* (/ (sin (* PI x)) (* PI x)) (/ (sin t_1) t_1))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return (sinf((((float) M_PI) * x)) / (((float) M_PI) * x)) * (sinf(t_1) / t_1);
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(Float32(sin(Float32(Float32(pi) * x)) / Float32(Float32(pi) * x)) * Float32(sin(t_1) / t_1)) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = (sin((single(pi) * x)) / (single(pi) * x)) * (sin(t_1) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin \left(\pi \cdot x\right)}{\pi \cdot x} \cdot \frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 97.9%
associate-*l*97.4%
associate-*l*97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x tau) :precision binary32 (* (fma -0.16666666666666666 (pow (* tau (* PI x)) 2.0) 1.0) (/ (/ (sin (* PI x)) x) PI)))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, powf((tau * (((float) M_PI) * x)), 2.0f), 1.0f) * ((sinf((((float) M_PI) * x)) / x) / ((float) M_PI));
}
function code(x, tau) return Float32(fma(Float32(-0.16666666666666666), (Float32(tau * Float32(Float32(pi) * x)) ^ Float32(2.0)), Float32(1.0)) * Float32(Float32(sin(Float32(Float32(pi) * x)) / x) / Float32(pi))) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, {\left(tau \cdot \left(\pi \cdot x\right)\right)}^{2}, 1\right) \cdot \frac{\frac{\sin \left(\pi \cdot x\right)}{x}}{\pi}
\end{array}
Initial program 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.0%
Simplified98.0%
associate-/r*97.8%
div-inv97.8%
Applied egg-rr97.8%
un-div-inv97.8%
Applied egg-rr97.8%
Taylor expanded in x around 0 79.3%
+-commutative79.3%
fma-def79.3%
*-commutative79.3%
unpow279.3%
unpow279.3%
swap-sqr79.3%
unpow279.3%
swap-sqr79.3%
associate-*r*79.3%
associate-*r*79.3%
unpow279.3%
associate-*r*79.3%
Simplified79.3%
Final simplification79.3%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* PI (* x tau)))) (/ (sin t_1) t_1)))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
return sinf(t_1) / t_1;
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) return Float32(sin(t_1) / t_1) end
function tmp = code(x, tau) t_1 = single(pi) * (x * tau); tmp = sin(t_1) / t_1; end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
\frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 97.9%
*-commutative97.9%
associate-*l*97.2%
*-commutative97.2%
associate-*l*98.0%
Simplified98.0%
associate-/r*97.8%
div-inv97.8%
Applied egg-rr97.8%
Taylor expanded in x around 0 71.2%
Final simplification71.2%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (* PI (* x (* PI x))) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, (((float) M_PI) * (x * (((float) M_PI) * x))), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), Float32(Float32(pi) * Float32(x * Float32(Float32(pi) * x))), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, \pi \cdot \left(x \cdot \left(\pi \cdot x\right)\right), 1\right)
\end{array}
Initial program 97.9%
associate-*l*97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 64.9%
Taylor expanded in x around 0 65.0%
+-commutative65.0%
fma-def65.0%
unpow265.0%
unpow265.0%
swap-sqr65.0%
unpow265.0%
Simplified65.0%
unpow265.0%
associate-*r*65.0%
Applied egg-rr65.0%
Final simplification65.0%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (pow (* PI x) 2.0) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, powf((((float) M_PI) * x), 2.0f), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), (Float32(Float32(pi) * x) ^ Float32(2.0)), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, {\left(\pi \cdot x\right)}^{2}, 1\right)
\end{array}
Initial program 97.9%
associate-*l*97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 64.9%
Taylor expanded in x around 0 65.0%
+-commutative65.0%
fma-def65.0%
unpow265.0%
unpow265.0%
swap-sqr65.0%
unpow265.0%
Simplified65.0%
Final simplification65.0%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (pow (* PI x) 2.0))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * powf((((float) M_PI) * x), 2.0f));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * (Float32(Float32(pi) * x) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * ((single(pi) * x) ^ single(2.0))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot {\left(\pi \cdot x\right)}^{2}
\end{array}
Initial program 97.9%
associate-*l*97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 64.9%
Taylor expanded in x around 0 65.0%
+-commutative65.0%
fma-def65.0%
unpow265.0%
unpow265.0%
swap-sqr65.0%
unpow265.0%
Simplified65.0%
fma-udef65.0%
*-commutative65.0%
Applied egg-rr65.0%
Final simplification65.0%
(FPCore (x tau) :precision binary32 (* -0.16666666666666666 (pow (* PI x) 2.0)))
float code(float x, float tau) {
return -0.16666666666666666f * powf((((float) M_PI) * x), 2.0f);
}
function code(x, tau) return Float32(Float32(-0.16666666666666666) * (Float32(Float32(pi) * x) ^ Float32(2.0))) end
function tmp = code(x, tau) tmp = single(-0.16666666666666666) * ((single(pi) * x) ^ single(2.0)); end
\begin{array}{l}
\\
-0.16666666666666666 \cdot {\left(\pi \cdot x\right)}^{2}
\end{array}
Initial program 97.9%
associate-*l*97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 64.9%
Taylor expanded in x around 0 65.0%
+-commutative65.0%
fma-def65.0%
unpow265.0%
unpow265.0%
swap-sqr65.0%
unpow265.0%
Simplified65.0%
Taylor expanded in x around inf 4.0%
unpow24.0%
unpow24.0%
swap-sqr4.0%
unpow24.0%
Simplified4.0%
Final simplification4.0%
(FPCore (x tau) :precision binary32 (/ (* PI x) (* PI x)))
float code(float x, float tau) {
return (((float) M_PI) * x) / (((float) M_PI) * x);
}
function code(x, tau) return Float32(Float32(Float32(pi) * x) / Float32(Float32(pi) * x)) end
function tmp = code(x, tau) tmp = (single(pi) * x) / (single(pi) * x); end
\begin{array}{l}
\\
\frac{\pi \cdot x}{\pi \cdot x}
\end{array}
Initial program 97.9%
associate-*l*97.4%
associate-*l*97.9%
Simplified97.9%
Taylor expanded in x around 0 64.9%
Taylor expanded in x around 0 64.1%
Final simplification64.1%
herbie shell --seed 2023333
(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))))