
(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))) (* (/ (sin t_1) t_1) (exp (log (/ (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) * expf(logf((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) * exp(log(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) * exp(log((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 e^{\log \left(\frac{\sin \left(x \cdot \pi\right)}{x \cdot \pi}\right)}
\end{array}
\end{array}
Initial program 97.8%
add-exp-log97.8%
*-commutative97.8%
*-commutative97.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(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.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%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
associate-*r/96.5%
associate-*r*96.7%
associate-/r*96.6%
*-commutative96.6%
*-commutative96.6%
associate-*l*96.9%
*-commutative96.9%
*-commutative96.9%
pow296.9%
Applied egg-rr96.9%
associate-/l/96.9%
times-frac96.8%
*-commutative96.8%
*-commutative96.8%
*-commutative96.8%
Applied egg-rr96.8%
Taylor expanded in x around inf 96.6%
times-frac96.7%
*-commutative96.7%
associate-*r*96.7%
*-commutative96.7%
*-commutative96.7%
*-commutative96.7%
unpow296.7%
unpow296.7%
swap-sqr97.0%
unpow297.0%
Simplified97.1%
Final simplification97.1%
(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(Float32(sin(Float32(Float32(x * Float32(pi)) * tau)) / 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 \left(\frac{\sin \left(\left(x \cdot \pi\right) \cdot tau\right)}{tau} \cdot {\left(x \cdot \pi\right)}^{-2}\right)
\end{array}
Initial program 97.8%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
Taylor expanded in x around inf 96.6%
associate-/r*96.8%
associate-*r*96.7%
*-commutative96.7%
associate-*l/96.7%
unpow296.7%
unpow296.7%
swap-sqr97.0%
unpow297.0%
associate-/l*97.0%
associate-/r/97.1%
Simplified97.5%
div-inv97.4%
*-commutative97.4%
associate-*r*96.9%
*-commutative96.9%
associate-*r*97.0%
pow-flip97.0%
metadata-eval97.0%
Applied egg-rr97.0%
*-commutative97.0%
associate-*r*97.5%
*-commutative97.5%
*-commutative97.5%
Simplified97.5%
Final simplification97.5%
(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%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
Taylor expanded in x around inf 96.6%
associate-/r*96.8%
associate-*r*96.7%
*-commutative96.7%
associate-*l/96.7%
unpow296.7%
unpow296.7%
swap-sqr97.0%
unpow297.0%
associate-/l*97.0%
associate-/r/97.1%
Simplified97.5%
Taylor expanded in tau around inf 96.7%
*-commutative96.7%
unpow296.7%
*-commutative96.7%
unpow296.7%
swap-sqr97.6%
unpow297.6%
*-commutative97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (x tau)
:precision binary32
(let* ((t_1 (* x (* PI tau))))
(*
(+ 1.0 (* -0.16666666666666666 (* (pow PI 2.0) (* x x))))
(/ (sin t_1) t_1))))
float code(float x, float tau) {
float t_1 = x * (((float) M_PI) * tau);
return (1.0f + (-0.16666666666666666f * (powf(((float) M_PI), 2.0f) * (x * x)))) * (sinf(t_1) / t_1);
}
function code(x, tau) t_1 = Float32(x * Float32(Float32(pi) * tau)) return Float32(Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * Float32((Float32(pi) ^ Float32(2.0)) * Float32(x * x)))) * Float32(sin(t_1) / t_1)) end
function tmp = code(x, tau) t_1 = x * (single(pi) * tau); tmp = (single(1.0) + (single(-0.16666666666666666) * ((single(pi) ^ single(2.0)) * (x * x)))) * (sin(t_1) / t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \left(\pi \cdot tau\right)\\
\left(1 + -0.16666666666666666 \cdot \left({\pi}^{2} \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 97.8%
associate-*l*97.1%
associate-*l*97.5%
Simplified97.5%
Taylor expanded in x around 0 83.7%
*-commutative83.7%
unpow283.7%
Simplified83.7%
Final simplification83.7%
(FPCore (x tau)
:precision binary32
(let* ((t_1 (* (* x PI) tau)))
(*
(/ (sin t_1) t_1)
(+ 1.0 (* -0.16666666666666666 (* (pow PI 2.0) (* x x)))))))
float code(float x, float tau) {
float t_1 = (x * ((float) M_PI)) * tau;
return (sinf(t_1) / t_1) * (1.0f + (-0.16666666666666666f * (powf(((float) M_PI), 2.0f) * (x * x))));
}
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(-0.16666666666666666) * Float32((Float32(pi) ^ Float32(2.0)) * Float32(x * x))))) end
function tmp = code(x, tau) t_1 = (x * single(pi)) * tau; tmp = (sin(t_1) / t_1) * (single(1.0) + (single(-0.16666666666666666) * ((single(pi) ^ single(2.0)) * (x * 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(1 + -0.16666666666666666 \cdot \left({\pi}^{2} \cdot \left(x \cdot x\right)\right)\right)
\end{array}
\end{array}
Initial program 97.8%
Taylor expanded in x around 0 83.7%
*-commutative83.7%
unpow283.7%
Simplified83.7%
Final simplification83.7%
(FPCore (x tau) :precision binary32 (/ (sin (* PI (* x tau))) (/ tau (fma -0.16666666666666666 (* x PI) (/ (/ 1.0 PI) x)))))
float code(float x, float tau) {
return sinf((((float) M_PI) * (x * tau))) / (tau / fmaf(-0.16666666666666666f, (x * ((float) M_PI)), ((1.0f / ((float) M_PI)) / x)));
}
function code(x, tau) return Float32(sin(Float32(Float32(pi) * Float32(x * tau))) / Float32(tau / fma(Float32(-0.16666666666666666), Float32(x * Float32(pi)), Float32(Float32(Float32(1.0) / Float32(pi)) / x)))) end
\begin{array}{l}
\\
\frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{\frac{tau}{\mathsf{fma}\left(-0.16666666666666666, x \cdot \pi, \frac{\frac{1}{\pi}}{x}\right)}}
\end{array}
Initial program 97.8%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
*-commutative96.8%
associate-*l/96.5%
associate-/l*96.7%
*-commutative96.7%
associate-*l*96.7%
associate-/l*96.8%
*-commutative96.8%
associate-*r*96.7%
swap-sqr97.0%
pow297.0%
*-commutative97.0%
Applied egg-rr97.0%
Taylor expanded in x around 0 83.0%
+-commutative83.0%
*-commutative83.0%
fma-def83.0%
*-commutative83.0%
associate-/r*83.1%
Simplified83.1%
Final simplification83.1%
(FPCore (x tau) :precision binary32 (/ (sin (* PI (* x tau))) (/ tau (+ (/ 1.0 (* x PI)) (* (* x PI) -0.16666666666666666)))))
float code(float x, float tau) {
return sinf((((float) M_PI) * (x * tau))) / (tau / ((1.0f / (x * ((float) M_PI))) + ((x * ((float) M_PI)) * -0.16666666666666666f)));
}
function code(x, tau) return Float32(sin(Float32(Float32(pi) * Float32(x * tau))) / Float32(tau / Float32(Float32(Float32(1.0) / Float32(x * Float32(pi))) + Float32(Float32(x * Float32(pi)) * Float32(-0.16666666666666666))))) end
function tmp = code(x, tau) tmp = sin((single(pi) * (x * tau))) / (tau / ((single(1.0) / (x * single(pi))) + ((x * single(pi)) * single(-0.16666666666666666)))); end
\begin{array}{l}
\\
\frac{\sin \left(\pi \cdot \left(x \cdot tau\right)\right)}{\frac{tau}{\frac{1}{x \cdot \pi} + \left(x \cdot \pi\right) \cdot -0.16666666666666666}}
\end{array}
Initial program 97.8%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
*-commutative96.8%
associate-*l/96.5%
associate-/l*96.7%
*-commutative96.7%
associate-*l*96.7%
associate-/l*96.8%
*-commutative96.8%
associate-*r*96.7%
swap-sqr97.0%
pow297.0%
*-commutative97.0%
Applied egg-rr97.0%
Taylor expanded in x around 0 83.0%
Final simplification83.0%
(FPCore (x tau) :precision binary32 (fma (* -0.16666666666666666 (* (pow PI 2.0) (+ 1.0 (* tau tau)))) (* x x) 1.0))
float code(float x, float tau) {
return fmaf((-0.16666666666666666f * (powf(((float) M_PI), 2.0f) * (1.0f + (tau * tau)))), (x * x), 1.0f);
}
function code(x, tau) return fma(Float32(Float32(-0.16666666666666666) * Float32((Float32(pi) ^ Float32(2.0)) * Float32(Float32(1.0) + Float32(tau * tau)))), Float32(x * x), Float32(1.0)) end
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666 \cdot \left({\pi}^{2} \cdot \left(1 + tau \cdot tau\right)\right), x \cdot x, 1\right)
\end{array}
Initial program 97.8%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
Taylor expanded in x around 0 77.6%
+-commutative77.6%
fma-def77.6%
distribute-lft-out77.6%
distribute-rgt1-in77.6%
unpow277.6%
unpow277.6%
Simplified77.6%
Final simplification77.6%
(FPCore (x tau) :precision binary32 (+ 1.0 (cbrt (* (pow (* x PI) 6.0) -0.004629629629629629))))
float code(float x, float tau) {
return 1.0f + cbrtf((powf((x * ((float) M_PI)), 6.0f) * -0.004629629629629629f));
}
function code(x, tau) return Float32(Float32(1.0) + cbrt(Float32((Float32(x * Float32(pi)) ^ Float32(6.0)) * Float32(-0.004629629629629629)))) end
\begin{array}{l}
\\
1 + \sqrt[3]{{\left(x \cdot \pi\right)}^{6} \cdot -0.004629629629629629}
\end{array}
Initial program 97.8%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
Taylor expanded in tau around 0 65.0%
*-commutative65.0%
Simplified65.0%
Taylor expanded in x around 0 65.4%
+-commutative65.4%
*-commutative65.4%
unpow265.4%
unpow265.4%
swap-sqr65.4%
unpow265.4%
*-commutative65.4%
Simplified65.4%
add-cbrt-cube65.4%
pow1/3-0.0%
pow3-0.0%
*-commutative-0.0%
*-commutative-0.0%
unpow-prod-down-0.0%
metadata-eval-0.0%
Applied egg-rr-0.0%
unpow1/365.4%
unpow265.4%
cube-prod65.4%
pow-sqr65.4%
*-commutative65.4%
metadata-eval65.4%
Simplified65.4%
Final simplification65.4%
(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%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
Taylor expanded in tau around 0 65.0%
*-commutative65.0%
Simplified65.0%
Taylor expanded in x around 0 65.4%
+-commutative65.4%
*-commutative65.4%
unpow265.4%
unpow265.4%
swap-sqr65.4%
unpow265.4%
fma-def65.4%
*-commutative65.4%
Simplified65.4%
Final simplification65.4%
(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.8%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
Taylor expanded in tau around 0 65.0%
*-commutative65.0%
Simplified65.0%
Taylor expanded in x around 0 65.4%
+-commutative65.4%
*-commutative65.4%
unpow265.4%
unpow265.4%
swap-sqr65.4%
unpow265.4%
*-commutative65.4%
Simplified65.4%
Final simplification65.4%
(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.8%
*-commutative97.8%
times-frac97.8%
associate-*r/97.8%
associate-*r*97.6%
associate-/r*97.5%
associate-/l/97.6%
associate-*l*97.2%
swap-sqr96.8%
associate-*r*96.8%
Simplified96.8%
Taylor expanded in x around 0 64.4%
Final simplification64.4%
herbie shell --seed 2023257
(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))))