
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * 2.0d0) / ((y * z) - (t * z))
end function
public static double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
def code(x, y, z, t): return (x * 2.0) / ((y * z) - (t * z))
function code(x, y, z, t) return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x * 2.0) / ((y * z) - (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * 2.0d0) / ((y * z) - (t * z))
end function
public static double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
def code(x, y, z, t): return (x * 2.0) / ((y * z) - (t * z))
function code(x, y, z, t) return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x * 2.0) / ((y * z) - (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\end{array}
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m t) :precision binary64 (* z_s (if (<= z_m 2e-15) (/ (+ x x) (* (- y t) z_m)) (/ (/ (+ x x) z_m) (- y t)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2e-15) {
tmp = (x + x) / ((y - t) * z_m);
} else {
tmp = ((x + x) / z_m) / (y - t);
}
return z_s * tmp;
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (z_m <= 2d-15) then
tmp = (x + x) / ((y - t) * z_m)
else
tmp = ((x + x) / z_m) / (y - t)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2e-15) {
tmp = (x + x) / ((y - t) * z_m);
} else {
tmp = ((x + x) / z_m) / (y - t);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if z_m <= 2e-15: tmp = (x + x) / ((y - t) * z_m) else: tmp = ((x + x) / z_m) / (y - t) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (z_m <= 2e-15) tmp = Float64(Float64(x + x) / Float64(Float64(y - t) * z_m)); else tmp = Float64(Float64(Float64(x + x) / z_m) / Float64(y - t)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (z_m <= 2e-15) tmp = (x + x) / ((y - t) * z_m); else tmp = ((x + x) / z_m) / (y - t); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[z$95$m, 2e-15], N[(N[(x + x), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + x), $MachinePrecision] / z$95$m), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2 \cdot 10^{-15}:\\
\;\;\;\;\frac{x + x}{\left(y - t\right) \cdot z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + x}{z\_m}}{y - t}\\
\end{array}
\end{array}
if z < 2.0000000000000002e-15Initial program 95.8%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6495.8
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6497.1
Applied rewrites97.1%
if 2.0000000000000002e-15 < z Initial program 82.7%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
associate-*r/N/A
distribute-rgt-out--N/A
count-2-revN/A
associate-/r*N/A
associate-/r*N/A
div-add-revN/A
count-2-revN/A
lower-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lower--.f6496.9
Applied rewrites96.9%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m t) :precision binary64 (* z_s (/ (+ x x) (* (- y t) z_m))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
return z_s * ((x + x) / ((y - t) * z_m));
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
code = z_s * ((x + x) / ((y - t) * z_m))
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
return z_s * ((x + x) / ((y - t) * z_m));
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): return z_s * ((x + x) / ((y - t) * z_m))
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) return Float64(z_s * Float64(Float64(x + x) / Float64(Float64(y - t) * z_m))) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m, t) tmp = z_s * ((x + x) / ((y - t) * z_m)); end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * N[(N[(x + x), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \frac{x + x}{\left(y - t\right) \cdot z\_m}
\end{array}
Initial program 88.9%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6488.9
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.2
Applied rewrites91.2%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(*
z_s
(if (<= t -3.7e-39)
(* (/ (/ x t) z_m) -2.0)
(if (<= t 7.0) (/ (+ x x) (* z_m y)) (/ (/ (+ x x) z_m) (- t))))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (t <= -3.7e-39) {
tmp = ((x / t) / z_m) * -2.0;
} else if (t <= 7.0) {
tmp = (x + x) / (z_m * y);
} else {
tmp = ((x + x) / z_m) / -t;
}
return z_s * tmp;
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-3.7d-39)) then
tmp = ((x / t) / z_m) * (-2.0d0)
else if (t <= 7.0d0) then
tmp = (x + x) / (z_m * y)
else
tmp = ((x + x) / z_m) / -t
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (t <= -3.7e-39) {
tmp = ((x / t) / z_m) * -2.0;
} else if (t <= 7.0) {
tmp = (x + x) / (z_m * y);
} else {
tmp = ((x + x) / z_m) / -t;
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if t <= -3.7e-39: tmp = ((x / t) / z_m) * -2.0 elif t <= 7.0: tmp = (x + x) / (z_m * y) else: tmp = ((x + x) / z_m) / -t return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (t <= -3.7e-39) tmp = Float64(Float64(Float64(x / t) / z_m) * -2.0); elseif (t <= 7.0) tmp = Float64(Float64(x + x) / Float64(z_m * y)); else tmp = Float64(Float64(Float64(x + x) / z_m) / Float64(-t)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (t <= -3.7e-39) tmp = ((x / t) / z_m) * -2.0; elseif (t <= 7.0) tmp = (x + x) / (z_m * y); else tmp = ((x + x) / z_m) / -t; end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[t, -3.7e-39], N[(N[(N[(x / t), $MachinePrecision] / z$95$m), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[t, 7.0], N[(N[(x + x), $MachinePrecision] / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + x), $MachinePrecision] / z$95$m), $MachinePrecision] / (-t)), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq -3.7 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{x}{t}}{z\_m} \cdot -2\\
\mathbf{elif}\;t \leq 7:\\
\;\;\;\;\frac{x + x}{z\_m \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + x}{z\_m}}{-t}\\
\end{array}
\end{array}
if t < -3.70000000000000015e-39Initial program 87.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f6471.3
Applied rewrites71.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.2
Applied rewrites73.2%
if -3.70000000000000015e-39 < t < 7Initial program 91.6%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6474.0
Applied rewrites74.0%
if 7 < t Initial program 85.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
associate-*r/N/A
distribute-rgt-out--N/A
count-2-revN/A
associate-/r*N/A
associate-/r*N/A
div-add-revN/A
count-2-revN/A
lower-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lower--.f6490.8
Applied rewrites90.8%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6474.1
Applied rewrites74.1%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(*
z_s
(if (<= t -3.7e-39)
(* (/ (/ x t) z_m) -2.0)
(if (<= t 7.0) (/ (+ x x) (* z_m y)) (* (/ x z_m) (/ -2.0 t))))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (t <= -3.7e-39) {
tmp = ((x / t) / z_m) * -2.0;
} else if (t <= 7.0) {
tmp = (x + x) / (z_m * y);
} else {
tmp = (x / z_m) * (-2.0 / t);
}
return z_s * tmp;
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-3.7d-39)) then
tmp = ((x / t) / z_m) * (-2.0d0)
else if (t <= 7.0d0) then
tmp = (x + x) / (z_m * y)
else
tmp = (x / z_m) * ((-2.0d0) / t)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (t <= -3.7e-39) {
tmp = ((x / t) / z_m) * -2.0;
} else if (t <= 7.0) {
tmp = (x + x) / (z_m * y);
} else {
tmp = (x / z_m) * (-2.0 / t);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if t <= -3.7e-39: tmp = ((x / t) / z_m) * -2.0 elif t <= 7.0: tmp = (x + x) / (z_m * y) else: tmp = (x / z_m) * (-2.0 / t) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (t <= -3.7e-39) tmp = Float64(Float64(Float64(x / t) / z_m) * -2.0); elseif (t <= 7.0) tmp = Float64(Float64(x + x) / Float64(z_m * y)); else tmp = Float64(Float64(x / z_m) * Float64(-2.0 / t)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (t <= -3.7e-39) tmp = ((x / t) / z_m) * -2.0; elseif (t <= 7.0) tmp = (x + x) / (z_m * y); else tmp = (x / z_m) * (-2.0 / t); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[t, -3.7e-39], N[(N[(N[(x / t), $MachinePrecision] / z$95$m), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[t, 7.0], N[(N[(x + x), $MachinePrecision] / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision], N[(N[(x / z$95$m), $MachinePrecision] * N[(-2.0 / t), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq -3.7 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{x}{t}}{z\_m} \cdot -2\\
\mathbf{elif}\;t \leq 7:\\
\;\;\;\;\frac{x + x}{z\_m \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z\_m} \cdot \frac{-2}{t}\\
\end{array}
\end{array}
if t < -3.70000000000000015e-39Initial program 87.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f6471.3
Applied rewrites71.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.2
Applied rewrites73.2%
if -3.70000000000000015e-39 < t < 7Initial program 91.6%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6474.0
Applied rewrites74.0%
if 7 < t Initial program 85.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
distribute-rgt-out--N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f6490.7
Applied rewrites90.7%
Taylor expanded in y around 0
lower-/.f6474.0
Applied rewrites74.0%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(let* ((t_1 (* x (/ (/ 2.0 y) z_m))))
(*
z_s
(if (<= y -3.1e+42)
t_1
(if (<= y 1.75e-13) (* (/ (/ x t) z_m) -2.0) t_1)))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double t_1 = x * ((2.0 / y) / z_m);
double tmp;
if (y <= -3.1e+42) {
tmp = t_1;
} else if (y <= 1.75e-13) {
tmp = ((x / t) / z_m) * -2.0;
} else {
tmp = t_1;
}
return z_s * tmp;
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x * ((2.0d0 / y) / z_m)
if (y <= (-3.1d+42)) then
tmp = t_1
else if (y <= 1.75d-13) then
tmp = ((x / t) / z_m) * (-2.0d0)
else
tmp = t_1
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double t_1 = x * ((2.0 / y) / z_m);
double tmp;
if (y <= -3.1e+42) {
tmp = t_1;
} else if (y <= 1.75e-13) {
tmp = ((x / t) / z_m) * -2.0;
} else {
tmp = t_1;
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): t_1 = x * ((2.0 / y) / z_m) tmp = 0 if y <= -3.1e+42: tmp = t_1 elif y <= 1.75e-13: tmp = ((x / t) / z_m) * -2.0 else: tmp = t_1 return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) t_1 = Float64(x * Float64(Float64(2.0 / y) / z_m)) tmp = 0.0 if (y <= -3.1e+42) tmp = t_1; elseif (y <= 1.75e-13) tmp = Float64(Float64(Float64(x / t) / z_m) * -2.0); else tmp = t_1; end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) t_1 = x * ((2.0 / y) / z_m); tmp = 0.0; if (y <= -3.1e+42) tmp = t_1; elseif (y <= 1.75e-13) tmp = ((x / t) / z_m) * -2.0; else tmp = t_1; end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(x * N[(N[(2.0 / y), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]}, N[(z$95$s * If[LessEqual[y, -3.1e+42], t$95$1, If[LessEqual[y, 1.75e-13], N[(N[(N[(x / t), $MachinePrecision] / z$95$m), $MachinePrecision] * -2.0), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
\begin{array}{l}
t_1 := x \cdot \frac{\frac{2}{y}}{z\_m}\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+42}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{x}{t}}{z\_m} \cdot -2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if y < -3.1000000000000002e42 or 1.7500000000000001e-13 < y Initial program 86.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6489.4
Applied rewrites89.4%
Taylor expanded in y around inf
Applied rewrites74.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6474.9
Applied rewrites74.9%
if -3.1000000000000002e42 < y < 1.7500000000000001e-13Initial program 91.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f6471.8
Applied rewrites71.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6472.3
Applied rewrites72.3%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(*
z_s
(if (<= y -2.1e+42)
(/ (/ (+ x x) y) z_m)
(if (<= y 1.75e-13) (* (/ (/ x t) z_m) -2.0) (/ (/ (+ x x) z_m) y)))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (y <= -2.1e+42) {
tmp = ((x + x) / y) / z_m;
} else if (y <= 1.75e-13) {
tmp = ((x / t) / z_m) * -2.0;
} else {
tmp = ((x + x) / z_m) / y;
}
return z_s * tmp;
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-2.1d+42)) then
tmp = ((x + x) / y) / z_m
else if (y <= 1.75d-13) then
tmp = ((x / t) / z_m) * (-2.0d0)
else
tmp = ((x + x) / z_m) / y
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (y <= -2.1e+42) {
tmp = ((x + x) / y) / z_m;
} else if (y <= 1.75e-13) {
tmp = ((x / t) / z_m) * -2.0;
} else {
tmp = ((x + x) / z_m) / y;
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if y <= -2.1e+42: tmp = ((x + x) / y) / z_m elif y <= 1.75e-13: tmp = ((x / t) / z_m) * -2.0 else: tmp = ((x + x) / z_m) / y return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (y <= -2.1e+42) tmp = Float64(Float64(Float64(x + x) / y) / z_m); elseif (y <= 1.75e-13) tmp = Float64(Float64(Float64(x / t) / z_m) * -2.0); else tmp = Float64(Float64(Float64(x + x) / z_m) / y); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (y <= -2.1e+42) tmp = ((x + x) / y) / z_m; elseif (y <= 1.75e-13) tmp = ((x / t) / z_m) * -2.0; else tmp = ((x + x) / z_m) / y; end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[y, -2.1e+42], N[(N[(N[(x + x), $MachinePrecision] / y), $MachinePrecision] / z$95$m), $MachinePrecision], If[LessEqual[y, 1.75e-13], N[(N[(N[(x / t), $MachinePrecision] / z$95$m), $MachinePrecision] * -2.0), $MachinePrecision], N[(N[(N[(x + x), $MachinePrecision] / z$95$m), $MachinePrecision] / y), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+42}:\\
\;\;\;\;\frac{\frac{x + x}{y}}{z\_m}\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{x}{t}}{z\_m} \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + x}{z\_m}}{y}\\
\end{array}
\end{array}
if y < -2.09999999999999995e42Initial program 85.2%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6485.2
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.6
Applied rewrites88.6%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-+.f64N/A
lift--.f6490.8
Applied rewrites90.8%
Taylor expanded in y around inf
associate-*r/N/A
lower-/.f64N/A
count-2-revN/A
lift-+.f6477.6
Applied rewrites77.6%
if -2.09999999999999995e42 < y < 1.7500000000000001e-13Initial program 91.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f6471.8
Applied rewrites71.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6472.3
Applied rewrites72.3%
if 1.7500000000000001e-13 < y Initial program 86.9%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6472.7
Applied rewrites72.7%
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
count-2-revN/A
associate-*r/N/A
lower-/.f64N/A
associate-*r/N/A
count-2-revN/A
lower-/.f64N/A
lift-+.f6472.2
Applied rewrites72.2%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(let* ((t_1 (* (/ x (* t z_m)) -2.0)))
(*
z_s
(if (<= t -3.7e-39) t_1 (if (<= t 8.6e+57) (/ (+ x x) (* z_m y)) t_1)))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double t_1 = (x / (t * z_m)) * -2.0;
double tmp;
if (t <= -3.7e-39) {
tmp = t_1;
} else if (t <= 8.6e+57) {
tmp = (x + x) / (z_m * y);
} else {
tmp = t_1;
}
return z_s * tmp;
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (x / (t * z_m)) * (-2.0d0)
if (t <= (-3.7d-39)) then
tmp = t_1
else if (t <= 8.6d+57) then
tmp = (x + x) / (z_m * y)
else
tmp = t_1
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double t_1 = (x / (t * z_m)) * -2.0;
double tmp;
if (t <= -3.7e-39) {
tmp = t_1;
} else if (t <= 8.6e+57) {
tmp = (x + x) / (z_m * y);
} else {
tmp = t_1;
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): t_1 = (x / (t * z_m)) * -2.0 tmp = 0 if t <= -3.7e-39: tmp = t_1 elif t <= 8.6e+57: tmp = (x + x) / (z_m * y) else: tmp = t_1 return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) t_1 = Float64(Float64(x / Float64(t * z_m)) * -2.0) tmp = 0.0 if (t <= -3.7e-39) tmp = t_1; elseif (t <= 8.6e+57) tmp = Float64(Float64(x + x) / Float64(z_m * y)); else tmp = t_1; end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) t_1 = (x / (t * z_m)) * -2.0; tmp = 0.0; if (t <= -3.7e-39) tmp = t_1; elseif (t <= 8.6e+57) tmp = (x + x) / (z_m * y); else tmp = t_1; end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(x / N[(t * z$95$m), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]}, N[(z$95$s * If[LessEqual[t, -3.7e-39], t$95$1, If[LessEqual[t, 8.6e+57], N[(N[(x + x), $MachinePrecision] / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
\begin{array}{l}
t_1 := \frac{x}{t \cdot z\_m} \cdot -2\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq -3.7 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 8.6 \cdot 10^{+57}:\\
\;\;\;\;\frac{x + x}{z\_m \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if t < -3.70000000000000015e-39 or 8.60000000000000066e57 < t Initial program 86.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f6474.2
Applied rewrites74.2%
if -3.70000000000000015e-39 < t < 8.60000000000000066e57Initial program 91.6%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m t) :precision binary64 (* z_s (/ (+ x x) (* z_m y))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
return z_s * ((x + x) / (z_m * y));
}
z\_m = private
z\_s = private
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(z_s, x, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
code = z_s * ((x + x) / (z_m * y))
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
return z_s * ((x + x) / (z_m * y));
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): return z_s * ((x + x) / (z_m * y))
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) return Float64(z_s * Float64(Float64(x + x) / Float64(z_m * y))) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m, t) tmp = z_s * ((x + x) / (z_m * y)); end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * N[(N[(x + x), $MachinePrecision] / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \frac{x + x}{z\_m \cdot y}
\end{array}
Initial program 88.9%
Taylor expanded in y around inf
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6452.4
Applied rewrites52.4%
herbie shell --seed 2025112
(FPCore (x y z t)
:name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
:precision binary64
(/ (* x 2.0) (- (* y z) (* t z))))