
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
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)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
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)) + (z * 5.0d0)
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) + (z * 5.0);
}
def code(x, y, z): return (x * (y + z)) + (z * 5.0)
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0)) end
function tmp = code(x, y, z) tmp = (x * (y + z)) + (z * 5.0); end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}
(FPCore (x y z) :precision binary64 (fma z 5.0 (* (+ z y) x)))
double code(double x, double y, double z) {
return fma(z, 5.0, ((z + y) * x));
}
function code(x, y, z) return fma(z, 5.0, Float64(Float64(z + y) * x)) end
code[x_, y_, z_] := N[(z * 5.0 + N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, 5, \left(z + y\right) \cdot x\right)
\end{array}
Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= x -1e+211) (* (+ z y) x) (fma (- x -5.0) z (* y x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1e+211) {
tmp = (z + y) * x;
} else {
tmp = fma((x - -5.0), z, (y * x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1e+211) tmp = Float64(Float64(z + y) * x); else tmp = fma(Float64(x - -5.0), z, Float64(y * x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1e+211], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], N[(N[(x - -5.0), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+211}:\\
\;\;\;\;\left(z + y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - -5, z, y \cdot x\right)\\
\end{array}
\end{array}
if x < -9.9999999999999996e210Initial program 99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
if -9.9999999999999996e210 < x Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
*-commutativeN/A
associate-+l+N/A
+-commutativeN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
(FPCore (x y z) :precision binary64 (if (<= x -130.0) (* (+ z y) x) (if (<= x 5.0) (fma 5.0 z (* y x)) (fma x z (* y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -130.0) {
tmp = (z + y) * x;
} else if (x <= 5.0) {
tmp = fma(5.0, z, (y * x));
} else {
tmp = fma(x, z, (y * x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -130.0) tmp = Float64(Float64(z + y) * x); elseif (x <= 5.0) tmp = fma(5.0, z, Float64(y * x)); else tmp = fma(x, z, Float64(y * x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -130.0], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 5.0], N[(5.0 * z + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -130:\\
\;\;\;\;\left(z + y\right) \cdot x\\
\mathbf{elif}\;x \leq 5:\\
\;\;\;\;\mathsf{fma}\left(5, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, z, y \cdot x\right)\\
\end{array}
\end{array}
if x < -130Initial program 99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.0
Applied rewrites99.0%
if -130 < x < 5Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
*-commutativeN/A
associate-+l+N/A
+-commutativeN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites98.8%
if 5 < x Initial program 100.0%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
*-commutativeN/A
associate-+l+N/A
+-commutativeN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6498.1
Applied rewrites98.1%
Taylor expanded in x around inf
Applied rewrites96.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (+ z y) x))) (if (<= x -130.0) t_0 (if (<= x 5.0) (fma 5.0 z (* y x)) t_0))))
double code(double x, double y, double z) {
double t_0 = (z + y) * x;
double tmp;
if (x <= -130.0) {
tmp = t_0;
} else if (x <= 5.0) {
tmp = fma(5.0, z, (y * x));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z + y) * x) tmp = 0.0 if (x <= -130.0) tmp = t_0; elseif (x <= 5.0) tmp = fma(5.0, z, Float64(y * x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -130.0], t$95$0, If[LessEqual[x, 5.0], N[(5.0 * z + N[(y * x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z + y\right) \cdot x\\
\mathbf{if}\;x \leq -130:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5:\\
\;\;\;\;\mathsf{fma}\left(5, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -130 or 5 < x Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6498.9
Applied rewrites98.9%
if -130 < x < 5Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-outN/A
*-commutativeN/A
associate-+l+N/A
+-commutativeN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites98.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma z 5.0 (* z x)))) (if (<= z -1.05) t_0 (if (<= z 7.1e+31) (* (+ z y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(z, 5.0, (z * x));
double tmp;
if (z <= -1.05) {
tmp = t_0;
} else if (z <= 7.1e+31) {
tmp = (z + y) * x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(z, 5.0, Float64(z * x)) tmp = 0.0 if (z <= -1.05) tmp = t_0; elseif (z <= 7.1e+31) tmp = Float64(Float64(z + y) * x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * 5.0 + N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.05], t$95$0, If[LessEqual[z, 7.1e+31], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(z, 5, z \cdot x\right)\\
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.1 \cdot 10^{+31}:\\
\;\;\;\;\left(z + y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.05000000000000004 or 7.09999999999999961e31 < z Initial program 99.8%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutative86.5
Applied rewrites86.5%
if -1.05000000000000004 < z < 7.09999999999999961e31Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6475.5
Applied rewrites75.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- x -5.0) z))) (if (<= z -1.05) t_0 (if (<= z 7.1e+31) (* (+ z y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (x - -5.0) * z;
double tmp;
if (z <= -1.05) {
tmp = t_0;
} else if (z <= 7.1e+31) {
tmp = (z + 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 = (x - (-5.0d0)) * z
if (z <= (-1.05d0)) then
tmp = t_0
else if (z <= 7.1d+31) then
tmp = (z + 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 = (x - -5.0) * z;
double tmp;
if (z <= -1.05) {
tmp = t_0;
} else if (z <= 7.1e+31) {
tmp = (z + y) * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x - -5.0) * z tmp = 0 if z <= -1.05: tmp = t_0 elif z <= 7.1e+31: tmp = (z + y) * x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - -5.0) * z) tmp = 0.0 if (z <= -1.05) tmp = t_0; elseif (z <= 7.1e+31) tmp = Float64(Float64(z + y) * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - -5.0) * z; tmp = 0.0; if (z <= -1.05) tmp = t_0; elseif (z <= 7.1e+31) tmp = (z + y) * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.05], t$95$0, If[LessEqual[z, 7.1e+31], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - -5\right) \cdot z\\
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.1 \cdot 10^{+31}:\\
\;\;\;\;\left(z + y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.05000000000000004 or 7.09999999999999961e31 < z Initial program 99.8%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6486.4
Applied rewrites86.4%
if -1.05000000000000004 < z < 7.09999999999999961e31Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6475.5
Applied rewrites75.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- x -5.0) z))) (if (<= z -0.0052) t_0 (if (<= z 1.2e-120) (* y x) t_0))))
double code(double x, double y, double z) {
double t_0 = (x - -5.0) * z;
double tmp;
if (z <= -0.0052) {
tmp = t_0;
} else if (z <= 1.2e-120) {
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 = (x - (-5.0d0)) * z
if (z <= (-0.0052d0)) then
tmp = t_0
else if (z <= 1.2d-120) 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 = (x - -5.0) * z;
double tmp;
if (z <= -0.0052) {
tmp = t_0;
} else if (z <= 1.2e-120) {
tmp = y * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x - -5.0) * z tmp = 0 if z <= -0.0052: tmp = t_0 elif z <= 1.2e-120: tmp = y * x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - -5.0) * z) tmp = 0.0 if (z <= -0.0052) tmp = t_0; elseif (z <= 1.2e-120) tmp = Float64(y * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - -5.0) * z; tmp = 0.0; if (z <= -0.0052) tmp = t_0; elseif (z <= 1.2e-120) tmp = y * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -0.0052], t$95$0, If[LessEqual[z, 1.2e-120], N[(y * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - -5\right) \cdot z\\
\mathbf{if}\;z \leq -0.0052:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-120}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.0051999999999999998 or 1.2e-120 < z Initial program 99.8%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6480.2
Applied rewrites80.2%
if -0.0051999999999999998 < z < 1.2e-120Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6468.4
Applied rewrites68.4%
(FPCore (x y z)
:precision binary64
(if (<= x -2.6e+39)
(* x z)
(if (<= x -2.15e-44)
(* y x)
(if (<= x 3900.0) (* 5.0 z) (if (<= x 9.2e+148) (* y x) (* x z))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.6e+39) {
tmp = x * z;
} else if (x <= -2.15e-44) {
tmp = y * x;
} else if (x <= 3900.0) {
tmp = 5.0 * z;
} else if (x <= 9.2e+148) {
tmp = y * x;
} else {
tmp = x * 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 (x <= (-2.6d+39)) then
tmp = x * z
else if (x <= (-2.15d-44)) then
tmp = y * x
else if (x <= 3900.0d0) then
tmp = 5.0d0 * z
else if (x <= 9.2d+148) then
tmp = y * x
else
tmp = x * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.6e+39) {
tmp = x * z;
} else if (x <= -2.15e-44) {
tmp = y * x;
} else if (x <= 3900.0) {
tmp = 5.0 * z;
} else if (x <= 9.2e+148) {
tmp = y * x;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.6e+39: tmp = x * z elif x <= -2.15e-44: tmp = y * x elif x <= 3900.0: tmp = 5.0 * z elif x <= 9.2e+148: tmp = y * x else: tmp = x * z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.6e+39) tmp = Float64(x * z); elseif (x <= -2.15e-44) tmp = Float64(y * x); elseif (x <= 3900.0) tmp = Float64(5.0 * z); elseif (x <= 9.2e+148) tmp = Float64(y * x); else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.6e+39) tmp = x * z; elseif (x <= -2.15e-44) tmp = y * x; elseif (x <= 3900.0) tmp = 5.0 * z; elseif (x <= 9.2e+148) tmp = y * x; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.6e+39], N[(x * z), $MachinePrecision], If[LessEqual[x, -2.15e-44], N[(y * x), $MachinePrecision], If[LessEqual[x, 3900.0], N[(5.0 * z), $MachinePrecision], If[LessEqual[x, 9.2e+148], N[(y * x), $MachinePrecision], N[(x * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{+39}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-44}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \leq 3900:\\
\;\;\;\;5 \cdot z\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{+148}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
\end{array}
if x < -2.6e39 or 9.2000000000000002e148 < x Initial program 99.9%
Taylor expanded in y around 0
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6453.8
Applied rewrites53.8%
Taylor expanded in x around inf
Applied rewrites53.8%
if -2.6e39 < x < -2.15000000000000007e-44 or 3900 < x < 9.2000000000000002e148Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6452.1
Applied rewrites52.1%
if -2.15000000000000007e-44 < x < 3900Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6471.6
Applied rewrites71.6%
(FPCore (x y z) :precision binary64 (if (<= z -1.05) (* 5.0 z) (if (<= z 7.1e+31) (* y x) (* 5.0 z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = 5.0 * z;
} else if (z <= 7.1e+31) {
tmp = y * x;
} else {
tmp = 5.0 * 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 <= (-1.05d0)) then
tmp = 5.0d0 * z
else if (z <= 7.1d+31) then
tmp = y * x
else
tmp = 5.0d0 * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = 5.0 * z;
} else if (z <= 7.1e+31) {
tmp = y * x;
} else {
tmp = 5.0 * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.05: tmp = 5.0 * z elif z <= 7.1e+31: tmp = y * x else: tmp = 5.0 * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.05) tmp = Float64(5.0 * z); elseif (z <= 7.1e+31) tmp = Float64(y * x); else tmp = Float64(5.0 * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.05) tmp = 5.0 * z; elseif (z <= 7.1e+31) tmp = y * x; else tmp = 5.0 * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.05], N[(5.0 * z), $MachinePrecision], If[LessEqual[z, 7.1e+31], N[(y * x), $MachinePrecision], N[(5.0 * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;5 \cdot z\\
\mathbf{elif}\;z \leq 7.1 \cdot 10^{+31}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;5 \cdot z\\
\end{array}
\end{array}
if z < -1.05000000000000004 or 7.09999999999999961e31 < z Initial program 99.8%
Taylor expanded in x around 0
lower-*.f6447.0
Applied rewrites47.0%
if -1.05000000000000004 < z < 7.09999999999999961e31Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6462.9
Applied rewrites62.9%
(FPCore (x y z) :precision binary64 (* 5.0 z))
double code(double x, double y, double z) {
return 5.0 * 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 = 5.0d0 * z
end function
public static double code(double x, double y, double z) {
return 5.0 * z;
}
def code(x, y, z): return 5.0 * z
function code(x, y, z) return Float64(5.0 * z) end
function tmp = code(x, y, z) tmp = 5.0 * z; end
code[x_, y_, z_] := N[(5.0 * z), $MachinePrecision]
\begin{array}{l}
\\
5 \cdot z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6436.3
Applied rewrites36.3%
herbie shell --seed 2025128
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
:precision binary64
(+ (* x (+ y z)) (* z 5.0)))