
(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 11 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 tau) (PI))) (t_2 (* x (PI)))) (* (/ (sin t_1) t_1) (/ (sin t_2) t_2))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot tau\right) \cdot \mathsf{PI}\left(\right)\\
t_2 := x \cdot \mathsf{PI}\left(\right)\\
\frac{\sin t\_1}{t\_1} \cdot \frac{\sin t\_2}{t\_2}
\end{array}
\end{array}
Initial program 98.0%
lift-*.f32N/A
lift-/.f32N/A
associate-*l/N/A
lower-/.f32N/A
Applied rewrites97.9%
Applied rewrites98.0%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (PI) x)) (t_2 (* tau t_1))) (* (/ (sin t_1) t_2) (/ (sin 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{\sin t\_1}{t\_2} \cdot \frac{\sin t\_2}{t\_1}
\end{array}
\end{array}
Initial program 98.0%
lift-*.f32N/A
lift-/.f32N/A
associate-*l/N/A
lift-*.f32N/A
times-fracN/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites97.8%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* (PI) x)) (t_2 (* tau t_1))) (* (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 := tau \cdot t\_1\\
\sin t\_1 \cdot \frac{\frac{\sin t\_2}{t\_2}}{t\_1}
\end{array}
\end{array}
Initial program 98.0%
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.7
Applied rewrites97.7%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* x (PI)))) (/ (* (sin (* (* x tau) (PI))) (sin t_1)) (* (* tau t_1) t_1))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \mathsf{PI}\left(\right)\\
\frac{\sin \left(\left(x \cdot tau\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sin t\_1}{\left(tau \cdot t\_1\right) \cdot t\_1}
\end{array}
\end{array}
Initial program 98.0%
remove-double-negN/A
lift-sin.f32N/A
sin-+PI-revN/A
sin-+PI-revN/A
lower-sin.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lift-PI.f32N/A
distribute-lft1-inN/A
lift-PI.f32N/A
lower-fma.f32N/A
lower-fma.f3279.2
Applied rewrites79.2%
lift-*.f32N/A
lift-/.f32N/A
frac-2negN/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
Applied rewrites80.9%
lift-sin.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
distribute-lft-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
unpow1N/A
metadata-evalN/A
unpow-prod-upN/A
lift-PI.f32N/A
metadata-evalN/A
pow1N/A
sin-+PI-revN/A
lift-sin.f32N/A
lower-neg.f3297.9
lift-sin.f32N/A
Applied rewrites97.4%
Final simplification97.4%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* tau (PI))) (t_2 (* x (PI)))) (/ (* (sin (* t_1 x)) (sin t_2)) (* t_1 (* x t_2)))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := tau \cdot \mathsf{PI}\left(\right)\\
t_2 := x \cdot \mathsf{PI}\left(\right)\\
\frac{\sin \left(t\_1 \cdot x\right) \cdot \sin t\_2}{t\_1 \cdot \left(x \cdot t\_2\right)}
\end{array}
\end{array}
Initial program 98.0%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lower-/.f32N/A
Applied rewrites98.0%
lift-/.f32N/A
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-/r*N/A
Applied rewrites97.4%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* tau (PI))) (t_2 (* x (PI)))) (* (/ (sin (* t_1 x)) (* t_1 (* x t_2))) (sin t_2))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := tau \cdot \mathsf{PI}\left(\right)\\
t_2 := x \cdot \mathsf{PI}\left(\right)\\
\frac{\sin \left(t\_1 \cdot x\right)}{t\_1 \cdot \left(x \cdot t\_2\right)} \cdot \sin t\_2
\end{array}
\end{array}
Initial program 98.0%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lower-/.f32N/A
Applied rewrites98.0%
lift-/.f32N/A
lift-*.f32N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites97.4%
(FPCore (x tau) :precision binary32 (let* ((t_1 (* tau (PI))) (t_2 (* x (PI)))) (* (sin (* t_1 x)) (/ (sin t_2) (* t_1 (* x t_2))))))
\begin{array}{l}
\\
\begin{array}{l}
t_1 := tau \cdot \mathsf{PI}\left(\right)\\
t_2 := x \cdot \mathsf{PI}\left(\right)\\
\sin \left(t\_1 \cdot x\right) \cdot \frac{\sin t\_2}{t\_1 \cdot \left(x \cdot t\_2\right)}
\end{array}
\end{array}
Initial program 98.0%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lower-/.f32N/A
Applied rewrites98.0%
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r/N/A
lift-/.f32N/A
frac-timesN/A
Applied rewrites97.2%
(FPCore (x tau)
:precision binary32
(let* ((t_1 (* (* x tau) (PI))))
(*
(/ (sin t_1) t_1)
(fma (* (* -0.16666666666666666 x) x) (* (PI) (PI)) 1.0))))\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot tau\right) \cdot \mathsf{PI}\left(\right)\\
\frac{\sin t\_1}{t\_1} \cdot \mathsf{fma}\left(\left(-0.16666666666666666 \cdot x\right) \cdot x, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)
\end{array}
\end{array}
Initial program 98.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3286.3
Applied rewrites86.3%
Applied rewrites86.3%
(FPCore (x tau)
:precision binary32
(let* ((t_1 (* (PI) (PI))))
(*
(fma (* -0.16666666666666666 (* tau tau)) (* t_1 (* x x)) 1.0)
(fma (* (* -0.16666666666666666 x) x) t_1 1.0))))\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathsf{fma}\left(-0.16666666666666666 \cdot \left(tau \cdot tau\right), t\_1 \cdot \left(x \cdot x\right), 1\right) \cdot \mathsf{fma}\left(\left(-0.16666666666666666 \cdot x\right) \cdot x, t\_1, 1\right)
\end{array}
\end{array}
Initial program 98.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3286.3
Applied rewrites86.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f32N/A
unpow2N/A
lower-*.f3280.9
Applied rewrites80.9%
(FPCore (x tau) :precision binary32 (fma (* (fma tau tau 1.0) (* (* (PI) (PI)) -0.16666666666666666)) (* x x) 1.0))
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(tau, tau, 1\right) \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -0.16666666666666666\right), x \cdot x, 1\right)
\end{array}
Initial program 98.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites79.8%
(FPCore (x tau) :precision binary32 1.0)
float code(float x, float tau) {
return 1.0f;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(x, tau)
use fmin_fmax_functions
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%
Taylor expanded in x around 0
Applied rewrites63.9%
herbie shell --seed 2025015
(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)))))