
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
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(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x + \sin y\right) + z \cdot \cos y
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x + sin(y)) + (z * cos(y));
}
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(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x + Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x + math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x + sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x + sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x + \sin y\right) + z \cdot \cos y
(FPCore (x y z) :precision binary64 (fma (cos y) z (+ (sin y) x)))
double code(double x, double y, double z) {
return fma(cos(y), z, (sin(y) + x));
}
function code(x, y, z) return fma(cos(y), z, Float64(sin(y) + x)) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\cos y, z, \sin y + x\right)
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= z -3.3e+19) (* z (cos y)) (if (<= z 1.8e+41) (+ (+ (sin y) z) x) (fma (cos y) z (+ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.3e+19) {
tmp = z * cos(y);
} else if (z <= 1.8e+41) {
tmp = (sin(y) + z) + x;
} else {
tmp = fma(cos(y), z, (x + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -3.3e+19) tmp = Float64(z * cos(y)); elseif (z <= 1.8e+41) tmp = Float64(Float64(sin(y) + z) + x); else tmp = fma(cos(y), z, Float64(x + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -3.3e+19], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.8e+41], N[(N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{+19}:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+41}:\\
\;\;\;\;\left(\sin y + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\end{array}
if z < -3.3e19Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6488.8%
Applied rewrites88.8%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
*-lft-identityN/A
lift-fma.f64N/A
*-commutativeN/A
lift-cos.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-sin.f64N/A
+-commutativeN/A
div-addN/A
lift-cos.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites88.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6442.4%
Applied rewrites42.4%
if -3.3e19 < z < 1.80000000000000013e41Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6482.2%
Applied rewrites82.2%
if 1.80000000000000013e41 < z Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
lower-+.f6470.9%
Applied rewrites70.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (cos y)))) (if (<= z -3.3e+19) t_0 (if (<= z 2.8e+154) (+ (+ (sin y) z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -3.3e+19) {
tmp = t_0;
} else if (z <= 2.8e+154) {
tmp = (sin(y) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
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(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = z * cos(y)
if (z <= (-3.3d+19)) then
tmp = t_0
else if (z <= 2.8d+154) then
tmp = (sin(y) + z) + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.cos(y);
double tmp;
if (z <= -3.3e+19) {
tmp = t_0;
} else if (z <= 2.8e+154) {
tmp = (Math.sin(y) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -3.3e+19: tmp = t_0 elif z <= 2.8e+154: tmp = (math.sin(y) + z) + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -3.3e+19) tmp = t_0; elseif (z <= 2.8e+154) tmp = Float64(Float64(sin(y) + z) + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -3.3e+19) tmp = t_0; elseif (z <= 2.8e+154) tmp = (sin(y) + z) + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.3e+19], t$95$0, If[LessEqual[z, 2.8e+154], N[(N[(N[Sin[y], $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+154}:\\
\;\;\;\;\left(\sin y + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -3.3e19 or 2.7999999999999999e154 < z Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6488.8%
Applied rewrites88.8%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
*-lft-identityN/A
lift-fma.f64N/A
*-commutativeN/A
lift-cos.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-sin.f64N/A
+-commutativeN/A
div-addN/A
lift-cos.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites88.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6442.4%
Applied rewrites42.4%
if -3.3e19 < z < 2.7999999999999999e154Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6482.2%
Applied rewrites82.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -3.3e+19)
t_0
(if (<= z -1.55e-22)
(+ x z)
(if (<= z 7.5e-45) (+ x (sin y)) (if (<= z 2.8e+154) (+ x z) t_0))))))double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -3.3e+19) {
tmp = t_0;
} else if (z <= -1.55e-22) {
tmp = x + z;
} else if (z <= 7.5e-45) {
tmp = x + sin(y);
} else if (z <= 2.8e+154) {
tmp = x + z;
} else {
tmp = t_0;
}
return tmp;
}
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(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = z * cos(y)
if (z <= (-3.3d+19)) then
tmp = t_0
else if (z <= (-1.55d-22)) then
tmp = x + z
else if (z <= 7.5d-45) then
tmp = x + sin(y)
else if (z <= 2.8d+154) then
tmp = x + z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.cos(y);
double tmp;
if (z <= -3.3e+19) {
tmp = t_0;
} else if (z <= -1.55e-22) {
tmp = x + z;
} else if (z <= 7.5e-45) {
tmp = x + Math.sin(y);
} else if (z <= 2.8e+154) {
tmp = x + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -3.3e+19: tmp = t_0 elif z <= -1.55e-22: tmp = x + z elif z <= 7.5e-45: tmp = x + math.sin(y) elif z <= 2.8e+154: tmp = x + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -3.3e+19) tmp = t_0; elseif (z <= -1.55e-22) tmp = Float64(x + z); elseif (z <= 7.5e-45) tmp = Float64(x + sin(y)); elseif (z <= 2.8e+154) tmp = Float64(x + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -3.3e+19) tmp = t_0; elseif (z <= -1.55e-22) tmp = x + z; elseif (z <= 7.5e-45) tmp = x + sin(y); elseif (z <= 2.8e+154) tmp = x + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.3e+19], t$95$0, If[LessEqual[z, -1.55e-22], N[(x + z), $MachinePrecision], If[LessEqual[z, 7.5e-45], N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.8e+154], N[(x + z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.55 \cdot 10^{-22}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-45}:\\
\;\;\;\;x + \sin y\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+154}:\\
\;\;\;\;x + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -3.3e19 or 2.7999999999999999e154 < z Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6488.8%
Applied rewrites88.8%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
*-lft-identityN/A
lift-fma.f64N/A
*-commutativeN/A
lift-cos.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-sin.f64N/A
+-commutativeN/A
div-addN/A
lift-cos.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites88.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6442.4%
Applied rewrites42.4%
if -3.3e19 < z < -1.55000000000000006e-22 or 7.5000000000000006e-45 < z < 2.7999999999999999e154Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
if -1.55000000000000006e-22 < z < 7.5000000000000006e-45Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites25.7%
Taylor expanded in z around 0
lower-+.f64N/A
lower-sin.f6458.9%
Applied rewrites58.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (sin y))))
(if (<= y -0.0112)
t_0
(if (<= y 1.62)
(+ x (+ z (* y (+ 1.0 (* y (fma -0.5 z (* -0.16666666666666666 y)))))))
t_0))))double code(double x, double y, double z) {
double t_0 = x + sin(y);
double tmp;
if (y <= -0.0112) {
tmp = t_0;
} else if (y <= 1.62) {
tmp = x + (z + (y * (1.0 + (y * fma(-0.5, z, (-0.16666666666666666 * y))))));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + sin(y)) tmp = 0.0 if (y <= -0.0112) tmp = t_0; elseif (y <= 1.62) tmp = Float64(x + Float64(z + Float64(y * Float64(1.0 + Float64(y * fma(-0.5, z, Float64(-0.16666666666666666 * y))))))); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.0112], t$95$0, If[LessEqual[y, 1.62], N[(x + N[(z + N[(y * N[(1.0 + N[(y * N[(-0.5 * z + N[(-0.16666666666666666 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \sin y\\
\mathbf{if}\;y \leq -0.0112:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.62:\\
\;\;\;\;x + \left(z + y \cdot \left(1 + y \cdot \mathsf{fma}\left(-0.5, z, -0.16666666666666666 \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -0.0111999999999999999 or 1.6200000000000001 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites25.7%
Taylor expanded in z around 0
lower-+.f64N/A
lower-sin.f6458.9%
Applied rewrites58.9%
if -0.0111999999999999999 < y < 1.6200000000000001Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f6454.1%
Applied rewrites54.1%
(FPCore (x y z)
:precision binary64
(if (<= y -1200.0)
(+ x z)
(if (<= y 0.205)
(+ x (+ z (* y (+ 1.0 (* y (fma -0.5 z (* -0.16666666666666666 y)))))))
(+ x z))))double code(double x, double y, double z) {
double tmp;
if (y <= -1200.0) {
tmp = x + z;
} else if (y <= 0.205) {
tmp = x + (z + (y * (1.0 + (y * fma(-0.5, z, (-0.16666666666666666 * y))))));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1200.0) tmp = Float64(x + z); elseif (y <= 0.205) tmp = Float64(x + Float64(z + Float64(y * Float64(1.0 + Float64(y * fma(-0.5, z, Float64(-0.16666666666666666 * y))))))); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1200.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 0.205], N[(x + N[(z + N[(y * N[(1.0 + N[(y * N[(-0.5 * z + N[(-0.16666666666666666 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -1200:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 0.205:\\
\;\;\;\;x + \left(z + y \cdot \left(1 + y \cdot \mathsf{fma}\left(-0.5, z, -0.16666666666666666 \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if y < -1200 or 0.204999999999999988 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
if -1200 < y < 0.204999999999999988Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f6454.1%
Applied rewrites54.1%
(FPCore (x y z) :precision binary64 (+ x z))
double code(double x, double y, double z) {
return x + z;
}
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(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + z
end function
public static double code(double x, double y, double z) {
return x + z;
}
def code(x, y, z): return x + z
function code(x, y, z) return Float64(x + z) end
function tmp = code(x, y, z) tmp = x + z; end
code[x_, y_, z_] := N[(x + z), $MachinePrecision]
x + z
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
(FPCore (x y z) :precision binary64 (if (<= z -2.1e-27) z (if (<= z 1e+51) (+ x y) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e-27) {
tmp = z;
} else if (z <= 1e+51) {
tmp = x + y;
} else {
tmp = z;
}
return tmp;
}
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(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-2.1d-27)) then
tmp = z
else if (z <= 1d+51) then
tmp = x + y
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e-27) {
tmp = z;
} else if (z <= 1e+51) {
tmp = x + y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e-27: tmp = z elif z <= 1e+51: tmp = x + y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e-27) tmp = z; elseif (z <= 1e+51) tmp = Float64(x + y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.1e-27) tmp = z; elseif (z <= 1e+51) tmp = x + y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e-27], z, If[LessEqual[z, 1e+51], N[(x + y), $MachinePrecision], z]]
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{-27}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 10^{+51}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
if z < -2.10000000000000015e-27 or 1e51 < z Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites25.7%
if -2.10000000000000015e-27 < z < 1e51Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6457.2%
Applied rewrites57.2%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
associate-+r+N/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites57.2%
Taylor expanded in z around 0
lower-+.f6438.8%
Applied rewrites38.8%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
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(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
z
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites25.7%
herbie shell --seed 2025187
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
(+ (+ x (sin y)) (* z (cos y))))