
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
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) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
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) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
(FPCore (x y z) :precision binary64 (fma y 2.0 (fma 3.0 x z)))
double code(double x, double y, double z) {
return fma(y, 2.0, fma(3.0, x, z));
}
function code(x, y, z) return fma(y, 2.0, fma(3.0, x, z)) end
code[x_, y_, z_] := N[(y * 2.0 + N[(3.0 * x + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, 2, \mathsf{fma}\left(3, x, z\right)\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+l+N/A
+-commutativeN/A
count-2-revN/A
distribute-lft-outN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= y -9e-37) (fma 2.0 y z) (if (<= y 1.05e+161) (fma 3.0 x z) (fma 2.0 y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9e-37) {
tmp = fma(2.0, y, z);
} else if (y <= 1.05e+161) {
tmp = fma(3.0, x, z);
} else {
tmp = fma(2.0, y, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -9e-37) tmp = fma(2.0, y, z); elseif (y <= 1.05e+161) tmp = fma(3.0, x, z); else tmp = fma(2.0, y, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -9e-37], N[(2.0 * y + z), $MachinePrecision], If[LessEqual[y, 1.05e+161], N[(3.0 * x + z), $MachinePrecision], N[(2.0 * y + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+161}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\end{array}
\end{array}
if y < -9.00000000000000081e-37 or 1.05e161 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6480.6
Applied rewrites80.6%
if -9.00000000000000081e-37 < y < 1.05e161Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f6485.0
Applied rewrites85.0%
(FPCore (x y z) :precision binary64 (if (<= x -4e+190) (* 3.0 x) (if (<= x 2.2e+168) (fma 2.0 y z) (* 3.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4e+190) {
tmp = 3.0 * x;
} else if (x <= 2.2e+168) {
tmp = fma(2.0, y, z);
} else {
tmp = 3.0 * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -4e+190) tmp = Float64(3.0 * x); elseif (x <= 2.2e+168) tmp = fma(2.0, y, z); else tmp = Float64(3.0 * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4e+190], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, 2.2e+168], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+190}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+168}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -4.0000000000000003e190 or 2.2000000000000002e168 < x Initial program 99.8%
Taylor expanded in x around inf
lower-*.f6478.5
Applied rewrites78.5%
if -4.0000000000000003e190 < x < 2.2000000000000002e168Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6479.6
Applied rewrites79.6%
(FPCore (x y z)
:precision binary64
(if (<= y -1.8e+36)
(* 2.0 y)
(if (<= y -5.2e-64)
(+ z x)
(if (<= y 1e-191) (* 3.0 x) (if (<= y 1.02e+166) (+ z x) (* 2.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+36) {
tmp = 2.0 * y;
} else if (y <= -5.2e-64) {
tmp = z + x;
} else if (y <= 1e-191) {
tmp = 3.0 * x;
} else if (y <= 1.02e+166) {
tmp = z + x;
} else {
tmp = 2.0 * y;
}
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 <= (-1.8d+36)) then
tmp = 2.0d0 * y
else if (y <= (-5.2d-64)) then
tmp = z + x
else if (y <= 1d-191) then
tmp = 3.0d0 * x
else if (y <= 1.02d+166) then
tmp = z + x
else
tmp = 2.0d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+36) {
tmp = 2.0 * y;
} else if (y <= -5.2e-64) {
tmp = z + x;
} else if (y <= 1e-191) {
tmp = 3.0 * x;
} else if (y <= 1.02e+166) {
tmp = z + x;
} else {
tmp = 2.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.8e+36: tmp = 2.0 * y elif y <= -5.2e-64: tmp = z + x elif y <= 1e-191: tmp = 3.0 * x elif y <= 1.02e+166: tmp = z + x else: tmp = 2.0 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.8e+36) tmp = Float64(2.0 * y); elseif (y <= -5.2e-64) tmp = Float64(z + x); elseif (y <= 1e-191) tmp = Float64(3.0 * x); elseif (y <= 1.02e+166) tmp = Float64(z + x); else tmp = Float64(2.0 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.8e+36) tmp = 2.0 * y; elseif (y <= -5.2e-64) tmp = z + x; elseif (y <= 1e-191) tmp = 3.0 * x; elseif (y <= 1.02e+166) tmp = z + x; else tmp = 2.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+36], N[(2.0 * y), $MachinePrecision], If[LessEqual[y, -5.2e-64], N[(z + x), $MachinePrecision], If[LessEqual[y, 1e-191], N[(3.0 * x), $MachinePrecision], If[LessEqual[y, 1.02e+166], N[(z + x), $MachinePrecision], N[(2.0 * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+36}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-64}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 10^{-191}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+166}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;2 \cdot y\\
\end{array}
\end{array}
if y < -1.7999999999999999e36 or 1.0200000000000001e166 < y Initial program 99.9%
Taylor expanded in y around inf
lower-*.f6467.0
Applied rewrites67.0%
if -1.7999999999999999e36 < y < -5.2e-64 or 1e-191 < y < 1.0200000000000001e166Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites44.4%
if -5.2e-64 < y < 1e-191Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6448.3
Applied rewrites48.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.15e+36) (* 2.0 y) (if (<= y -5.2e-64) z (if (<= y 1.05e+161) (* 3.0 x) (* 2.0 y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+36) {
tmp = 2.0 * y;
} else if (y <= -5.2e-64) {
tmp = z;
} else if (y <= 1.05e+161) {
tmp = 3.0 * x;
} else {
tmp = 2.0 * y;
}
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 <= (-1.15d+36)) then
tmp = 2.0d0 * y
else if (y <= (-5.2d-64)) then
tmp = z
else if (y <= 1.05d+161) then
tmp = 3.0d0 * x
else
tmp = 2.0d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+36) {
tmp = 2.0 * y;
} else if (y <= -5.2e-64) {
tmp = z;
} else if (y <= 1.05e+161) {
tmp = 3.0 * x;
} else {
tmp = 2.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.15e+36: tmp = 2.0 * y elif y <= -5.2e-64: tmp = z elif y <= 1.05e+161: tmp = 3.0 * x else: tmp = 2.0 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.15e+36) tmp = Float64(2.0 * y); elseif (y <= -5.2e-64) tmp = z; elseif (y <= 1.05e+161) tmp = Float64(3.0 * x); else tmp = Float64(2.0 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.15e+36) tmp = 2.0 * y; elseif (y <= -5.2e-64) tmp = z; elseif (y <= 1.05e+161) tmp = 3.0 * x; else tmp = 2.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.15e+36], N[(2.0 * y), $MachinePrecision], If[LessEqual[y, -5.2e-64], z, If[LessEqual[y, 1.05e+161], N[(3.0 * x), $MachinePrecision], N[(2.0 * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+36}:\\
\;\;\;\;2 \cdot y\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-64}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+161}:\\
\;\;\;\;3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;2 \cdot y\\
\end{array}
\end{array}
if y < -1.14999999999999998e36 or 1.05e161 < y Initial program 99.9%
Taylor expanded in y around inf
lower-*.f6466.8
Applied rewrites66.8%
if -1.14999999999999998e36 < y < -5.2e-64Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites40.1%
if -5.2e-64 < y < 1.05e161Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6442.8
Applied rewrites42.8%
(FPCore (x y z) :precision binary64 (if (<= z -44000000.0) z (if (<= z 1.95e+95) (* 2.0 y) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -44000000.0) {
tmp = z;
} else if (z <= 1.95e+95) {
tmp = 2.0 * 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 <= (-44000000.0d0)) then
tmp = z
else if (z <= 1.95d+95) then
tmp = 2.0d0 * y
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -44000000.0) {
tmp = z;
} else if (z <= 1.95e+95) {
tmp = 2.0 * y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -44000000.0: tmp = z elif z <= 1.95e+95: tmp = 2.0 * y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -44000000.0) tmp = z; elseif (z <= 1.95e+95) tmp = Float64(2.0 * y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -44000000.0) tmp = z; elseif (z <= 1.95e+95) tmp = 2.0 * y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -44000000.0], z, If[LessEqual[z, 1.95e+95], N[(2.0 * y), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -44000000:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+95}:\\
\;\;\;\;2 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -4.4e7 or 1.9499999999999999e95 < z Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites64.1%
if -4.4e7 < z < 1.9499999999999999e95Initial program 99.9%
Taylor expanded in y around inf
lower-*.f6445.4
Applied rewrites45.4%
(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 99.9%
Taylor expanded in z around inf
Applied rewrites34.6%
herbie shell --seed 2025101
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
:precision binary64
(+ (+ (+ (+ (+ x y) y) x) z) x))