
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
return fabs((((x + 4.0) / y) - ((x / y) * 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 = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z): return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) / y) - ((x / y) * z))); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
return fabs((((x + 4.0) / y) - ((x / y) * 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 = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z): return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) / y) - ((x / y) * z))); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
(FPCore (x y z) :precision binary64 (if (<= (fabs y) 4e-79) (fabs (/ (- (fma z x -4.0) x) (fabs y))) (fabs (- (/ (+ x 4.0) (fabs y)) (* (/ x (fabs y)) z)))))
double code(double x, double y, double z) {
double tmp;
if (fabs(y) <= 4e-79) {
tmp = fabs(((fma(z, x, -4.0) - x) / fabs(y)));
} else {
tmp = fabs((((x + 4.0) / fabs(y)) - ((x / fabs(y)) * z)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (abs(y) <= 4e-79) tmp = abs(Float64(Float64(fma(z, x, -4.0) - x) / abs(y))); else tmp = abs(Float64(Float64(Float64(x + 4.0) / abs(y)) - Float64(Float64(x / abs(y)) * z))); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[Abs[y], $MachinePrecision], 4e-79], N[Abs[N[(N[(N[(z * x + -4.0), $MachinePrecision] - x), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision] - N[(N[(x / N[Abs[y], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|y\right| \leq 4 \cdot 10^{-79}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right) - x}{\left|y\right|}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{\left|y\right|} - \frac{x}{\left|y\right|} \cdot z\right|\\
\end{array}
if y < 4e-79Initial program 91.6%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6496.0%
Applied rewrites96.0%
if 4e-79 < y Initial program 91.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* (/ (- 1.0 z) y) x))))
(if (<= x -24000000.0)
t_0
(if (<= x 6.2) (fabs (/ (- (* z x) 4.0) y)) t_0))))double code(double x, double y, double z) {
double t_0 = fabs((((1.0 - z) / y) * x));
double tmp;
if (x <= -24000000.0) {
tmp = t_0;
} else if (x <= 6.2) {
tmp = fabs((((z * x) - 4.0) / 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 = abs((((1.0d0 - z) / y) * x))
if (x <= (-24000000.0d0)) then
tmp = t_0
else if (x <= 6.2d0) then
tmp = abs((((z * x) - 4.0d0) / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((((1.0 - z) / y) * x));
double tmp;
if (x <= -24000000.0) {
tmp = t_0;
} else if (x <= 6.2) {
tmp = Math.abs((((z * x) - 4.0) / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((((1.0 - z) / y) * x)) tmp = 0 if x <= -24000000.0: tmp = t_0 elif x <= 6.2: tmp = math.fabs((((z * x) - 4.0) / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(Float64(Float64(1.0 - z) / y) * x)) tmp = 0.0 if (x <= -24000000.0) tmp = t_0; elseif (x <= 6.2) tmp = abs(Float64(Float64(Float64(z * x) - 4.0) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((((1.0 - z) / y) * x)); tmp = 0.0; if (x <= -24000000.0) tmp = t_0; elseif (x <= 6.2) tmp = abs((((z * x) - 4.0) / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -24000000.0], t$95$0, If[LessEqual[x, 6.2], N[Abs[N[(N[(N[(z * x), $MachinePrecision] - 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left|\frac{1 - z}{y} \cdot x\right|\\
\mathbf{if}\;x \leq -24000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.2:\\
\;\;\;\;\left|\frac{z \cdot x - 4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.4e7 or 6.20000000000000018 < x Initial program 91.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.7%
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
sub-divN/A
lift--.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
if -2.4e7 < x < 6.20000000000000018Initial program 91.6%
Taylor expanded in x around 0
Applied rewrites79.4%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6473.6%
Applied rewrites73.6%
(FPCore (x y z) :precision binary64 (if (<= x -1e+114) (fabs (* (/ (- 1.0 z) 1.0) (/ x y))) (fabs (/ (- (fma z x -4.0) x) y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1e+114) {
tmp = fabs((((1.0 - z) / 1.0) * (x / y)));
} else {
tmp = fabs(((fma(z, x, -4.0) - x) / y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1e+114) tmp = abs(Float64(Float64(Float64(1.0 - z) / 1.0) * Float64(x / y))); else tmp = abs(Float64(Float64(fma(z, x, -4.0) - x) / y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1e+114], N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] / 1.0), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(z * x + -4.0), $MachinePrecision] - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+114}:\\
\;\;\;\;\left|\frac{1 - z}{1} \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right) - x}{y}\right|\\
\end{array}
if x < -1e114Initial program 91.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
sub-divN/A
lift--.f64N/A
associate-*r/N/A
*-lft-identityN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6461.5%
Applied rewrites61.5%
if -1e114 < x Initial program 91.6%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6496.0%
Applied rewrites96.0%
(FPCore (x y z) :precision binary64 (if (<= x -1e+114) (fabs (* (/ (- 1.0 z) y) x)) (fabs (/ (- (fma z x -4.0) x) y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1e+114) {
tmp = fabs((((1.0 - z) / y) * x));
} else {
tmp = fabs(((fma(z, x, -4.0) - x) / y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1e+114) tmp = abs(Float64(Float64(Float64(1.0 - z) / y) * x)); else tmp = abs(Float64(Float64(fma(z, x, -4.0) - x) / y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1e+114], N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(z * x + -4.0), $MachinePrecision] - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+114}:\\
\;\;\;\;\left|\frac{1 - z}{y} \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right) - x}{y}\right|\\
\end{array}
if x < -1e114Initial program 91.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.7%
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
sub-divN/A
lift--.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
if -1e114 < x Initial program 91.6%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6496.0%
Applied rewrites96.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fabs (* (/ (- 1.0 z) y) x)))) (if (<= x -0.000145) t_0 (if (<= x 9e-10) (fabs (/ (- -4.0 x) y)) t_0))))
double code(double x, double y, double z) {
double t_0 = fabs((((1.0 - z) / y) * x));
double tmp;
if (x <= -0.000145) {
tmp = t_0;
} else if (x <= 9e-10) {
tmp = fabs(((-4.0 - 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 = abs((((1.0d0 - z) / y) * x))
if (x <= (-0.000145d0)) then
tmp = t_0
else if (x <= 9d-10) then
tmp = abs((((-4.0d0) - 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 = Math.abs((((1.0 - z) / y) * x));
double tmp;
if (x <= -0.000145) {
tmp = t_0;
} else if (x <= 9e-10) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((((1.0 - z) / y) * x)) tmp = 0 if x <= -0.000145: tmp = t_0 elif x <= 9e-10: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(Float64(Float64(1.0 - z) / y) * x)) tmp = 0.0 if (x <= -0.000145) tmp = t_0; elseif (x <= 9e-10) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((((1.0 - z) / y) * x)); tmp = 0.0; if (x <= -0.000145) tmp = t_0; elseif (x <= 9e-10) tmp = abs(((-4.0 - x) / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -0.000145], t$95$0, If[LessEqual[x, 9e-10], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left|\frac{1 - z}{y} \cdot x\right|\\
\mathbf{if}\;x \leq -0.000145:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-10}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -1.45e-4 or 8.9999999999999999e-10 < x Initial program 91.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.7%
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
sub-divN/A
lift--.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
if -1.45e-4 < x < 8.9999999999999999e-10Initial program 91.6%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
Taylor expanded in z around 0
lower-*.f64N/A
lower-+.f6470.2%
Applied rewrites70.2%
lift-*.f64N/A
mul-1-negN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f6470.2%
Applied rewrites70.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fabs (* (/ x y) z)))) (if (<= z -2.2e+133) t_0 (if (<= z 4.7e+53) (fabs (/ (- -4.0 x) y)) t_0))))
double code(double x, double y, double z) {
double t_0 = fabs(((x / y) * z));
double tmp;
if (z <= -2.2e+133) {
tmp = t_0;
} else if (z <= 4.7e+53) {
tmp = fabs(((-4.0 - 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 = abs(((x / y) * z))
if (z <= (-2.2d+133)) then
tmp = t_0
else if (z <= 4.7d+53) then
tmp = abs((((-4.0d0) - 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 = Math.abs(((x / y) * z));
double tmp;
if (z <= -2.2e+133) {
tmp = t_0;
} else if (z <= 4.7e+53) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(((x / y) * z)) tmp = 0 if z <= -2.2e+133: tmp = t_0 elif z <= 4.7e+53: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(Float64(x / y) * z)) tmp = 0.0 if (z <= -2.2e+133) tmp = t_0; elseif (z <= 4.7e+53) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(((x / y) * z)); tmp = 0.0; if (z <= -2.2e+133) tmp = t_0; elseif (z <= 4.7e+53) tmp = abs(((-4.0 - x) / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -2.2e+133], t$95$0, If[LessEqual[z, 4.7e+53], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left|\frac{x}{y} \cdot z\right|\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{+133}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.7 \cdot 10^{+53}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -2.2e133 or 4.69999999999999976e53 < z Initial program 91.6%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6496.0%
Applied rewrites96.0%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6437.5%
Applied rewrites37.5%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6443.5%
Applied rewrites43.5%
if -2.2e133 < z < 4.69999999999999976e53Initial program 91.6%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
Taylor expanded in z around 0
lower-*.f64N/A
lower-+.f6470.2%
Applied rewrites70.2%
lift-*.f64N/A
mul-1-negN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f6470.2%
Applied rewrites70.2%
(FPCore (x y z) :precision binary64 (fabs (/ (- -4.0 x) y)))
double code(double x, double y, double z) {
return fabs(((-4.0 - 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 = abs((((-4.0d0) - x) / y))
end function
public static double code(double x, double y, double z) {
return Math.abs(((-4.0 - x) / y));
}
def code(x, y, z): return math.fabs(((-4.0 - x) / y))
function code(x, y, z) return abs(Float64(Float64(-4.0 - x) / y)) end
function tmp = code(x, y, z) tmp = abs(((-4.0 - x) / y)); end
code[x_, y_, z_] := N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\left|\frac{-4 - x}{y}\right|
Initial program 91.6%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
Taylor expanded in z around 0
lower-*.f64N/A
lower-+.f6470.2%
Applied rewrites70.2%
lift-*.f64N/A
mul-1-negN/A
lift-+.f64N/A
distribute-neg-outN/A
metadata-evalN/A
sub-flipN/A
lift--.f6470.2%
Applied rewrites70.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fabs (/ x y)))) (if (<= x -210000.0) t_0 (if (<= x 6.2) (fabs (/ 4.0 y)) t_0))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -210000.0) {
tmp = t_0;
} else if (x <= 6.2) {
tmp = fabs((4.0 / 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 = abs((x / y))
if (x <= (-210000.0d0)) then
tmp = t_0
else if (x <= 6.2d0) then
tmp = abs((4.0d0 / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double tmp;
if (x <= -210000.0) {
tmp = t_0;
} else if (x <= 6.2) {
tmp = Math.abs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -210000.0: tmp = t_0 elif x <= 6.2: tmp = math.fabs((4.0 / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -210000.0) tmp = t_0; elseif (x <= 6.2) tmp = abs(Float64(4.0 / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); tmp = 0.0; if (x <= -210000.0) tmp = t_0; elseif (x <= 6.2) tmp = abs((4.0 / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -210000.0], t$95$0, If[LessEqual[x, 6.2], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -210000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.2:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.1e5 or 6.20000000000000018 < x Initial program 91.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
Taylor expanded in z around 0
lower-/.f6434.1%
Applied rewrites34.1%
if -2.1e5 < x < 6.20000000000000018Initial program 91.6%
Taylor expanded in x around 0
lower-/.f6440.2%
Applied rewrites40.2%
(FPCore (x y z) :precision binary64 (fabs (/ x y)))
double code(double x, double y, double z) {
return fabs((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 = abs((x / y))
end function
public static double code(double x, double y, double z) {
return Math.abs((x / y));
}
def code(x, y, z): return math.fabs((x / y))
function code(x, y, z) return abs(Float64(x / y)) end
function tmp = code(x, y, z) tmp = abs((x / y)); end
code[x_, y_, z_] := N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]
\left|\frac{x}{y}\right|
Initial program 91.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6461.7%
Applied rewrites61.7%
Taylor expanded in z around 0
lower-/.f6434.1%
Applied rewrites34.1%
herbie shell --seed 2025185
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))