
(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) (/ (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.9%
associate-*l*97.3%
associate-*l*98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x tau) :precision binary32 (* (sin (* tau (* x PI))) (* (pow (* x PI) -2.0) (/ (sin (* x PI)) tau))))
float code(float x, float tau) {
return sinf((tau * (x * ((float) M_PI)))) * (powf((x * ((float) M_PI)), -2.0f) * (sinf((x * ((float) M_PI))) / tau));
}
function code(x, tau) return Float32(sin(Float32(tau * Float32(x * Float32(pi)))) * Float32((Float32(x * Float32(pi)) ^ Float32(-2.0)) * Float32(sin(Float32(x * Float32(pi))) / tau))) end
function tmp = code(x, tau) tmp = sin((tau * (x * single(pi)))) * (((x * single(pi)) ^ single(-2.0)) * (sin((x * single(pi))) / tau)); end
\begin{array}{l}
\\
\sin \left(tau \cdot \left(x \cdot \pi\right)\right) \cdot \left({\left(x \cdot \pi\right)}^{-2} \cdot \frac{\sin \left(x \cdot \pi\right)}{tau}\right)
\end{array}
Initial program 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in x around inf 97.0%
associate-/l*96.8%
*-commutative96.8%
*-commutative96.8%
associate-/l*97.0%
*-commutative97.0%
*-commutative97.0%
*-commutative97.0%
times-frac96.8%
Simplified97.0%
*-commutative97.0%
div-inv96.9%
associate-*l*96.8%
associate-*r*96.6%
*-commutative96.6%
times-frac96.9%
*-un-lft-identity96.9%
pow296.9%
unpow-prod-down97.0%
associate-/l/97.1%
add-log-exp52.7%
Applied egg-rr97.0%
expm1-def97.3%
expm1-log1p97.4%
associate-*l*97.2%
*-commutative97.2%
associate-*r*97.3%
*-commutative97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x tau) :precision binary32 (* (* (sin (* tau (* x PI))) (pow (* x PI) -2.0)) (/ (sin (* x PI)) tau)))
float code(float x, float tau) {
return (sinf((tau * (x * ((float) M_PI)))) * powf((x * ((float) M_PI)), -2.0f)) * (sinf((x * ((float) M_PI))) / tau);
}
function code(x, tau) return Float32(Float32(sin(Float32(tau * Float32(x * Float32(pi)))) * (Float32(x * Float32(pi)) ^ Float32(-2.0))) * Float32(sin(Float32(x * Float32(pi))) / tau)) end
function tmp = code(x, tau) tmp = (sin((tau * (x * single(pi)))) * ((x * single(pi)) ^ single(-2.0))) * (sin((x * single(pi))) / tau); end
\begin{array}{l}
\\
\left(\sin \left(tau \cdot \left(x \cdot \pi\right)\right) \cdot {\left(x \cdot \pi\right)}^{-2}\right) \cdot \frac{\sin \left(x \cdot \pi\right)}{tau}
\end{array}
Initial program 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in x around inf 97.0%
associate-/l*96.8%
*-commutative96.8%
*-commutative96.8%
associate-/l*97.0%
*-commutative97.0%
*-commutative97.0%
*-commutative97.0%
times-frac96.8%
Simplified97.0%
add-log-exp96.4%
exp-prod78.2%
div-inv78.2%
pow278.2%
unpow-prod-down78.3%
pow-flip78.3%
metadata-eval78.3%
Applied egg-rr78.3%
log-pow78.5%
*-commutative78.5%
associate-*r*78.6%
*-commutative78.6%
rem-log-exp97.5%
Simplified97.5%
Final simplification97.5%
(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(x * Float32(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 := x \cdot \left(\pi \cdot tau\right)\\
\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.9%
associate-*l*97.3%
associate-*l*98.0%
Simplified98.0%
Taylor expanded in x around 0 85.3%
*-commutative85.3%
unpow285.3%
Simplified85.3%
Final simplification85.3%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* tau (* x PI)))) (* (/ (sin t_1) t_1) (+ 1.0 (* -0.16666666666666666 (pow (* x 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 * powf((x * ((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(-0.16666666666666666) * (Float32(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 * 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 + -0.16666666666666666 \cdot {\left(x \cdot \pi\right)}^{2}\right)
\end{array}
\end{array}
Initial program 97.9%
Taylor expanded in x around 0 85.3%
*-commutative85.3%
unpow285.3%
Simplified85.3%
Taylor expanded in x around 0 85.3%
unpow285.3%
*-commutative85.3%
unpow285.3%
swap-sqr85.3%
unpow285.3%
Simplified85.3%
Final simplification85.3%
(FPCore (x tau) :precision binary32 (/ (* (sin (* tau (* x PI))) (+ (* (* x PI) -0.16666666666666666) (/ 1.0 (* x PI)))) tau))
float code(float x, float tau) {
return (sinf((tau * (x * ((float) M_PI)))) * (((x * ((float) M_PI)) * -0.16666666666666666f) + (1.0f / (x * ((float) M_PI))))) / tau;
}
function code(x, tau) return Float32(Float32(sin(Float32(tau * Float32(x * Float32(pi)))) * 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((tau * (x * single(pi)))) * (((x * single(pi)) * single(-0.16666666666666666)) + (single(1.0) / (x * single(pi))))) / tau; end
\begin{array}{l}
\\
\frac{\sin \left(tau \cdot \left(x \cdot \pi\right)\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-*r/98.0%
associate-*l/97.8%
associate-/l/97.9%
associate-*r/97.8%
associate-*l*97.2%
associate-*r*97.0%
associate-/r*97.2%
associate-/l/97.0%
swap-sqr96.9%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in x around 0 84.8%
Taylor expanded in tau around inf 85.0%
Final simplification85.0%
(FPCore (x tau)
:precision binary32
(exp
(*
(* x x)
(*
(pow PI 2.0)
(+ -0.16666666666666666 (* -0.16666666666666666 (* tau tau)))))))
float code(float x, float tau) {
return expf(((x * x) * (powf(((float) M_PI), 2.0f) * (-0.16666666666666666f + (-0.16666666666666666f * (tau * tau))))));
}
function code(x, tau) return exp(Float32(Float32(x * x) * Float32((Float32(pi) ^ Float32(2.0)) * Float32(Float32(-0.16666666666666666) + Float32(Float32(-0.16666666666666666) * Float32(tau * tau)))))) end
function tmp = code(x, tau) tmp = exp(((x * x) * ((single(pi) ^ single(2.0)) * (single(-0.16666666666666666) + (single(-0.16666666666666666) * (tau * tau)))))); end
\begin{array}{l}
\\
e^{\left(x \cdot x\right) \cdot \left({\pi}^{2} \cdot \left(-0.16666666666666666 + -0.16666666666666666 \cdot \left(tau \cdot tau\right)\right)\right)}
\end{array}
Initial program 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
add-exp-log93.9%
associate-*r/93.8%
associate-*l/93.8%
*-commutative93.8%
associate-*r*93.6%
*-commutative93.6%
associate-*l*93.9%
associate-/r*93.9%
*-commutative93.9%
Applied egg-rr93.9%
Taylor expanded in x around 0 81.0%
associate-*r*81.0%
distribute-rgt-out81.0%
unpow281.0%
unpow281.0%
Simplified81.0%
Final simplification81.0%
(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 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in x around inf 97.0%
associate-/l*96.8%
*-commutative96.8%
*-commutative96.8%
associate-/l*97.0%
*-commutative97.0%
*-commutative97.0%
*-commutative97.0%
times-frac96.8%
Simplified97.0%
Taylor expanded in x around 0 71.7%
Taylor expanded in x around -inf 72.0%
Final simplification72.0%
(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 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in x around inf 97.0%
associate-/l*96.8%
*-commutative96.8%
*-commutative96.8%
associate-/l*97.0%
*-commutative97.0%
*-commutative97.0%
*-commutative97.0%
times-frac96.8%
Simplified97.0%
Taylor expanded in x around 0 71.7%
Taylor expanded in x around 0 70.6%
+-commutative70.6%
fma-def70.6%
unpow270.6%
associate-*r*70.6%
unpow270.6%
unpow270.6%
unswap-sqr70.6%
swap-sqr70.6%
associate-*r*70.6%
*-commutative70.6%
associate-*r*70.6%
associate-*r*70.6%
*-commutative70.6%
associate-*r*70.6%
unpow270.6%
Simplified70.6%
Final simplification70.6%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (* (* x x) (* (pow PI 2.0) (* tau tau))))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * ((x * x) * (powf(((float) M_PI), 2.0f) * (tau * tau))));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * Float32(Float32(x * x) * Float32((Float32(pi) ^ Float32(2.0)) * Float32(tau * tau))))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * ((x * x) * ((single(pi) ^ single(2.0)) * (tau * tau)))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot \left(\left(x \cdot x\right) \cdot \left({\pi}^{2} \cdot \left(tau \cdot tau\right)\right)\right)
\end{array}
Initial program 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in x around inf 97.0%
associate-/l*96.8%
*-commutative96.8%
*-commutative96.8%
associate-/l*97.0%
*-commutative97.0%
*-commutative97.0%
*-commutative97.0%
times-frac96.8%
Simplified97.0%
Taylor expanded in x around 0 71.7%
Taylor expanded in x around 0 70.6%
unpow270.6%
associate-*r*70.6%
*-commutative70.6%
unpow270.6%
Simplified70.6%
Final simplification70.6%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (* x (* PI (* x PI))))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * (x * (((float) M_PI) * (x * ((float) M_PI)))));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * Float32(x * Float32(Float32(pi) * Float32(x * Float32(pi)))))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * (x * (single(pi) * (x * single(pi))))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot \left(x \cdot \left(\pi \cdot \left(x \cdot \pi\right)\right)\right)
\end{array}
Initial program 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in tau around 0 66.4%
*-commutative66.4%
Simplified66.4%
Taylor expanded in x around 0 66.4%
unpow266.4%
*-commutative66.4%
unpow266.4%
swap-sqr66.4%
unpow266.4%
Simplified66.4%
unpow266.4%
associate-*r*66.4%
Applied egg-rr66.4%
Final simplification66.4%
(FPCore (x tau) :precision binary32 (+ 1.0 (* -0.16666666666666666 (* x (* x (pow PI 2.0))))))
float code(float x, float tau) {
return 1.0f + (-0.16666666666666666f * (x * (x * powf(((float) M_PI), 2.0f))));
}
function code(x, tau) return Float32(Float32(1.0) + Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * (Float32(pi) ^ Float32(2.0)))))) end
function tmp = code(x, tau) tmp = single(1.0) + (single(-0.16666666666666666) * (x * (x * (single(pi) ^ single(2.0))))); end
\begin{array}{l}
\\
1 + -0.16666666666666666 \cdot \left(x \cdot \left(x \cdot {\pi}^{2}\right)\right)
\end{array}
Initial program 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in tau around 0 66.4%
*-commutative66.4%
Simplified66.4%
Taylor expanded in x around 0 66.4%
unpow266.4%
*-commutative66.4%
unpow266.4%
swap-sqr66.4%
unpow266.4%
Simplified66.4%
unpow-prod-down66.4%
pow266.4%
associate-*r*66.4%
Applied egg-rr66.4%
Final simplification66.4%
(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 97.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in tau around 0 66.4%
*-commutative66.4%
Simplified66.4%
Taylor expanded in x around 0 66.4%
unpow266.4%
*-commutative66.4%
unpow266.4%
swap-sqr66.4%
unpow266.4%
Simplified66.4%
Final simplification66.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.9%
*-commutative97.9%
times-frac97.9%
associate-*r/97.7%
associate-*r*97.5%
associate-/r*97.3%
associate-/l/97.5%
associate-*l*97.3%
swap-sqr97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in x around 0 65.6%
Final simplification65.6%
herbie shell --seed 2023172
(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))))