
(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 11 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(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 98.0%
associate-*l*97.6%
associate-*l*98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x tau) :precision binary32 (* (sin (* x PI)) (/ (sin (* tau (* x PI))) (* tau (pow (* x PI) 2.0)))))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) * (sinf((tau * (x * ((float) M_PI)))) / (tau * powf((x * ((float) M_PI)), 2.0f)));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) * Float32(sin(Float32(tau * Float32(x * Float32(pi)))) / Float32(tau * (Float32(x * Float32(pi)) ^ Float32(2.0))))) end
function tmp = code(x, tau) tmp = sin((x * single(pi))) * (sin((tau * (x * single(pi)))) / (tau * ((x * single(pi)) ^ single(2.0)))); end
\begin{array}{l}
\\
\sin \left(x \cdot \pi\right) \cdot \frac{\sin \left(tau \cdot \left(x \cdot \pi\right)\right)}{tau \cdot {\left(x \cdot \pi\right)}^{2}}
\end{array}
Initial program 98.0%
*-commutative98.0%
times-frac97.7%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.4%
associate-/l/97.5%
associate-*l*97.2%
swap-sqr97.0%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in x around inf 96.7%
associate-*r*96.8%
*-commutative96.8%
*-commutative96.8%
*-commutative96.8%
unpow296.8%
unpow296.8%
swap-sqr97.1%
unpow297.1%
Simplified97.1%
Taylor expanded in tau around 0 97.5%
Final simplification97.5%
(FPCore (x tau) :precision binary32 (* (sin (* x PI)) (/ (/ (sin (* tau (* x PI))) tau) (pow (* x PI) 2.0))))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) * ((sinf((tau * (x * ((float) M_PI)))) / tau) / powf((x * ((float) M_PI)), 2.0f));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) * Float32(Float32(sin(Float32(tau * Float32(x * Float32(pi)))) / tau) / (Float32(x * Float32(pi)) ^ Float32(2.0)))) end
function tmp = code(x, tau) tmp = sin((x * single(pi))) * ((sin((tau * (x * single(pi)))) / tau) / ((x * single(pi)) ^ single(2.0))); end
\begin{array}{l}
\\
\sin \left(x \cdot \pi\right) \cdot \frac{\frac{\sin \left(tau \cdot \left(x \cdot \pi\right)\right)}{tau}}{{\left(x \cdot \pi\right)}^{2}}
\end{array}
Initial program 98.0%
*-commutative98.0%
times-frac97.7%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.4%
associate-/l/97.5%
associate-*l*97.2%
swap-sqr97.0%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in x around inf 96.7%
associate-*r*96.8%
*-commutative96.8%
*-commutative96.8%
*-commutative96.8%
unpow296.8%
unpow296.8%
swap-sqr97.1%
unpow297.1%
Simplified97.1%
*-commutative97.1%
*-un-lft-identity97.1%
times-frac96.9%
Applied egg-rr96.9%
associate-*r/96.9%
*-commutative96.9%
Simplified96.9%
Taylor expanded in tau around -inf 97.6%
Final simplification97.6%
(FPCore (x tau)
:precision binary32
(let* ((t_1 (* tau (* x PI))))
(*
(/ (sin t_1) t_1)
(+ 1.0 (* (* -0.16666666666666666 (* x x)) (pow PI 2.0))))))
float code(float x, float tau) {
float t_1 = tau * (x * ((float) M_PI));
return (sinf(t_1) / t_1) * (1.0f + ((-0.16666666666666666f * (x * x)) * powf(((float) M_PI), 2.0f)));
}
function code(x, tau) t_1 = Float32(tau * Float32(x * Float32(pi))) return Float32(Float32(sin(t_1) / t_1) * Float32(Float32(1.0) + Float32(Float32(Float32(-0.16666666666666666) * Float32(x * x)) * (Float32(pi) ^ Float32(2.0))))) end
function tmp = code(x, tau) t_1 = tau * (x * single(pi)); tmp = (sin(t_1) / t_1) * (single(1.0) + ((single(-0.16666666666666666) * (x * x)) * (single(pi) ^ single(2.0)))); end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := tau \cdot \left(x \cdot \pi\right)\\
\frac{\sin t_1}{t_1} \cdot \left(1 + \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right) \cdot {\pi}^{2}\right)
\end{array}
\end{array}
Initial program 98.0%
Taylor expanded in x around 0 82.2%
associate-*r*82.2%
unpow282.2%
Simplified82.2%
Final simplification82.2%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* tau (* x PI)))) (* (/ (sin t_1) t_1) (+ 1.0 (* (pow (* x PI) 2.0) -0.16666666666666666)))))
float code(float x, float tau) {
float t_1 = tau * (x * ((float) M_PI));
return (sinf(t_1) / t_1) * (1.0f + (powf((x * ((float) M_PI)), 2.0f) * -0.16666666666666666f));
}
function code(x, tau) t_1 = Float32(tau * Float32(x * Float32(pi))) 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 = tau * (x * single(pi)); 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 := tau \cdot \left(x \cdot \pi\right)\\
\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 98.0%
clear-num97.7%
associate-/r/97.8%
*-commutative97.8%
*-commutative97.8%
Applied egg-rr97.8%
Taylor expanded in x around 0 82.2%
unpow282.2%
*-commutative82.2%
unpow282.2%
swap-sqr82.2%
unpow282.2%
*-commutative82.2%
Simplified82.2%
Final simplification82.2%
(FPCore (x tau) :precision binary32 (* (sin (* x PI)) (fma -0.16666666666666666 (* PI (* x (* tau tau))) (/ 1.0 (* x PI)))))
float code(float x, float tau) {
return sinf((x * ((float) M_PI))) * fmaf(-0.16666666666666666f, (((float) M_PI) * (x * (tau * tau))), (1.0f / (x * ((float) M_PI))));
}
function code(x, tau) return Float32(sin(Float32(x * Float32(pi))) * fma(Float32(-0.16666666666666666), Float32(Float32(pi) * Float32(x * Float32(tau * tau))), Float32(Float32(1.0) / Float32(x * Float32(pi))))) end
\begin{array}{l}
\\
\sin \left(x \cdot \pi\right) \cdot \mathsf{fma}\left(-0.16666666666666666, \pi \cdot \left(x \cdot \left(tau \cdot tau\right)\right), \frac{1}{x \cdot \pi}\right)
\end{array}
Initial program 98.0%
*-commutative98.0%
times-frac97.7%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.4%
associate-/l/97.5%
associate-*l*97.2%
swap-sqr97.0%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in x around 0 77.9%
fma-def77.9%
*-commutative77.9%
associate-*l*77.9%
unpow277.9%
Simplified77.9%
Final simplification77.9%
(FPCore (x tau) :precision binary32 (fma (* -0.16666666666666666 (* (pow PI 2.0) (/ (- 1.0 (pow tau 4.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 - powf(tau, 4.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(Float32(1.0) - (tau ^ Float32(4.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 \frac{1 - {tau}^{4}}{1 - tau \cdot tau}\right), x \cdot x, 1\right)
\end{array}
Initial program 98.0%
*-commutative98.0%
times-frac97.7%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.4%
associate-/l/97.5%
associate-*l*97.2%
swap-sqr97.0%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in x around 0 77.1%
+-commutative77.1%
fma-def77.1%
distribute-lft-out77.1%
distribute-rgt1-in77.1%
unpow277.1%
unpow277.1%
Simplified77.1%
+-commutative77.1%
flip-+77.1%
metadata-eval77.1%
pow277.1%
pow277.1%
pow-prod-up77.1%
metadata-eval77.1%
Applied egg-rr77.1%
Final simplification77.1%
(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 98.0%
*-commutative98.0%
times-frac97.7%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.4%
associate-/l/97.5%
associate-*l*97.2%
swap-sqr97.0%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in x around 0 77.1%
+-commutative77.1%
fma-def77.1%
distribute-lft-out77.1%
distribute-rgt1-in77.1%
unpow277.1%
unpow277.1%
Simplified77.1%
Final simplification77.1%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* tau (* x PI)))) (/ (sin t_1) t_1)))
float code(float x, float tau) {
float t_1 = tau * (x * ((float) M_PI));
return sinf(t_1) / t_1;
}
function code(x, tau) t_1 = Float32(tau * Float32(x * Float32(pi))) return Float32(sin(t_1) / t_1) end
function tmp = code(x, tau) t_1 = tau * (x * single(pi)); tmp = sin(t_1) / t_1; end
\begin{array}{l}
\\
\begin{array}{l}
t_1 := tau \cdot \left(x \cdot \pi\right)\\
\frac{\sin t_1}{t_1}
\end{array}
\end{array}
Initial program 98.0%
clear-num97.7%
associate-/r/97.8%
*-commutative97.8%
*-commutative97.8%
Applied egg-rr97.8%
Taylor expanded in x around 0 70.0%
Final simplification70.0%
(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 98.0%
*-commutative98.0%
times-frac97.7%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.4%
associate-/l/97.5%
associate-*l*97.2%
swap-sqr97.0%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in x around inf 96.7%
associate-*r*96.8%
*-commutative96.8%
*-commutative96.8%
*-commutative96.8%
unpow296.8%
unpow296.8%
swap-sqr97.1%
unpow297.1%
Simplified97.1%
Taylor expanded in tau around 0 63.8%
*-commutative63.8%
associate-/r*63.7%
Simplified63.7%
Taylor expanded in x around 0 64.6%
unpow264.6%
unpow264.6%
swap-sqr64.6%
unpow264.6%
*-commutative64.6%
Simplified64.6%
Final simplification64.6%
(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.0%
*-commutative98.0%
times-frac97.7%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.4%
associate-/l/97.5%
associate-*l*97.2%
swap-sqr97.0%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in x around 0 63.0%
Final simplification63.0%
herbie shell --seed 2023188
(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))))