
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
double code(double x, double y, double z) {
return (x * (y + z)) / 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 * (y + z)) / z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
def code(x, y, z): return (x * (y + z)) / z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\frac{x \cdot \left(y + z\right)}{z}
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
double code(double x, double y, double z) {
return (x * (y + z)) / 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 * (y + z)) / z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
def code(x, y, z): return (x * (y + z)) / z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\frac{x \cdot \left(y + z\right)}{z}
(FPCore (x y z) :precision binary64 (* (copysign 1.0 x) (if (<= (fabs x) 1e-229) (+ (/ (* y (fabs x)) z) (fabs x)) (* (/ (+ z y) z) (fabs x)))))
double code(double x, double y, double z) {
double tmp;
if (fabs(x) <= 1e-229) {
tmp = ((y * fabs(x)) / z) + fabs(x);
} else {
tmp = ((z + y) / z) * fabs(x);
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(x) <= 1e-229) {
tmp = ((y * Math.abs(x)) / z) + Math.abs(x);
} else {
tmp = ((z + y) / z) * Math.abs(x);
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(x) <= 1e-229: tmp = ((y * math.fabs(x)) / z) + math.fabs(x) else: tmp = ((z + y) / z) * math.fabs(x) return math.copysign(1.0, x) * tmp
function code(x, y, z) tmp = 0.0 if (abs(x) <= 1e-229) tmp = Float64(Float64(Float64(y * abs(x)) / z) + abs(x)); else tmp = Float64(Float64(Float64(z + y) / z) * abs(x)); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(x) <= 1e-229) tmp = ((y * abs(x)) / z) + abs(x); else tmp = ((z + y) / z) * abs(x); end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 1e-229], N[(N[(N[(y * N[Abs[x], $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[(z + y), $MachinePrecision] / z), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 10^{-229}:\\
\;\;\;\;\frac{y \cdot \left|x\right|}{z} + \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{z + y}{z} \cdot \left|x\right|\\
\end{array}
if x < 1.0000000000000001e-229Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
add-to-fraction-revN/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6494.3%
Applied rewrites94.3%
if 1.0000000000000001e-229 < x Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.15e+217) (* (/ (+ z y) z) x) (* (/ x z) (+ z y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.15e+217) {
tmp = ((z + y) / z) * x;
} else {
tmp = (x / z) * (z + 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+217) then
tmp = ((z + y) / z) * x
else
tmp = (x / z) * (z + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.15e+217) {
tmp = ((z + y) / z) * x;
} else {
tmp = (x / z) * (z + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.15e+217: tmp = ((z + y) / z) * x else: tmp = (x / z) * (z + y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.15e+217) tmp = Float64(Float64(Float64(z + y) / z) * x); else tmp = Float64(Float64(x / z) * Float64(z + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.15e+217) tmp = ((z + y) / z) * x; else tmp = (x / z) * (z + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.15e+217], N[(N[(N[(z + y), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(z + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{+217}:\\
\;\;\;\;\frac{z + y}{z} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(z + y\right)\\
\end{array}
if y < 1.1499999999999999e217Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
if 1.1499999999999999e217 < y Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6484.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.5%
Applied rewrites84.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (fabs x) z) (+ z y)))
(t_1 (/ (* (fabs x) (+ y z)) z)))
(*
(copysign 1.0 x)
(if (<= t_1 -1e+179)
(* (/ y z) (fabs x))
(if (<= t_1 0.0)
t_0
(if (<= t_1 1e-138) (* 1.0 (fabs x)) t_0))))))double code(double x, double y, double z) {
double t_0 = (fabs(x) / z) * (z + y);
double t_1 = (fabs(x) * (y + z)) / z;
double tmp;
if (t_1 <= -1e+179) {
tmp = (y / z) * fabs(x);
} else if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 1e-138) {
tmp = 1.0 * fabs(x);
} else {
tmp = t_0;
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (Math.abs(x) / z) * (z + y);
double t_1 = (Math.abs(x) * (y + z)) / z;
double tmp;
if (t_1 <= -1e+179) {
tmp = (y / z) * Math.abs(x);
} else if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 1e-138) {
tmp = 1.0 * Math.abs(x);
} else {
tmp = t_0;
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z): t_0 = (math.fabs(x) / z) * (z + y) t_1 = (math.fabs(x) * (y + z)) / z tmp = 0 if t_1 <= -1e+179: tmp = (y / z) * math.fabs(x) elif t_1 <= 0.0: tmp = t_0 elif t_1 <= 1e-138: tmp = 1.0 * math.fabs(x) else: tmp = t_0 return math.copysign(1.0, x) * tmp
function code(x, y, z) t_0 = Float64(Float64(abs(x) / z) * Float64(z + y)) t_1 = Float64(Float64(abs(x) * Float64(y + z)) / z) tmp = 0.0 if (t_1 <= -1e+179) tmp = Float64(Float64(y / z) * abs(x)); elseif (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 1e-138) tmp = Float64(1.0 * abs(x)); else tmp = t_0; end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y, z) t_0 = (abs(x) / z) * (z + y); t_1 = (abs(x) * (y + z)) / z; tmp = 0.0; if (t_1 <= -1e+179) tmp = (y / z) * abs(x); elseif (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 1e-138) tmp = 1.0 * abs(x); else tmp = t_0; end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] / z), $MachinePrecision] * N[(z + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Abs[x], $MachinePrecision] * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -1e+179], N[(N[(y / z), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 1e-138], N[(1.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision], t$95$0]]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{\left|x\right|}{z} \cdot \left(z + y\right)\\
t_1 := \frac{\left|x\right| \cdot \left(y + z\right)}{z}\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+179}:\\
\;\;\;\;\frac{y}{z} \cdot \left|x\right|\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{-138}:\\
\;\;\;\;1 \cdot \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 y z)) z) < -9.9999999999999998e178Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
Taylor expanded in y around inf
lower-/.f6448.2%
Applied rewrites48.2%
if -9.9999999999999998e178 < (/.f64 (*.f64 x (+.f64 y z)) z) < 0.0 or 1.0000000000000001e-138 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6484.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.5%
Applied rewrites84.5%
if 0.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < 1.0000000000000001e-138Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
Taylor expanded in y around 0
Applied rewrites49.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.3e-25) (* (/ y z) x) (if (<= y 1.12e-57) (* 1.0 x) (/ (* x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.3e-25) {
tmp = (y / z) * x;
} else if (y <= 1.12e-57) {
tmp = 1.0 * x;
} else {
tmp = (x * y) / 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 (y <= (-1.3d-25)) then
tmp = (y / z) * x
else if (y <= 1.12d-57) then
tmp = 1.0d0 * x
else
tmp = (x * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.3e-25) {
tmp = (y / z) * x;
} else if (y <= 1.12e-57) {
tmp = 1.0 * x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.3e-25: tmp = (y / z) * x elif y <= 1.12e-57: tmp = 1.0 * x else: tmp = (x * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.3e-25) tmp = Float64(Float64(y / z) * x); elseif (y <= 1.12e-57) tmp = Float64(1.0 * x); else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.3e-25) tmp = (y / z) * x; elseif (y <= 1.12e-57) tmp = 1.0 * x; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.3e-25], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 1.12e-57], N[(1.0 * x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-25}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{-57}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
if y < -1.3e-25Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
Taylor expanded in y around inf
lower-/.f6448.2%
Applied rewrites48.2%
if -1.3e-25 < y < 1.12e-57Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
Taylor expanded in y around 0
Applied rewrites49.8%
if 1.12e-57 < y Initial program 84.8%
Taylor expanded in y around inf
lower-*.f6448.5%
Applied rewrites48.5%
(FPCore (x y z) :precision binary64 (* (copysign 1.0 x) (if (<= (/ (* (fabs x) (+ y z)) z) -5e-208) (* (/ y z) (fabs x)) (* 1.0 (fabs x)))))
double code(double x, double y, double z) {
double tmp;
if (((fabs(x) * (y + z)) / z) <= -5e-208) {
tmp = (y / z) * fabs(x);
} else {
tmp = 1.0 * fabs(x);
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (((Math.abs(x) * (y + z)) / z) <= -5e-208) {
tmp = (y / z) * Math.abs(x);
} else {
tmp = 1.0 * Math.abs(x);
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z): tmp = 0 if ((math.fabs(x) * (y + z)) / z) <= -5e-208: tmp = (y / z) * math.fabs(x) else: tmp = 1.0 * math.fabs(x) return math.copysign(1.0, x) * tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(abs(x) * Float64(y + z)) / z) <= -5e-208) tmp = Float64(Float64(y / z) * abs(x)); else tmp = Float64(1.0 * abs(x)); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((abs(x) * (y + z)) / z) <= -5e-208) tmp = (y / z) * abs(x); else tmp = 1.0 * abs(x); end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(N[Abs[x], $MachinePrecision] * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], -5e-208], N[(N[(y / z), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left|x\right| \cdot \left(y + z\right)}{z} \leq -5 \cdot 10^{-208}:\\
\;\;\;\;\frac{y}{z} \cdot \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left|x\right|\\
\end{array}
if (/.f64 (*.f64 x (+.f64 y z)) z) < -4.9999999999999996e-208Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
Taylor expanded in y around inf
lower-/.f6448.2%
Applied rewrites48.2%
if -4.9999999999999996e-208 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
Taylor expanded in y around 0
Applied rewrites49.8%
(FPCore (x y z) :precision binary64 (* 1.0 x))
double code(double x, double y, double z) {
return 1.0 * 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 = 1.0d0 * x
end function
public static double code(double x, double y, double z) {
return 1.0 * x;
}
def code(x, y, z): return 1.0 * x
function code(x, y, z) return Float64(1.0 * x) end
function tmp = code(x, y, z) tmp = 1.0 * x; end
code[x_, y_, z_] := N[(1.0 * x), $MachinePrecision]
1 \cdot x
Initial program 84.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
Taylor expanded in y around 0
Applied rewrites49.8%
herbie shell --seed 2025258
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
(/ (* x (+ y z)) z))