
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (PI))) (t_2 (* t_1 tau))) (* (/ (sin t_2) t_2) (/ (sin t_1) t_1))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \mathsf{PI}\left(\right)\\
t_2 := t\_1 \cdot tau\\
\frac{\sin t\_2}{t\_2} \cdot \frac{\sin t\_1}{t\_1}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (PI))) (t_2 (* t_1 tau))) (* (/ (sin t_2) t_2) (/ (sin t_1) t_1))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \mathsf{PI}\left(\right)\\
t_2 := t\_1 \cdot tau\\
\frac{\sin t\_2}{t\_2} \cdot \frac{\sin t\_1}{t\_1}
\end{array}
\end{array}
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (PI))) (t_2 (* t_1 tau))) (* (/ (sin t_2) t_2) (/ (sin t_1) t_1))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \mathsf{PI}\left(\right)\\
t_2 := t\_1 \cdot tau\\
\frac{\sin t\_2}{t\_2} \cdot \frac{\sin t\_1}{t\_1}
\end{array}
\end{array}
Initial program 97.9%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (PI) x)) (t_2 (* (* tau x) (PI)))) (* (sin t_1) (/ (/ (sin t_2) t_2) t_1))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{PI}\left(\right) \cdot x\\
t_2 := \left(tau \cdot x\right) \cdot \mathsf{PI}\left(\right)\\
\sin t\_1 \cdot \frac{\frac{\sin t\_2}{t\_2}}{t\_1}
\end{array}
\end{array}
Initial program 97.9%
lift-*.f32N/A
*-commutativeN/A
lift-/.f32N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f3297.8
Applied rewrites97.8%
Taylor expanded in x around inf
lower-/.f32N/A
lower-sin.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3297.8
Applied rewrites97.8%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (* tau x) (PI)))) (/ (* (sin t_1) (sin (* (PI) x))) (* x (* (PI) t_1)))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(tau \cdot x\right) \cdot \mathsf{PI}\left(\right)\\
\frac{\sin t\_1 \cdot \sin \left(\mathsf{PI}\left(\right) \cdot x\right)}{x \cdot \left(\mathsf{PI}\left(\right) \cdot t\_1\right)}
\end{array}
\end{array}
Initial program 97.9%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lower-/.f32N/A
Applied rewrites97.7%
Applied rewrites97.7%
lift-/.f32N/A
lift-*.f32N/A
associate-/l*N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
Applied rewrites97.5%
(FPCore (x tau)
:precision binary32
(/
(/
(*
(* (- (* (* 0.16666666666666666 (* x x)) (* (PI) (PI))) 1.0) x)
(/ (sin (* tau (* x (PI)))) x))
x)
(* (- tau) (PI))))\begin{array}{l}
\\
\frac{\frac{\left(\left(\left(0.16666666666666666 \cdot \left(x \cdot x\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) - 1\right) \cdot x\right) \cdot \frac{\sin \left(tau \cdot \left(x \cdot \mathsf{PI}\left(\right)\right)\right)}{x}}{x}}{\left(-tau\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 97.9%
lift-*.f32N/A
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f32N/A
Applied rewrites97.2%
lift-*.f32N/A
*-commutativeN/A
lift-/.f32N/A
lift-*.f32N/A
associate-/r*N/A
frac-2negN/A
associate-*l/N/A
lower-/.f32N/A
Applied rewrites96.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-*.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3282.5
Applied rewrites82.5%
Final simplification82.5%
(FPCore (x tau)
:precision binary32
(let* ((t_1 (* (* tau x) (PI))))
(/
(* (fma (* -0.16666666666666666 (* x x)) (* (PI) (PI)) 1.0) (sin t_1))
t_1)))\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(tau \cdot x\right) \cdot \mathsf{PI}\left(\right)\\
\frac{\mathsf{fma}\left(-0.16666666666666666 \cdot \left(x \cdot x\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sin t\_1}{t\_1}
\end{array}
\end{array}
Initial program 97.9%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lower-/.f32N/A
Applied rewrites97.7%
Applied rewrites97.7%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3229.5
Applied rewrites28.1%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (PI) x)) (t_2 (* tau t_1))) (/ (* t_1 (/ (sin t_2) t_2)) t_1)))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{PI}\left(\right) \cdot x\\
t_2 := tau \cdot t\_1\\
\frac{t\_1 \cdot \frac{\sin t\_2}{t\_2}}{t\_1}
\end{array}
\end{array}
Initial program 97.9%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lower-/.f32N/A
Applied rewrites97.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3270.2
Applied rewrites70.2%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (PI) x)) (t_2 (* (* tau x) (PI)))) (* t_1 (/ (/ (sin t_2) t_2) t_1))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{PI}\left(\right) \cdot x\\
t_2 := \left(tau \cdot x\right) \cdot \mathsf{PI}\left(\right)\\
t\_1 \cdot \frac{\frac{\sin t\_2}{t\_2}}{t\_1}
\end{array}
\end{array}
Initial program 97.9%
lift-*.f32N/A
*-commutativeN/A
lift-/.f32N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f3297.8
Applied rewrites97.8%
Taylor expanded in x around inf
lower-/.f32N/A
lower-sin.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3297.8
Applied rewrites97.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3270.1
Applied rewrites70.1%
(FPCore (x tau) :precision binary32 (* (/ (/ 1.0 tau) x) (/ (sin (* tau (* (PI) x))) (PI))))
\begin{array}{l}
\\
\frac{\frac{1}{tau}}{x} \cdot \frac{\sin \left(tau \cdot \left(\mathsf{PI}\left(\right) \cdot x\right)\right)}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 97.9%
lift-*.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-timesN/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
times-fracN/A
lower-*.f32N/A
Applied rewrites97.2%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f32N/A
lower-/.f3269.8
Applied rewrites69.8%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (PI) x))) (/ (sin t_1) t_1)))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{PI}\left(\right) \cdot x\\
\frac{\sin t\_1}{t\_1}
\end{array}
\end{array}
Initial program 97.9%
lift-*.f32N/A
*-commutativeN/A
lift-/.f32N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f3297.8
Applied rewrites97.8%
Taylor expanded in x around inf
lower-/.f32N/A
lower-sin.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3297.8
Applied rewrites97.8%
Taylor expanded in tau around 0
lower-/.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3263.9
Applied rewrites63.9%
Final simplification63.9%
(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%
Taylor expanded in x around 0
Applied rewrites63.2%
herbie shell --seed 2024326
(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)))))