
(FPCore (x y z) :precision binary64 (+ (* x y) (* z (- 1.0 y))))
double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - 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 * y) + (z * (1.0d0 - y))
end function
public static double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - y));
}
def code(x, y, z): return (x * y) + (z * (1.0 - y))
function code(x, y, z) return Float64(Float64(x * y) + Float64(z * Float64(1.0 - y))) end
function tmp = code(x, y, z) tmp = (x * y) + (z * (1.0 - y)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + z \cdot \left(1 - y\right)
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x y) (* z (- 1.0 y))))
double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - 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 * y) + (z * (1.0d0 - y))
end function
public static double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - y));
}
def code(x, y, z): return (x * y) + (z * (1.0 - y))
function code(x, y, z) return Float64(Float64(x * y) + Float64(z * Float64(1.0 - y))) end
function tmp = code(x, y, z) tmp = (x * y) + (z * (1.0 - y)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + z \cdot \left(1 - y\right)
\end{array}
(FPCore (x y z) :precision binary64 (fma (- z x) (- y) z))
double code(double x, double y, double z) {
return fma((z - x), -y, z);
}
function code(x, y, z) return fma(Float64(z - x), Float64(-y), z) end
code[x_, y_, z_] := N[(N[(z - x), $MachinePrecision] * (-y) + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - x, -y, z\right)
\end{array}
Initial program 97.8%
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (- z (* (- z x) y)))
double code(double x, double y, double z) {
return z - ((z - x) * 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 = z - ((z - x) * y)
end function
public static double code(double x, double y, double z) {
return z - ((z - x) * y);
}
def code(x, y, z): return z - ((z - x) * y)
function code(x, y, z) return Float64(z - Float64(Float64(z - x) * y)) end
function tmp = code(x, y, z) tmp = z - ((z - x) * y); end
code[x_, y_, z_] := N[(z - N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z - \left(z - x\right) \cdot y
\end{array}
Initial program 97.8%
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- x z) y))) (if (<= y -1.1) t_0 (if (<= y 7.2e-8) (fma (- x) (- y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (x - z) * y;
double tmp;
if (y <= -1.1) {
tmp = t_0;
} else if (y <= 7.2e-8) {
tmp = fma(-x, -y, z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - z) * y) tmp = 0.0 if (y <= -1.1) tmp = t_0; elseif (y <= 7.2e-8) tmp = fma(Float64(-x), Float64(-y), z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -1.1], t$95$0, If[LessEqual[y, 7.2e-8], N[((-x) * (-y) + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - z\right) \cdot y\\
\mathbf{if}\;y \leq -1.1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(-x, -y, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.1000000000000001 or 7.19999999999999962e-8 < y Initial program 97.8%
Applied rewrites100.0%
Taylor expanded in y around inf
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
sub-negate-revN/A
lower--.f6464.6
Applied rewrites64.6%
if -1.1000000000000001 < y < 7.19999999999999962e-8Initial program 97.8%
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6476.2
Applied rewrites76.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- x z) y))) (if (<= y -1.1) t_0 (if (<= y 7.2e-8) (- z (* (- x) y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (x - z) * y;
double tmp;
if (y <= -1.1) {
tmp = t_0;
} else if (y <= 7.2e-8) {
tmp = z - (-x * y);
} 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 = (x - z) * y
if (y <= (-1.1d0)) then
tmp = t_0
else if (y <= 7.2d-8) then
tmp = z - (-x * y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - z) * y;
double tmp;
if (y <= -1.1) {
tmp = t_0;
} else if (y <= 7.2e-8) {
tmp = z - (-x * y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x - z) * y tmp = 0 if y <= -1.1: tmp = t_0 elif y <= 7.2e-8: tmp = z - (-x * y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - z) * y) tmp = 0.0 if (y <= -1.1) tmp = t_0; elseif (y <= 7.2e-8) tmp = Float64(z - Float64(Float64(-x) * y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - z) * y; tmp = 0.0; if (y <= -1.1) tmp = t_0; elseif (y <= 7.2e-8) tmp = z - (-x * y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -1.1], t$95$0, If[LessEqual[y, 7.2e-8], N[(z - N[((-x) * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - z\right) \cdot y\\
\mathbf{if}\;y \leq -1.1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-8}:\\
\;\;\;\;z - \left(-x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.1000000000000001 or 7.19999999999999962e-8 < y Initial program 97.8%
Applied rewrites100.0%
Taylor expanded in y around inf
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
sub-negate-revN/A
lower--.f6464.6
Applied rewrites64.6%
if -1.1000000000000001 < y < 7.19999999999999962e-8Initial program 97.8%
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6476.2
Applied rewrites76.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- x z) y))) (if (<= y -4.6e-99) t_0 (if (<= y 1.5e-98) (* (- 1.0 y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (x - z) * y;
double tmp;
if (y <= -4.6e-99) {
tmp = t_0;
} else if (y <= 1.5e-98) {
tmp = (1.0 - y) * 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 = (x - z) * y
if (y <= (-4.6d-99)) then
tmp = t_0
else if (y <= 1.5d-98) then
tmp = (1.0d0 - y) * z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - z) * y;
double tmp;
if (y <= -4.6e-99) {
tmp = t_0;
} else if (y <= 1.5e-98) {
tmp = (1.0 - y) * z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x - z) * y tmp = 0 if y <= -4.6e-99: tmp = t_0 elif y <= 1.5e-98: tmp = (1.0 - y) * z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - z) * y) tmp = 0.0 if (y <= -4.6e-99) tmp = t_0; elseif (y <= 1.5e-98) tmp = Float64(Float64(1.0 - y) * z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - z) * y; tmp = 0.0; if (y <= -4.6e-99) tmp = t_0; elseif (y <= 1.5e-98) tmp = (1.0 - y) * z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -4.6e-99], t$95$0, If[LessEqual[y, 1.5e-98], N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - z\right) \cdot y\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{-99}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-98}:\\
\;\;\;\;\left(1 - y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.5999999999999997e-99 or 1.5e-98 < y Initial program 97.8%
Applied rewrites100.0%
Taylor expanded in y around inf
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
sub-negate-revN/A
lower--.f6464.6
Applied rewrites64.6%
if -4.5999999999999997e-99 < y < 1.5e-98Initial program 97.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6462.3
Applied rewrites62.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- 1.0 y) z))) (if (<= z -2.2e-68) t_0 (if (<= z 1.18e-57) (* y x) t_0))))
double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if (z <= -2.2e-68) {
tmp = t_0;
} else if (z <= 1.18e-57) {
tmp = y * 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 = (1.0d0 - y) * z
if (z <= (-2.2d-68)) then
tmp = t_0
else if (z <= 1.18d-57) then
tmp = y * x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if (z <= -2.2e-68) {
tmp = t_0;
} else if (z <= 1.18e-57) {
tmp = y * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 - y) * z tmp = 0 if z <= -2.2e-68: tmp = t_0 elif z <= 1.18e-57: tmp = y * x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * z) tmp = 0.0 if (z <= -2.2e-68) tmp = t_0; elseif (z <= 1.18e-57) tmp = Float64(y * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (1.0 - y) * z; tmp = 0.0; if (z <= -2.2e-68) tmp = t_0; elseif (z <= 1.18e-57) tmp = y * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.2e-68], t$95$0, If[LessEqual[z, 1.18e-57], N[(y * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - y\right) \cdot z\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{-68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.18 \cdot 10^{-57}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.20000000000000002e-68 or 1.18e-57 < z Initial program 97.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6462.3
Applied rewrites62.3%
if -2.20000000000000002e-68 < z < 1.18e-57Initial program 97.8%
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6476.2
Applied rewrites76.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6441.4
Applied rewrites41.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- y) z)))
(if (<= y -3e+200)
(* y x)
(if (<= y -1.06e+14)
t_0
(if (<= y -4.6e-99)
(* y x)
(if (<= y 1.5e-98)
z
(if (<= y 1.05e+55) (* y x) (if (<= y 4e+242) t_0 (* y x)))))))))
double code(double x, double y, double z) {
double t_0 = -y * z;
double tmp;
if (y <= -3e+200) {
tmp = y * x;
} else if (y <= -1.06e+14) {
tmp = t_0;
} else if (y <= -4.6e-99) {
tmp = y * x;
} else if (y <= 1.5e-98) {
tmp = z;
} else if (y <= 1.05e+55) {
tmp = y * x;
} else if (y <= 4e+242) {
tmp = t_0;
} else {
tmp = y * x;
}
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 = -y * z
if (y <= (-3d+200)) then
tmp = y * x
else if (y <= (-1.06d+14)) then
tmp = t_0
else if (y <= (-4.6d-99)) then
tmp = y * x
else if (y <= 1.5d-98) then
tmp = z
else if (y <= 1.05d+55) then
tmp = y * x
else if (y <= 4d+242) then
tmp = t_0
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -y * z;
double tmp;
if (y <= -3e+200) {
tmp = y * x;
} else if (y <= -1.06e+14) {
tmp = t_0;
} else if (y <= -4.6e-99) {
tmp = y * x;
} else if (y <= 1.5e-98) {
tmp = z;
} else if (y <= 1.05e+55) {
tmp = y * x;
} else if (y <= 4e+242) {
tmp = t_0;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z): t_0 = -y * z tmp = 0 if y <= -3e+200: tmp = y * x elif y <= -1.06e+14: tmp = t_0 elif y <= -4.6e-99: tmp = y * x elif y <= 1.5e-98: tmp = z elif y <= 1.05e+55: tmp = y * x elif y <= 4e+242: tmp = t_0 else: tmp = y * x return tmp
function code(x, y, z) t_0 = Float64(Float64(-y) * z) tmp = 0.0 if (y <= -3e+200) tmp = Float64(y * x); elseif (y <= -1.06e+14) tmp = t_0; elseif (y <= -4.6e-99) tmp = Float64(y * x); elseif (y <= 1.5e-98) tmp = z; elseif (y <= 1.05e+55) tmp = Float64(y * x); elseif (y <= 4e+242) tmp = t_0; else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = -y * z; tmp = 0.0; if (y <= -3e+200) tmp = y * x; elseif (y <= -1.06e+14) tmp = t_0; elseif (y <= -4.6e-99) tmp = y * x; elseif (y <= 1.5e-98) tmp = z; elseif (y <= 1.05e+55) tmp = y * x; elseif (y <= 4e+242) tmp = t_0; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-y) * z), $MachinePrecision]}, If[LessEqual[y, -3e+200], N[(y * x), $MachinePrecision], If[LessEqual[y, -1.06e+14], t$95$0, If[LessEqual[y, -4.6e-99], N[(y * x), $MachinePrecision], If[LessEqual[y, 1.5e-98], z, If[LessEqual[y, 1.05e+55], N[(y * x), $MachinePrecision], If[LessEqual[y, 4e+242], t$95$0, N[(y * x), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-y\right) \cdot z\\
\mathbf{if}\;y \leq -3 \cdot 10^{+200}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq -1.06 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.6 \cdot 10^{-99}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-98}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+55}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+242}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -2.99999999999999991e200 or -1.06e14 < y < -4.5999999999999997e-99 or 1.5e-98 < y < 1.05e55 or 4.0000000000000002e242 < y Initial program 97.8%
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6476.2
Applied rewrites76.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6441.4
Applied rewrites41.4%
if -2.99999999999999991e200 < y < -1.06e14 or 1.05e55 < y < 4.0000000000000002e242Initial program 97.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6462.3
Applied rewrites62.3%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lift-neg.f6427.5
Applied rewrites27.5%
if -4.5999999999999997e-99 < y < 1.5e-98Initial program 97.8%
Taylor expanded in y around 0
Applied rewrites37.2%
(FPCore (x y z) :precision binary64 (if (<= y -4.6e-99) (* y x) (if (<= y 1.5e-98) z (* y x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.6e-99) {
tmp = y * x;
} else if (y <= 1.5e-98) {
tmp = z;
} else {
tmp = y * x;
}
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 (y <= (-4.6d-99)) then
tmp = y * x
else if (y <= 1.5d-98) then
tmp = z
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.6e-99) {
tmp = y * x;
} else if (y <= 1.5e-98) {
tmp = z;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.6e-99: tmp = y * x elif y <= 1.5e-98: tmp = z else: tmp = y * x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.6e-99) tmp = Float64(y * x); elseif (y <= 1.5e-98) tmp = z; else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.6e-99) tmp = y * x; elseif (y <= 1.5e-98) tmp = z; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.6e-99], N[(y * x), $MachinePrecision], If[LessEqual[y, 1.5e-98], z, N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{-99}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-98}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < -4.5999999999999997e-99 or 1.5e-98 < y Initial program 97.8%
Applied rewrites100.0%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6476.2
Applied rewrites76.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6441.4
Applied rewrites41.4%
if -4.5999999999999997e-99 < y < 1.5e-98Initial program 97.8%
Taylor expanded in y around 0
Applied rewrites37.2%
(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
\begin{array}{l}
\\
z
\end{array}
Initial program 97.8%
Taylor expanded in y around 0
Applied rewrites37.2%
herbie shell --seed 2025135
(FPCore (x y z)
:name "Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3"
:precision binary64
(+ (* x y) (* z (- 1.0 y))))