
(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 12 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))) (* (/ (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}
Initial program 98.3%
Final simplification98.3%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* PI (* x tau)))) (* (/ (sin (* x PI)) (* x PI)) (/ (sin t_1) t_1))))
float code(float x, float tau) {
float t_1 = ((float) M_PI) * (x * tau);
return (sinf((x * ((float) M_PI))) / (x * ((float) M_PI))) * (sinf(t_1) / t_1);
}
function code(x, tau) t_1 = Float32(Float32(pi) * Float32(x * tau)) return Float32(Float32(sin(Float32(x * Float32(pi))) / Float32(x * Float32(pi))) * Float32(sin(t_1) / t_1)) end
function tmp = code(x, tau) t_1 = single(pi) * (x * tau); tmp = (sin((x * single(pi))) / (x * single(pi))) * (sin(t_1) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \pi \cdot \left(x \cdot tau\right)\\
\frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi} \cdot \frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 98.3%
*-commutative98.3%
associate-*l*97.8%
*-commutative97.8%
associate-*l*98.2%
Simplified98.2%
Final simplification98.2%
(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(sin(Float32(Float32(x * Float32(pi)) * tau)) * Float32((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 \left(\sin \left(\left(x \cdot \pi\right) \cdot tau\right) \cdot \frac{{\left(x \cdot \pi\right)}^{-2}}{tau}\right)
\end{array}
Initial program 98.3%
frac-times98.0%
*-commutative98.0%
*-commutative98.0%
associate-*l*97.4%
*-commutative97.4%
associate-*l*97.4%
pow297.4%
*-commutative97.4%
Applied egg-rr97.4%
div-inv97.4%
*-commutative97.4%
associate-*r*97.7%
*-commutative97.7%
associate-*l*97.6%
*-commutative97.6%
*-commutative97.6%
associate-/r*97.6%
Applied egg-rr97.7%
Final simplification97.7%
(FPCore (x tau) :precision binary32 (* (/ (sin (* (* x PI) tau)) tau) (/ (sin (* x PI)) (pow (* x PI) 2.0))))
float code(float x, float tau) {
return (sinf(((x * ((float) M_PI)) * tau)) / tau) * (sinf((x * ((float) M_PI))) / powf((x * ((float) M_PI)), 2.0f));
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(x * Float32(pi)) * tau)) / tau) * Float32(sin(Float32(x * Float32(pi))) / (Float32(x * Float32(pi)) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = (sin(((x * single(pi)) * tau)) / tau) * (sin((x * single(pi))) / ((x * single(pi)) ^ single(2.0))); end
\begin{array}{l}
\\
\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{tau} \cdot \frac{\sin \left(x \cdot \pi\right)}{{\left(x \cdot \pi\right)}^{2}}
\end{array}
Initial program 98.3%
Taylor expanded in x around inf 97.3%
times-frac97.2%
*-commutative97.2%
unpow297.2%
unpow297.2%
swap-sqr97.9%
unpow297.9%
*-commutative97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x tau) :precision binary32 (* (/ (sin (* (* x PI) tau)) tau) (+ (* (* x PI) -0.16666666666666666) (/ 1.0 (* x PI)))))
float code(float x, float tau) {
return (sinf(((x * ((float) M_PI)) * tau)) / tau) * (((x * ((float) M_PI)) * -0.16666666666666666f) + (1.0f / (x * ((float) M_PI))));
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(x * Float32(pi)) * 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(((x * single(pi)) * tau)) / tau) * (((x * single(pi)) * single(-0.16666666666666666)) + (single(1.0) / (x * single(pi)))); end
\begin{array}{l}
\\
\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{tau} \cdot \left(\left(x \cdot \pi\right) \cdot -0.16666666666666666 + \frac{1}{x \cdot \pi}\right)
\end{array}
Initial program 98.3%
Taylor expanded in x around inf 97.3%
times-frac97.2%
*-commutative97.2%
unpow297.2%
unpow297.2%
swap-sqr97.9%
unpow297.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in x around 0 86.5%
Final simplification86.5%
(FPCore (x tau) :precision binary32 (* (/ (sin (* (* x PI) tau)) tau) (/ 1.0 (* x PI))))
float code(float x, float tau) {
return (sinf(((x * ((float) M_PI)) * tau)) / tau) * (1.0f / (x * ((float) M_PI)));
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(x * Float32(pi)) * tau)) / tau) * Float32(Float32(1.0) / Float32(x * Float32(pi)))) end
function tmp = code(x, tau) tmp = (sin(((x * single(pi)) * tau)) / tau) * (single(1.0) / (x * single(pi))); end
\begin{array}{l}
\\
\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{tau} \cdot \frac{1}{x \cdot \pi}
\end{array}
Initial program 98.3%
Taylor expanded in x around inf 97.3%
times-frac97.2%
*-commutative97.2%
unpow297.2%
unpow297.2%
swap-sqr97.9%
unpow297.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in x around 0 71.5%
Final simplification71.5%
(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 98.3%
*-commutative98.3%
associate-*l*97.8%
*-commutative97.8%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in x around 0 71.5%
Final simplification71.5%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (pow (* (* x PI) tau) 2.0) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, powf(((x * ((float) M_PI)) * tau), 2.0f), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), (Float32(Float32(x * Float32(pi)) * tau) ^ Float32(2.0)), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, {\left(\left(x \cdot \pi\right) \cdot tau\right)}^{2}, 1\right)
\end{array}
Initial program 98.3%
*-commutative98.3%
associate-*l*97.8%
*-commutative97.8%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in x around 0 81.1%
+-commutative81.1%
fma-def81.1%
*-commutative81.1%
associate-*l*81.1%
unpow281.1%
unpow281.1%
unpow281.1%
unswap-sqr81.1%
swap-sqr81.1%
unpow281.1%
associate-*r*81.1%
*-commutative81.1%
*-commutative81.1%
*-commutative81.1%
Simplified81.1%
Taylor expanded in x around 0 70.8%
Final simplification70.8%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (pow (* PI (* x tau)) 2.0) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, powf((((float) M_PI) * (x * tau)), 2.0f), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), (Float32(Float32(pi) * Float32(x * tau)) ^ Float32(2.0)), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, {\left(\pi \cdot \left(x \cdot tau\right)\right)}^{2}, 1\right)
\end{array}
Initial program 98.3%
*-commutative98.3%
associate-*l*97.8%
*-commutative97.8%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in x around 0 81.1%
+-commutative81.1%
fma-def81.1%
*-commutative81.1%
associate-*l*81.1%
unpow281.1%
unpow281.1%
unpow281.1%
unswap-sqr81.1%
swap-sqr81.1%
unpow281.1%
associate-*r*81.1%
*-commutative81.1%
*-commutative81.1%
*-commutative81.1%
Simplified81.1%
Taylor expanded in x around 0 70.8%
Taylor expanded in tau around 0 70.8%
*-commutative70.8%
unpow270.8%
unpow270.8%
swap-sqr70.8%
unpow270.8%
swap-sqr70.8%
*-commutative70.8%
associate-*r*70.8%
*-commutative70.8%
associate-*r*70.8%
unpow270.8%
Simplified70.8%
Final simplification70.8%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (pow (* (* x PI) tau) 2.0))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * powf(((x * ((float) M_PI)) * tau), 2.0f));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * (Float32(Float32(x * Float32(pi)) * tau) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * (((x * single(pi)) * tau) ^ single(2.0))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot {\left(\left(x \cdot \pi\right) \cdot tau\right)}^{2}
\end{array}
Initial program 98.3%
*-commutative98.3%
associate-*l*97.8%
*-commutative97.8%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in x around 0 81.1%
+-commutative81.1%
fma-def81.1%
*-commutative81.1%
associate-*l*81.1%
unpow281.1%
unpow281.1%
unpow281.1%
unswap-sqr81.1%
swap-sqr81.1%
unpow281.1%
associate-*r*81.1%
*-commutative81.1%
*-commutative81.1%
*-commutative81.1%
Simplified81.1%
Taylor expanded in x around 0 70.8%
fma-udef70.8%
Applied egg-rr70.8%
Final simplification70.8%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (pow (* x PI) 2.0))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * powf((x * ((float) M_PI)), 2.0f));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * (Float32(x * Float32(pi)) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * ((x * single(pi)) ^ single(2.0))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot {\left(x \cdot \pi\right)}^{2}
\end{array}
Initial program 98.3%
Taylor expanded in tau around 0 64.7%
Taylor expanded in x around 0 65.1%
+-commutative65.1%
fma-def65.1%
*-commutative65.1%
unpow265.1%
unpow265.1%
swap-sqr65.1%
unpow265.1%
*-commutative65.1%
Simplified65.1%
fma-udef65.1%
*-commutative65.1%
*-commutative65.1%
Applied egg-rr65.1%
Final simplification65.1%
(FPCore (x tau) :precision binary32 1.0)
float code(float x, float tau) {
return 1.0f;
}
real(4) function code(x, tau)
real(4), intent (in) :: x
real(4), intent (in) :: tau
code = 1.0e0
end function
function code(x, tau) return Float32(1.0) end
function tmp = code(x, tau) tmp = single(1.0); end
\begin{array}{l}
\\
1
\end{array}
Initial program 98.3%
associate-*l/98.2%
associate-/l*98.3%
associate-*l*97.6%
associate-*l*98.1%
*-commutative98.1%
*-commutative98.1%
Applied egg-rr98.1%
Taylor expanded in x around 0 63.9%
Final simplification63.9%
herbie shell --seed 2023334
(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))))