
(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 14 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 (* (* x PI) tau)) (t_2 (expm1 (log1p (* x PI))))) (* (/ (sin t_1) t_1) (/ (sin t_2) t_2))))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
float t_2 = expm1f(log1pf((x * ((float) M_PI))));
return (sinf(t_1) / t_1) * (sinf(t_2) / t_2);
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) t_2 = expm1(log1p(Float32(x * Float32(pi)))) return Float32(Float32(sin(t_1) / t_1) * Float32(sin(t_2) / t_2)) end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
t_2 := \mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \pi\right)\right)\\
\frac{\sin t_1}{t_1} \cdot \frac{\sin t_2}{t_2}
\end{array}
\end{array}
Initial program 97.8%
expm1-log1p-u97.8%
Applied egg-rr97.8%
expm1-log1p-u97.8%
Applied egg-rr97.8%
Final simplification97.8%
(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(x * Float32(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 := x \cdot \left(\pi \cdot tau\right)\\
\frac{\sin t_1}{t_1} \cdot \frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
\end{array}
Initial program 97.8%
Taylor expanded in x around inf 97.8%
*-commutative97.8%
associate-*r*97.2%
*-commutative97.2%
*-commutative97.2%
associate-*r*97.8%
*-commutative97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x tau) :precision binary32 (* (sin (* x PI)) (/ (/ (sin (* x (* PI tau))) (pow (* x PI) 2.0)) tau)))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) * ((sinf((x * (((float) M_PI) * tau))) / powf((x * ((float) M_PI)), 2.0f)) / tau);
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) * Float32(Float32(sin(Float32(x * Float32(Float32(pi) * tau))) / (Float32(x * Float32(pi)) ^ Float32(2.0))) / tau)) end
function tmp = code(x, tau) tmp = sin((x * single(pi))) * ((sin((x * (single(pi) * tau))) / ((x * single(pi)) ^ single(2.0))) / tau); end
\begin{array}{l}
\\
\sin \left(x \cdot \pi\right) \cdot \frac{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{{\left(x \cdot \pi\right)}^{2}}}{tau}
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
clear-num97.0%
frac-times97.1%
*-un-lft-identity97.1%
associate-*r*97.2%
*-commutative97.2%
associate-*r*97.2%
associate-*r*97.2%
pow297.2%
Applied egg-rr97.2%
Taylor expanded in x around inf 96.9%
*-commutative96.9%
associate-*r*97.1%
unpow297.1%
unpow297.1%
swap-sqr97.2%
unpow297.2%
*-commutative97.2%
associate-*l/97.1%
*-commutative97.1%
associate-/r*97.2%
Simplified97.2%
Final simplification97.2%
(FPCore (x tau) :precision binary32 (* (sin (* x PI)) (/ (sin (* (* x PI) tau)) (* tau (pow (* x PI) 2.0)))))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) * (sinf(((x * ((float) M_PI)) * tau)) / (tau * powf((x * ((float) M_PI)), 2.0f)));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) * Float32(sin(Float32(Float32(x * Float32(pi)) * tau)) / Float32(tau * (Float32(x * Float32(pi)) ^ Float32(2.0))))) end
function tmp = code(x, tau) tmp = sin((x * single(pi))) * (sin(((x * single(pi)) * tau)) / (tau * ((x * single(pi)) ^ single(2.0)))); end
\begin{array}{l}
\\
\sin \left(x \cdot \pi\right) \cdot \frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{tau \cdot {\left(x \cdot \pi\right)}^{2}}
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
clear-num97.0%
frac-times97.1%
*-un-lft-identity97.1%
associate-*r*97.2%
*-commutative97.2%
associate-*r*97.2%
associate-*r*97.2%
pow297.2%
Applied egg-rr97.2%
associate-*l/97.2%
associate-/r/97.1%
Applied egg-rr97.1%
Taylor expanded in x around inf 96.9%
*-commutative96.9%
unpow296.9%
unpow296.9%
swap-sqr97.4%
unpow297.4%
Simplified97.4%
Final simplification97.4%
(FPCore (x tau) :precision binary32 (/ (sin (* (* x PI) tau)) (* tau (/ (pow (* x PI) 2.0) (sin (* x PI))))))
float code(float x, float tau) {
return sinf(((x * ((float) M_PI)) * tau)) / (tau * (powf((x * ((float) M_PI)), 2.0f) / sinf((x * ((float) M_PI)))));
}
function code(x, tau) return Float32(sin(Float32(Float32(x * Float32(pi)) * tau)) / Float32(tau * Float32((Float32(x * Float32(pi)) ^ Float32(2.0)) / sin(Float32(x * Float32(pi)))))) end
function tmp = code(x, tau) tmp = sin(((x * single(pi)) * tau)) / (tau * (((x * single(pi)) ^ single(2.0)) / sin((x * single(pi))))); end
\begin{array}{l}
\\
\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{tau \cdot \frac{{\left(x \cdot \pi\right)}^{2}}{\sin \left(x \cdot \pi\right)}}
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
clear-num97.0%
frac-times97.1%
*-un-lft-identity97.1%
associate-*r*97.2%
*-commutative97.2%
associate-*r*97.2%
associate-*r*97.2%
pow297.2%
Applied egg-rr97.2%
Taylor expanded in x around inf 97.7%
Final simplification97.7%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (* x PI) tau))) (* (/ (sin t_1) t_1) (+ 1.0 (* (pow (* x PI) 2.0) -0.16666666666666666)))))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (1.0f + (powf((x * ((float) M_PI)), 2.0f) * -0.16666666666666666f));
}
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(x * Float32(pi)) ^ Float32(2.0)) * Float32(-0.16666666666666666)))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (single(1.0) + (((x * single(pi)) ^ single(2.0)) * single(-0.16666666666666666))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t_1}{t_1} \cdot \left(1 + {\left(x \cdot \pi\right)}^{2} \cdot -0.16666666666666666\right)
\end{array}
\end{array}
Initial program 97.8%
expm1-log1p-u97.8%
Applied egg-rr97.8%
Taylor expanded in x around 0 85.7%
unpow285.7%
unpow285.7%
swap-sqr85.7%
unpow285.7%
Simplified85.7%
Final simplification85.7%
(FPCore (x tau) :precision binary32 (* (fma -0.16666666666666666 (* x PI) (/ (/ 1.0 x) PI)) (/ (sin (* PI (* x tau))) tau)))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, (x * ((float) M_PI)), ((1.0f / x) / ((float) M_PI))) * (sinf((((float) M_PI) * (x * tau))) / tau);
}
function code(x, tau) return Float32(fma(Float32(-0.16666666666666666), Float32(x * Float32(pi)), Float32(Float32(Float32(1.0) / x) / Float32(pi))) * Float32(sin(Float32(Float32(pi) * Float32(x * tau))) / tau)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, x \cdot \pi, \frac{\frac{1}{x}}{\pi}\right) \cdot \frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{tau}
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in x around 0 85.0%
fma-def85.0%
associate-/r*85.1%
Simplified85.1%
Final simplification85.1%
(FPCore (x tau) :precision binary32 (* (/ (sin (* PI (* x tau))) tau) (+ (* (* x PI) -0.16666666666666666) (/ 1.0 (* x PI)))))
float code(float x, float tau) {
return (sinf((((float) M_PI) * (x * tau))) / tau) * (((x * ((float) M_PI)) * -0.16666666666666666f) + (1.0f / (x * ((float) M_PI))));
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(pi) * Float32(x * tau))) / tau) * Float32(Float32(Float32(x * Float32(pi)) * Float32(-0.16666666666666666)) + Float32(Float32(1.0) / Float32(x * Float32(pi))))) end
function tmp = code(x, tau) tmp = (sin((single(pi) * (x * tau))) / tau) * (((x * single(pi)) * single(-0.16666666666666666)) + (single(1.0) / (x * single(pi)))); end
\begin{array}{l}
\\
\frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{tau} \cdot \left(\left(x \cdot \pi\right) \cdot -0.16666666666666666 + \frac{1}{x \cdot \pi}\right)
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in x around 0 85.0%
Final simplification85.0%
(FPCore (x tau) :precision binary32 (* (/ (sin (* PI (* x tau))) tau) (/ 1.0 (* x PI))))
float code(float x, float tau) {
return (sinf((((float) M_PI) * (x * tau))) / tau) * (1.0f / (x * ((float) M_PI)));
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(pi) * Float32(x * tau))) / tau) * Float32(Float32(1.0) / Float32(x * Float32(pi)))) end
function tmp = code(x, tau) tmp = (sin((single(pi) * (x * tau))) / tau) * (single(1.0) / (x * single(pi))); end
\begin{array}{l}
\\
\frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{tau} \cdot \frac{1}{x \cdot \pi}
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in x around 0 72.0%
Final simplification72.0%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (* x PI) tau))) (/ (sin t_1) t_1)))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return sinf(t_1) / t_1;
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(sin(t_1) / t_1) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = sin(t_1) / t_1; end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 97.8%
expm1-log1p-u97.8%
Applied egg-rr97.8%
Taylor expanded in x around 0 72.3%
Final simplification72.3%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (* (pow x 2.0) (pow PI 2.0)))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * (powf(x, 2.0f) * powf(((float) M_PI), 2.0f)));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * Float32((x ^ Float32(2.0)) * (Float32(pi) ^ Float32(2.0))))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * ((x ^ single(2.0)) * (single(pi) ^ single(2.0)))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot \left({x}^{2} \cdot {\pi}^{2}\right)
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 66.3%
Taylor expanded in x around 0 66.7%
Final simplification66.7%
(FPCore (x tau) :precision binary32 (/ (sin (* x PI)) (* x PI)))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) / (x * ((float) M_PI));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi))) end
function tmp = code(x, tau) tmp = sin((x * single(pi))) / (x * single(pi)); end
\begin{array}{l}
\\
\frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 66.3%
Final simplification66.3%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (pow (* x PI) 2.0) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, powf((x * ((float) M_PI)), 2.0f), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), (Float32(x * Float32(pi)) ^ Float32(2.0)), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, {\left(x \cdot \pi\right)}^{2}, 1\right)
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 66.3%
Taylor expanded in x around 0 66.7%
+-commutative66.7%
fma-def66.7%
unpow266.7%
unpow266.7%
swap-sqr66.7%
unpow266.7%
Simplified66.7%
Final simplification66.7%
(FPCore (x tau) :precision binary32 (/ PI PI))
float code(float x, float tau) {
return ((float) M_PI) / ((float) M_PI);
}
function code(x, tau) return Float32(Float32(pi) / Float32(pi)) end
function tmp = code(x, tau) tmp = single(pi) / single(pi); end
\begin{array}{l}
\\
\frac{\pi}{\pi}
\end{array}
Initial program 97.8%
associate-*l/97.8%
*-commutative97.8%
times-frac97.5%
associate-/l/97.3%
associate-*l*97.1%
*-commutative97.1%
associate-*l*97.1%
Simplified97.1%
Taylor expanded in tau around 0 66.3%
add-log-exp66.0%
Applied egg-rr66.0%
rem-log-exp66.3%
associate-/r*66.2%
Applied egg-rr66.2%
Taylor expanded in x around 0 65.5%
Final simplification65.5%
herbie shell --seed 2023336
(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))))