
(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 13 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 97.9%
Final simplification97.9%
(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.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
*-commutative97.0%
associate-*r/97.1%
associate-*r*97.1%
*-commutative97.1%
associate-*r*97.1%
associate-*r*97.3%
pow297.3%
Applied egg-rr97.3%
Taylor expanded in x around inf 96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
associate-*r*96.9%
associate-*r/97.0%
unpow297.0%
unpow297.0%
swap-sqr97.2%
unpow297.2%
Simplified97.4%
Final simplification97.4%
(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.9%
*-un-lft-identity97.9%
times-frac97.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 82.3%
unpow282.3%
unpow282.3%
swap-sqr82.3%
unpow282.3%
Simplified82.3%
Final simplification82.3%
(FPCore (x tau) :precision binary32 (* (+ (* (* x PI) -0.16666666666666666) (/ 1.0 (* x PI))) (/ (sin (* x (* PI tau))) tau)))
float code(float x, float tau) {
return (((x * ((float) M_PI)) * -0.16666666666666666f) + (1.0f / (x * ((float) M_PI)))) * (sinf((x * (((float) M_PI) * tau))) / tau);
}
function code(x, tau) return Float32(Float32(Float32(Float32(x * Float32(pi)) * Float32(-0.16666666666666666)) + Float32(Float32(1.0) / Float32(x * Float32(pi)))) * Float32(sin(Float32(x * Float32(Float32(pi) * tau))) / tau)) end
function tmp = code(x, tau) tmp = (((x * single(pi)) * single(-0.16666666666666666)) + (single(1.0) / (x * single(pi)))) * (sin((x * (single(pi) * tau))) / tau); end
\begin{array}{l}
\\
\left(\left(x \cdot \pi\right) \cdot -0.16666666666666666 + \frac{1}{x \cdot \pi}\right) \cdot \frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau}
\end{array}
Initial program 97.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 81.6%
Taylor expanded in x around 0 81.8%
*-commutative81.8%
associate-*r*81.8%
*-commutative81.8%
Simplified81.8%
Final simplification81.8%
(FPCore (x tau) :precision binary32 (/ (* (sin (* (* x PI) tau)) (+ (* (* x PI) -0.16666666666666666) (/ 1.0 (* x PI)))) tau))
float code(float x, float tau) {
return (sinf(((x * ((float) M_PI)) * tau)) * (((x * ((float) M_PI)) * -0.16666666666666666f) + (1.0f / (x * ((float) M_PI))))) / tau;
}
function code(x, tau) return Float32(Float32(sin(Float32(Float32(x * Float32(pi)) * tau)) * Float32(Float32(Float32(x * Float32(pi)) * Float32(-0.16666666666666666)) + Float32(Float32(1.0) / Float32(x * Float32(pi))))) / tau) end
function tmp = code(x, tau) tmp = (sin(((x * single(pi)) * tau)) * (((x * single(pi)) * single(-0.16666666666666666)) + (single(1.0) / (x * single(pi))))) / tau; end
\begin{array}{l}
\\
\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right) \cdot \left(\left(x \cdot \pi\right) \cdot -0.16666666666666666 + \frac{1}{x \cdot \pi}\right)}{tau}
\end{array}
Initial program 97.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 81.6%
Taylor expanded in tau around inf 81.8%
Final simplification81.8%
(FPCore (x tau) :precision binary32 (+ 1.0 (* (* -0.16666666666666666 (pow x 2.0)) (pow (* PI (hypot 1.0 tau)) 2.0))))
float code(float x, float tau) {
return 1.0f + ((-0.16666666666666666f * powf(x, 2.0f)) * powf((((float) M_PI) * hypotf(1.0f, tau)), 2.0f));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(2.0))) * (Float32(Float32(pi) * hypot(Float32(1.0), tau)) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = single(1.0) + ((single(-0.16666666666666666) * (x ^ single(2.0))) * ((single(pi) * hypot(single(1.0), tau)) ^ single(2.0))); end
\begin{array}{l}
\\
1 + \left(-0.16666666666666666 \cdot {x}^{2}\right) \cdot {\left(\pi \cdot \mathsf{hypot}\left(1, tau\right)\right)}^{2}
\end{array}
Initial program 97.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 75.5%
+-commutative75.5%
fma-def75.5%
distribute-lft-out75.5%
distribute-lft1-in75.5%
Simplified75.5%
fma-udef75.5%
associate-*r*75.5%
add-sqr-sqrt75.5%
pow275.5%
*-commutative75.5%
sqrt-prod75.5%
unpow275.5%
sqrt-prod75.5%
add-sqr-sqrt75.5%
+-commutative75.5%
unpow275.5%
hypot-1-def75.5%
Applied egg-rr75.5%
Final simplification75.5%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (* (pow (* x PI) 2.0) (fma tau tau 1.0)) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, (powf((x * ((float) M_PI)), 2.0f) * fmaf(tau, tau, 1.0f)), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), Float32((Float32(x * Float32(pi)) ^ Float32(2.0)) * fma(tau, tau, Float32(1.0))), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, {\left(x \cdot \pi\right)}^{2} \cdot \mathsf{fma}\left(tau, tau, 1\right), 1\right)
\end{array}
Initial program 97.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 75.5%
+-commutative75.5%
fma-def75.5%
distribute-lft-out75.5%
distribute-lft1-in75.5%
Simplified75.5%
Taylor expanded in x around 0 75.5%
+-commutative75.5%
fma-def75.5%
associate-*r*75.5%
unpow275.5%
unpow275.5%
swap-sqr75.5%
unpow275.5%
+-commutative75.5%
unpow275.5%
fma-udef75.5%
Simplified75.5%
Final simplification75.5%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (* x PI) tau))) (* (/ (sin t_1) t_1) (* x (/ 1.0 x)))))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (x * (1.0f / x));
}
function code(x, tau) t_1 = Float32(Float32(x * Float32(pi)) * tau) return Float32(Float32(sin(t_1) / t_1) * Float32(x * Float32(Float32(1.0) / x))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (x * (single(1.0) / x)); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \pi\right) \cdot tau\\
\frac{\sin t_1}{t_1} \cdot \left(x \cdot \frac{1}{x}\right)
\end{array}
\end{array}
Initial program 97.9%
*-un-lft-identity97.9%
times-frac97.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 67.6%
Final simplification67.6%
(FPCore (x tau) :precision binary32 (/ (/ (sin (* x (* PI tau))) tau) (* x PI)))
float code(float x, float tau) {
return (sinf((x * (((float) M_PI) * tau))) / tau) / (x * ((float) M_PI));
}
function code(x, tau) return Float32(Float32(sin(Float32(x * Float32(Float32(pi) * tau))) / tau) / Float32(x * Float32(pi))) end
function tmp = code(x, tau) tmp = (sin((x * (single(pi) * tau))) / tau) / (x * single(pi)); end
\begin{array}{l}
\\
\frac{\frac{\sin \left(x \cdot \left(\pi \cdot tau\right)\right)}{tau}}{x \cdot \pi}
\end{array}
Initial program 97.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
*-commutative97.0%
clear-num97.0%
un-div-inv97.1%
associate-*r*97.1%
*-commutative97.1%
associate-*r*97.2%
associate-*r*97.3%
pow297.3%
Applied egg-rr97.3%
Taylor expanded in x around 0 67.5%
Final simplification67.5%
(FPCore (x tau) :precision binary32 (fma -0.16666666666666666 (* PI (* x (* x PI))) 1.0))
float code(float x, float tau) {
return fmaf(-0.16666666666666666f, (((float) M_PI) * (x * (x * ((float) M_PI)))), 1.0f);
}
function code(x, tau) return fma(Float32(-0.16666666666666666), Float32(Float32(pi) * Float32(x * Float32(x * Float32(pi)))), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, \pi \cdot \left(x \cdot \left(x \cdot \pi\right)\right), 1\right)
\end{array}
Initial program 97.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in tau around 0 60.8%
Taylor expanded in x around 0 61.2%
+-commutative61.2%
fma-def61.2%
unpow261.2%
unpow261.2%
swap-sqr61.2%
unpow261.2%
Simplified61.2%
unpow261.2%
associate-*r*61.2%
Applied egg-rr61.2%
Final simplification61.2%
(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.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in tau around 0 60.8%
Taylor expanded in x around 0 61.2%
+-commutative61.2%
fma-def61.2%
unpow261.2%
unpow261.2%
swap-sqr61.2%
unpow261.2%
Simplified61.2%
Final simplification61.2%
(FPCore (x tau) :precision binary32 (+ 1.0 (* (pow (* x PI) 2.0) -0.16666666666666666)))
float code(float x, float tau) {
return 1.0f + (powf((x * ((float) M_PI)), 2.0f) * -0.16666666666666666f);
}
function code(x, tau) return Float32(Float32(1.0) + Float32((Float32(x * Float32(pi)) ^ Float32(2.0)) * Float32(-0.16666666666666666))) end
function tmp = code(x, tau) tmp = single(1.0) + (((x * single(pi)) ^ single(2.0)) * single(-0.16666666666666666)); end
\begin{array}{l}
\\
1 + {\left(x \cdot \pi\right)}^{2} \cdot -0.16666666666666666
\end{array}
Initial program 97.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in tau around 0 60.8%
Taylor expanded in x around 0 61.2%
+-commutative61.2%
fma-def61.2%
unpow261.2%
unpow261.2%
swap-sqr61.2%
unpow261.2%
Simplified61.2%
fma-udef61.2%
Applied egg-rr61.2%
Final simplification61.2%
(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 97.9%
associate-*l/97.8%
*-commutative97.8%
times-frac97.3%
associate-/l/97.3%
associate-*l*97.0%
*-commutative97.0%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 60.0%
Final simplification60.0%
herbie shell --seed 2023298
(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))))