
(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]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
Herbie found 7 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]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* y (fabs z)) (* t (fabs z)))))
(*
(copysign 1.0 z)
(if (<= t_1 -4e+139)
(/ 1.0 (* (/ (fabs z) (+ x x)) (- y t)))
(if (<= t_1 3e+151)
(/ (+ x x) (* (- y t) (fabs z)))
(/ 1.0 (/ (fabs z) (/ (+ x x) (- y t)))))))))double code(double x, double y, double z, double t) {
double t_1 = (y * fabs(z)) - (t * fabs(z));
double tmp;
if (t_1 <= -4e+139) {
tmp = 1.0 / ((fabs(z) / (x + x)) * (y - t));
} else if (t_1 <= 3e+151) {
tmp = (x + x) / ((y - t) * fabs(z));
} else {
tmp = 1.0 / (fabs(z) / ((x + x) / (y - t)));
}
return copysign(1.0, z) * tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (y * Math.abs(z)) - (t * Math.abs(z));
double tmp;
if (t_1 <= -4e+139) {
tmp = 1.0 / ((Math.abs(z) / (x + x)) * (y - t));
} else if (t_1 <= 3e+151) {
tmp = (x + x) / ((y - t) * Math.abs(z));
} else {
tmp = 1.0 / (Math.abs(z) / ((x + x) / (y - t)));
}
return Math.copySign(1.0, z) * tmp;
}
def code(x, y, z, t): t_1 = (y * math.fabs(z)) - (t * math.fabs(z)) tmp = 0 if t_1 <= -4e+139: tmp = 1.0 / ((math.fabs(z) / (x + x)) * (y - t)) elif t_1 <= 3e+151: tmp = (x + x) / ((y - t) * math.fabs(z)) else: tmp = 1.0 / (math.fabs(z) / ((x + x) / (y - t))) return math.copysign(1.0, z) * tmp
function code(x, y, z, t) t_1 = Float64(Float64(y * abs(z)) - Float64(t * abs(z))) tmp = 0.0 if (t_1 <= -4e+139) tmp = Float64(1.0 / Float64(Float64(abs(z) / Float64(x + x)) * Float64(y - t))); elseif (t_1 <= 3e+151) tmp = Float64(Float64(x + x) / Float64(Float64(y - t) * abs(z))); else tmp = Float64(1.0 / Float64(abs(z) / Float64(Float64(x + x) / Float64(y - t)))); end return Float64(copysign(1.0, z) * tmp) end
function tmp_2 = code(x, y, z, t) t_1 = (y * abs(z)) - (t * abs(z)); tmp = 0.0; if (t_1 <= -4e+139) tmp = 1.0 / ((abs(z) / (x + x)) * (y - t)); elseif (t_1 <= 3e+151) tmp = (x + x) / ((y - t) * abs(z)); else tmp = 1.0 / (abs(z) / ((x + x) / (y - t))); end tmp_2 = (sign(z) * abs(1.0)) * tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * N[Abs[z], $MachinePrecision]), $MachinePrecision] - N[(t * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -4e+139], N[(1.0 / N[(N[(N[Abs[z], $MachinePrecision] / N[(x + x), $MachinePrecision]), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 3e+151], N[(N[(x + x), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Abs[z], $MachinePrecision] / N[(N[(x + x), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_1 := y \cdot \left|z\right| - t \cdot \left|z\right|\\
\mathsf{copysign}\left(1, z\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+139}:\\
\;\;\;\;\frac{1}{\frac{\left|z\right|}{x + x} \cdot \left(y - t\right)}\\
\mathbf{elif}\;t\_1 \leq 3 \cdot 10^{+151}:\\
\;\;\;\;\frac{x + x}{\left(y - t\right) \cdot \left|z\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\left|z\right|}{\frac{x + x}{y - t}}}\\
\end{array}
\end{array}
if (-.f64 (*.f64 y z) (*.f64 t z)) < -4.0000000000000001e139Initial program 89.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-/r*N/A
mult-flipN/A
associate-*l/N/A
mult-flip-revN/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lower--.f6492.7%
Applied rewrites92.7%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
div-flip-revN/A
lift-/.f64N/A
lift-/.f6491.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.6%
Applied rewrites91.6%
if -4.0000000000000001e139 < (-.f64 (*.f64 y z) (*.f64 t z)) < 2.9999999999999999e151Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6489.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.8%
Applied rewrites91.8%
if 2.9999999999999999e151 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 89.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-/r*N/A
mult-flipN/A
associate-*l/N/A
mult-flipN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lower--.f6492.1%
Applied rewrites92.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* y (fabs z)) (* t (fabs z)))))
(*
(copysign 1.0 z)
(if (<= t_1 -4e+139)
(/ 1.0 (* (/ (fabs z) (+ x x)) (- y t)))
(if (<= t_1 3e+151)
(/ (+ x x) (* (- y t) (fabs z)))
(/ (/ (+ x x) (- y t)) (fabs z)))))))double code(double x, double y, double z, double t) {
double t_1 = (y * fabs(z)) - (t * fabs(z));
double tmp;
if (t_1 <= -4e+139) {
tmp = 1.0 / ((fabs(z) / (x + x)) * (y - t));
} else if (t_1 <= 3e+151) {
tmp = (x + x) / ((y - t) * fabs(z));
} else {
tmp = ((x + x) / (y - t)) / fabs(z);
}
return copysign(1.0, z) * tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (y * Math.abs(z)) - (t * Math.abs(z));
double tmp;
if (t_1 <= -4e+139) {
tmp = 1.0 / ((Math.abs(z) / (x + x)) * (y - t));
} else if (t_1 <= 3e+151) {
tmp = (x + x) / ((y - t) * Math.abs(z));
} else {
tmp = ((x + x) / (y - t)) / Math.abs(z);
}
return Math.copySign(1.0, z) * tmp;
}
def code(x, y, z, t): t_1 = (y * math.fabs(z)) - (t * math.fabs(z)) tmp = 0 if t_1 <= -4e+139: tmp = 1.0 / ((math.fabs(z) / (x + x)) * (y - t)) elif t_1 <= 3e+151: tmp = (x + x) / ((y - t) * math.fabs(z)) else: tmp = ((x + x) / (y - t)) / math.fabs(z) return math.copysign(1.0, z) * tmp
function code(x, y, z, t) t_1 = Float64(Float64(y * abs(z)) - Float64(t * abs(z))) tmp = 0.0 if (t_1 <= -4e+139) tmp = Float64(1.0 / Float64(Float64(abs(z) / Float64(x + x)) * Float64(y - t))); elseif (t_1 <= 3e+151) tmp = Float64(Float64(x + x) / Float64(Float64(y - t) * abs(z))); else tmp = Float64(Float64(Float64(x + x) / Float64(y - t)) / abs(z)); end return Float64(copysign(1.0, z) * tmp) end
function tmp_2 = code(x, y, z, t) t_1 = (y * abs(z)) - (t * abs(z)); tmp = 0.0; if (t_1 <= -4e+139) tmp = 1.0 / ((abs(z) / (x + x)) * (y - t)); elseif (t_1 <= 3e+151) tmp = (x + x) / ((y - t) * abs(z)); else tmp = ((x + x) / (y - t)) / abs(z); end tmp_2 = (sign(z) * abs(1.0)) * tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * N[Abs[z], $MachinePrecision]), $MachinePrecision] - N[(t * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -4e+139], N[(1.0 / N[(N[(N[Abs[z], $MachinePrecision] / N[(x + x), $MachinePrecision]), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 3e+151], N[(N[(x + x), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + x), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[Abs[z], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_1 := y \cdot \left|z\right| - t \cdot \left|z\right|\\
\mathsf{copysign}\left(1, z\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+139}:\\
\;\;\;\;\frac{1}{\frac{\left|z\right|}{x + x} \cdot \left(y - t\right)}\\
\mathbf{elif}\;t\_1 \leq 3 \cdot 10^{+151}:\\
\;\;\;\;\frac{x + x}{\left(y - t\right) \cdot \left|z\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + x}{y - t}}{\left|z\right|}\\
\end{array}
\end{array}
if (-.f64 (*.f64 y z) (*.f64 t z)) < -4.0000000000000001e139Initial program 89.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-/r*N/A
mult-flipN/A
associate-*l/N/A
mult-flip-revN/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lower--.f6492.7%
Applied rewrites92.7%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
div-flip-revN/A
lift-/.f64N/A
lift-/.f6491.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.6%
Applied rewrites91.6%
if -4.0000000000000001e139 < (-.f64 (*.f64 y z) (*.f64 t z)) < 2.9999999999999999e151Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6489.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.8%
Applied rewrites91.8%
if 2.9999999999999999e151 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 89.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-/r*N/A
mult-flipN/A
associate-*l/N/A
mult-flip-revN/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lower--.f6492.7%
Applied rewrites92.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (/ (+ x x) (- y t)) (fabs z)))
(t_2 (- (* y (fabs z)) (* t (fabs z)))))
(*
(copysign 1.0 z)
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 3e+151) (/ (+ x x) (* (- y t) (fabs z))) t_1)))))double code(double x, double y, double z, double t) {
double t_1 = ((x + x) / (y - t)) / fabs(z);
double t_2 = (y * fabs(z)) - (t * fabs(z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 3e+151) {
tmp = (x + x) / ((y - t) * fabs(z));
} else {
tmp = t_1;
}
return copysign(1.0, z) * tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = ((x + x) / (y - t)) / Math.abs(z);
double t_2 = (y * Math.abs(z)) - (t * Math.abs(z));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 3e+151) {
tmp = (x + x) / ((y - t) * Math.abs(z));
} else {
tmp = t_1;
}
return Math.copySign(1.0, z) * tmp;
}
def code(x, y, z, t): t_1 = ((x + x) / (y - t)) / math.fabs(z) t_2 = (y * math.fabs(z)) - (t * math.fabs(z)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 3e+151: tmp = (x + x) / ((y - t) * math.fabs(z)) else: tmp = t_1 return math.copysign(1.0, z) * tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(x + x) / Float64(y - t)) / abs(z)) t_2 = Float64(Float64(y * abs(z)) - Float64(t * abs(z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 3e+151) tmp = Float64(Float64(x + x) / Float64(Float64(y - t) * abs(z))); else tmp = t_1; end return Float64(copysign(1.0, z) * tmp) end
function tmp_2 = code(x, y, z, t) t_1 = ((x + x) / (y - t)) / abs(z); t_2 = (y * abs(z)) - (t * abs(z)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 3e+151) tmp = (x + x) / ((y - t) * abs(z)); else tmp = t_1; end tmp_2 = (sign(z) * abs(1.0)) * tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x + x), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[Abs[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[Abs[z], $MachinePrecision]), $MachinePrecision] - N[(t * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 3e+151], N[(N[(x + x), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \frac{\frac{x + x}{y - t}}{\left|z\right|}\\
t_2 := y \cdot \left|z\right| - t \cdot \left|z\right|\\
\mathsf{copysign}\left(1, z\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 3 \cdot 10^{+151}:\\
\;\;\;\;\frac{x + x}{\left(y - t\right) \cdot \left|z\right|}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (*.f64 y z) (*.f64 t z)) < -inf.0 or 2.9999999999999999e151 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 89.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-/r*N/A
mult-flipN/A
associate-*l/N/A
mult-flip-revN/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lower--.f6492.7%
Applied rewrites92.7%
if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < 2.9999999999999999e151Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6489.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.8%
Applied rewrites91.8%
(FPCore (x y z t) :precision binary64 (* (copysign 1.0 z) (if (<= (fabs z) 3e-26) (/ (+ x x) (* (- y t) (fabs z))) (/ (/ (+ x x) (fabs z)) (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (fabs(z) <= 3e-26) {
tmp = (x + x) / ((y - t) * fabs(z));
} else {
tmp = ((x + x) / fabs(z)) / (y - t);
}
return copysign(1.0, z) * tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.abs(z) <= 3e-26) {
tmp = (x + x) / ((y - t) * Math.abs(z));
} else {
tmp = ((x + x) / Math.abs(z)) / (y - t);
}
return Math.copySign(1.0, z) * tmp;
}
def code(x, y, z, t): tmp = 0 if math.fabs(z) <= 3e-26: tmp = (x + x) / ((y - t) * math.fabs(z)) else: tmp = ((x + x) / math.fabs(z)) / (y - t) return math.copysign(1.0, z) * tmp
function code(x, y, z, t) tmp = 0.0 if (abs(z) <= 3e-26) tmp = Float64(Float64(x + x) / Float64(Float64(y - t) * abs(z))); else tmp = Float64(Float64(Float64(x + x) / abs(z)) / Float64(y - t)); end return Float64(copysign(1.0, z) * tmp) end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (abs(z) <= 3e-26) tmp = (x + x) / ((y - t) * abs(z)); else tmp = ((x + x) / abs(z)) / (y - t); end tmp_2 = (sign(z) * abs(1.0)) * tmp; end
code[x_, y_, z_, t_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z], $MachinePrecision], 3e-26], N[(N[(x + x), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + x), $MachinePrecision] / N[Abs[z], $MachinePrecision]), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, z\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 3 \cdot 10^{-26}:\\
\;\;\;\;\frac{x + x}{\left(y - t\right) \cdot \left|z\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + x}{\left|z\right|}}{y - t}\\
\end{array}
if z < 3.0000000000000001e-26Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6489.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.8%
Applied rewrites91.8%
if 3.0000000000000001e-26 < z Initial program 89.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lower--.f6492.0%
Applied rewrites92.0%
(FPCore (x y z t) :precision binary64 (/ (+ x x) (* (- y t) z)))
double code(double x, double y, double z, double t) {
return (x + x) / ((y - 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 + x) / ((y - t) * z)
end function
public static double code(double x, double y, double z, double t) {
return (x + x) / ((y - t) * z);
}
def code(x, y, z, t): return (x + x) / ((y - t) * z)
function code(x, y, z, t) return Float64(Float64(x + x) / Float64(Float64(y - t) * z)) end
function tmp = code(x, y, z, t) tmp = (x + x) / ((y - t) * z); end
code[x_, y_, z_, t_] := N[(N[(x + x), $MachinePrecision] / N[(N[(y - t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\frac{x + x}{\left(y - t\right) \cdot z}
Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6489.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.8%
Applied rewrites91.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* -2.0 (/ x (* t z))))) (if (<= t -6e-63) t_1 (if (<= t 3.8e+58) (/ (+ x x) (* y z)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = -2.0 * (x / (t * z));
double tmp;
if (t <= -6e-63) {
tmp = t_1;
} else if (t <= 3.8e+58) {
tmp = (x + x) / (y * z);
} else {
tmp = t_1;
}
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, 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
real(8) :: t_1
real(8) :: tmp
t_1 = (-2.0d0) * (x / (t * z))
if (t <= (-6d-63)) then
tmp = t_1
else if (t <= 3.8d+58) then
tmp = (x + x) / (y * z)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -2.0 * (x / (t * z));
double tmp;
if (t <= -6e-63) {
tmp = t_1;
} else if (t <= 3.8e+58) {
tmp = (x + x) / (y * z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -2.0 * (x / (t * z)) tmp = 0 if t <= -6e-63: tmp = t_1 elif t <= 3.8e+58: tmp = (x + x) / (y * z) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(-2.0 * Float64(x / Float64(t * z))) tmp = 0.0 if (t <= -6e-63) tmp = t_1; elseif (t <= 3.8e+58) tmp = Float64(Float64(x + x) / Float64(y * z)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -2.0 * (x / (t * z)); tmp = 0.0; if (t <= -6e-63) tmp = t_1; elseif (t <= 3.8e+58) tmp = (x + x) / (y * z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-2.0 * N[(x / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -6e-63], t$95$1, If[LessEqual[t, 3.8e+58], N[(N[(x + x), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := -2 \cdot \frac{x}{t \cdot z}\\
\mathbf{if}\;t \leq -6 \cdot 10^{-63}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.8 \cdot 10^{+58}:\\
\;\;\;\;\frac{x + x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -5.9999999999999996e-63 or 3.7999999999999999e58 < t Initial program 89.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.7%
Applied rewrites52.7%
if -5.9999999999999996e-63 < t < 3.7999999999999999e58Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6489.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.8%
Applied rewrites91.8%
Taylor expanded in y around inf
lower-*.f6453.6%
Applied rewrites53.6%
(FPCore (x y z t) :precision binary64 (/ (+ x x) (* y z)))
double code(double x, double y, double z, double t) {
return (x + 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, 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 + x) / (y * z)
end function
public static double code(double x, double y, double z, double t) {
return (x + x) / (y * z);
}
def code(x, y, z, t): return (x + x) / (y * z)
function code(x, y, z, t) return Float64(Float64(x + x) / Float64(y * z)) end
function tmp = code(x, y, z, t) tmp = (x + x) / (y * z); end
code[x_, y_, z_, t_] := N[(N[(x + x), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision]
\frac{x + x}{y \cdot z}
Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6489.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.8%
Applied rewrites91.8%
Taylor expanded in y around inf
lower-*.f6453.6%
Applied rewrites53.6%
herbie shell --seed 2025258
(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))))