
(FPCore (z2 z0 z1 z3) :precision binary64 (/ (- z2) (+ (* (* z2 (/ z0 (* z1 z1))) z2) z3)))
double code(double z2, double z0, double z1, double z3) {
return -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3);
}
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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
code = -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3)
end function
public static double code(double z2, double z0, double z1, double z3) {
return -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3);
}
def code(z2, z0, z1, z3): return -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3)
function code(z2, z0, z1, z3) return Float64(Float64(-z2) / Float64(Float64(Float64(z2 * Float64(z0 / Float64(z1 * z1))) * z2) + z3)) end
function tmp = code(z2, z0, z1, z3) tmp = -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3); end
code[z2_, z0_, z1_, z3_] := N[((-z2) / N[(N[(N[(z2 * N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision]
\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z2 z0 z1 z3) :precision binary64 (/ (- z2) (+ (* (* z2 (/ z0 (* z1 z1))) z2) z3)))
double code(double z2, double z0, double z1, double z3) {
return -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3);
}
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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
code = -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3)
end function
public static double code(double z2, double z0, double z1, double z3) {
return -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3);
}
def code(z2, z0, z1, z3): return -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3)
function code(z2, z0, z1, z3) return Float64(Float64(-z2) / Float64(Float64(Float64(z2 * Float64(z0 / Float64(z1 * z1))) * z2) + z3)) end
function tmp = code(z2, z0, z1, z3) tmp = -z2 / (((z2 * (z0 / (z1 * z1))) * z2) + z3); end
code[z2_, z0_, z1_, z3_] := N[((-z2) / N[(N[(N[(z2 * N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision]
\frac{-z2}{\left(z2 \cdot \frac{z0}{z1 \cdot z1}\right) \cdot z2 + z3}
(FPCore (z2 z0 z1 z3) :precision binary64 (/ (- z2) (+ (* (/ (* (/ z2 z1) z0) z1) z2) z3)))
double code(double z2, double z0, double z1, double z3) {
return -z2 / (((((z2 / z1) * z0) / z1) * z2) + z3);
}
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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
code = -z2 / (((((z2 / z1) * z0) / z1) * z2) + z3)
end function
public static double code(double z2, double z0, double z1, double z3) {
return -z2 / (((((z2 / z1) * z0) / z1) * z2) + z3);
}
def code(z2, z0, z1, z3): return -z2 / (((((z2 / z1) * z0) / z1) * z2) + z3)
function code(z2, z0, z1, z3) return Float64(Float64(-z2) / Float64(Float64(Float64(Float64(Float64(z2 / z1) * z0) / z1) * z2) + z3)) end
function tmp = code(z2, z0, z1, z3) tmp = -z2 / (((((z2 / z1) * z0) / z1) * z2) + z3); end
code[z2_, z0_, z1_, z3_] := N[((-z2) / N[(N[(N[(N[(N[(z2 / z1), $MachinePrecision] * z0), $MachinePrecision] / z1), $MachinePrecision] * z2), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision]
\frac{-z2}{\frac{\frac{z2}{z1} \cdot z0}{z1} \cdot z2 + z3}
Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
(FPCore (z2 z0 z1 z3) :precision binary64 (/ (- z2) (+ (* (* (/ z2 z1) (/ z0 z1)) z2) z3)))
double code(double z2, double z0, double z1, double z3) {
return -z2 / ((((z2 / z1) * (z0 / z1)) * z2) + z3);
}
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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
code = -z2 / ((((z2 / z1) * (z0 / z1)) * z2) + z3)
end function
public static double code(double z2, double z0, double z1, double z3) {
return -z2 / ((((z2 / z1) * (z0 / z1)) * z2) + z3);
}
def code(z2, z0, z1, z3): return -z2 / ((((z2 / z1) * (z0 / z1)) * z2) + z3)
function code(z2, z0, z1, z3) return Float64(Float64(-z2) / Float64(Float64(Float64(Float64(z2 / z1) * Float64(z0 / z1)) * z2) + z3)) end
function tmp = code(z2, z0, z1, z3) tmp = -z2 / ((((z2 / z1) * (z0 / z1)) * z2) + z3); end
code[z2_, z0_, z1_, z3_] := N[((-z2) / N[(N[(N[(N[(z2 / z1), $MachinePrecision] * N[(z0 / z1), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision]
\frac{-z2}{\left(\frac{z2}{z1} \cdot \frac{z0}{z1}\right) \cdot z2 + z3}
Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6491.9%
Applied rewrites91.9%
(FPCore (z2 z0 z1 z3) :precision binary64 (if (<= (fabs z1) 50000.0) (* (/ (- z2) (+ (* z3 (fabs z1)) (* (* z0 (/ z2 (fabs z1))) z2))) (fabs z1)) (/ (- z2) (+ (* (* z2 (/ z0 (* (fabs z1) (fabs z1)))) z2) z3))))
double code(double z2, double z0, double z1, double z3) {
double tmp;
if (fabs(z1) <= 50000.0) {
tmp = (-z2 / ((z3 * fabs(z1)) + ((z0 * (z2 / fabs(z1))) * z2))) * fabs(z1);
} else {
tmp = -z2 / (((z2 * (z0 / (fabs(z1) * fabs(z1)))) * z2) + z3);
}
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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8) :: tmp
if (abs(z1) <= 50000.0d0) then
tmp = (-z2 / ((z3 * abs(z1)) + ((z0 * (z2 / abs(z1))) * z2))) * abs(z1)
else
tmp = -z2 / (((z2 * (z0 / (abs(z1) * abs(z1)))) * z2) + z3)
end if
code = tmp
end function
public static double code(double z2, double z0, double z1, double z3) {
double tmp;
if (Math.abs(z1) <= 50000.0) {
tmp = (-z2 / ((z3 * Math.abs(z1)) + ((z0 * (z2 / Math.abs(z1))) * z2))) * Math.abs(z1);
} else {
tmp = -z2 / (((z2 * (z0 / (Math.abs(z1) * Math.abs(z1)))) * z2) + z3);
}
return tmp;
}
def code(z2, z0, z1, z3): tmp = 0 if math.fabs(z1) <= 50000.0: tmp = (-z2 / ((z3 * math.fabs(z1)) + ((z0 * (z2 / math.fabs(z1))) * z2))) * math.fabs(z1) else: tmp = -z2 / (((z2 * (z0 / (math.fabs(z1) * math.fabs(z1)))) * z2) + z3) return tmp
function code(z2, z0, z1, z3) tmp = 0.0 if (abs(z1) <= 50000.0) tmp = Float64(Float64(Float64(-z2) / Float64(Float64(z3 * abs(z1)) + Float64(Float64(z0 * Float64(z2 / abs(z1))) * z2))) * abs(z1)); else tmp = Float64(Float64(-z2) / Float64(Float64(Float64(z2 * Float64(z0 / Float64(abs(z1) * abs(z1)))) * z2) + z3)); end return tmp end
function tmp_2 = code(z2, z0, z1, z3) tmp = 0.0; if (abs(z1) <= 50000.0) tmp = (-z2 / ((z3 * abs(z1)) + ((z0 * (z2 / abs(z1))) * z2))) * abs(z1); else tmp = -z2 / (((z2 * (z0 / (abs(z1) * abs(z1)))) * z2) + z3); end tmp_2 = tmp; end
code[z2_, z0_, z1_, z3_] := If[LessEqual[N[Abs[z1], $MachinePrecision], 50000.0], N[(N[((-z2) / N[(N[(z3 * N[Abs[z1], $MachinePrecision]), $MachinePrecision] + N[(N[(z0 * N[(z2 / N[Abs[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[z1], $MachinePrecision]), $MachinePrecision], N[((-z2) / N[(N[(N[(z2 * N[(z0 / N[(N[Abs[z1], $MachinePrecision] * N[Abs[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z2), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z1\right| \leq 50000:\\
\;\;\;\;\frac{-z2}{z3 \cdot \left|z1\right| + \left(z0 \cdot \frac{z2}{\left|z1\right|}\right) \cdot z2} \cdot \left|z1\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{-z2}{\left(z2 \cdot \frac{z0}{\left|z1\right| \cdot \left|z1\right|}\right) \cdot z2 + z3}\\
\end{array}
if z1 < 5e4Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
Applied rewrites80.1%
if 5e4 < z1 Initial program 83.1%
(FPCore (z2 z0 z1 z3)
:precision binary64
(*
(copysign 1.0 z2)
(if (<= (fabs z2) 1.15e+207)
(/
(- (fabs z2))
(+ (* (/ (* z0 (fabs z2)) (* z1 z1)) (fabs z2)) z3))
(* (* (/ -1.0 (fabs z2)) z1) (/ z1 z0)))))double code(double z2, double z0, double z1, double z3) {
double tmp;
if (fabs(z2) <= 1.15e+207) {
tmp = -fabs(z2) / ((((z0 * fabs(z2)) / (z1 * z1)) * fabs(z2)) + z3);
} else {
tmp = ((-1.0 / fabs(z2)) * z1) * (z1 / z0);
}
return copysign(1.0, z2) * tmp;
}
public static double code(double z2, double z0, double z1, double z3) {
double tmp;
if (Math.abs(z2) <= 1.15e+207) {
tmp = -Math.abs(z2) / ((((z0 * Math.abs(z2)) / (z1 * z1)) * Math.abs(z2)) + z3);
} else {
tmp = ((-1.0 / Math.abs(z2)) * z1) * (z1 / z0);
}
return Math.copySign(1.0, z2) * tmp;
}
def code(z2, z0, z1, z3): tmp = 0 if math.fabs(z2) <= 1.15e+207: tmp = -math.fabs(z2) / ((((z0 * math.fabs(z2)) / (z1 * z1)) * math.fabs(z2)) + z3) else: tmp = ((-1.0 / math.fabs(z2)) * z1) * (z1 / z0) return math.copysign(1.0, z2) * tmp
function code(z2, z0, z1, z3) tmp = 0.0 if (abs(z2) <= 1.15e+207) tmp = Float64(Float64(-abs(z2)) / Float64(Float64(Float64(Float64(z0 * abs(z2)) / Float64(z1 * z1)) * abs(z2)) + z3)); else tmp = Float64(Float64(Float64(-1.0 / abs(z2)) * z1) * Float64(z1 / z0)); end return Float64(copysign(1.0, z2) * tmp) end
function tmp_2 = code(z2, z0, z1, z3) tmp = 0.0; if (abs(z2) <= 1.15e+207) tmp = -abs(z2) / ((((z0 * abs(z2)) / (z1 * z1)) * abs(z2)) + z3); else tmp = ((-1.0 / abs(z2)) * z1) * (z1 / z0); end tmp_2 = (sign(z2) * abs(1.0)) * tmp; end
code[z2_, z0_, z1_, z3_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z2], $MachinePrecision], 1.15e+207], N[((-N[Abs[z2], $MachinePrecision]) / N[(N[(N[(N[(z0 * N[Abs[z2], $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 / N[Abs[z2], $MachinePrecision]), $MachinePrecision] * z1), $MachinePrecision] * N[(z1 / z0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, z2\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 1.15 \cdot 10^{+207}:\\
\;\;\;\;\frac{-\left|z2\right|}{\frac{z0 \cdot \left|z2\right|}{z1 \cdot z1} \cdot \left|z2\right| + z3}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-1}{\left|z2\right|} \cdot z1\right) \cdot \frac{z1}{z0}\\
\end{array}
if z2 < 1.15e207Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6483.2%
Applied rewrites83.2%
if 1.15e207 < z2 Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
Taylor expanded in z2 around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6443.6%
Applied rewrites43.6%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6451.0%
Applied rewrites51.0%
(FPCore (z2 z0 z1 z3)
:precision binary64
(*
(copysign 1.0 z2)
(if (<= (fabs z2) 6e+242)
(/
(- (fabs z2))
(+ (* (* (fabs z2) (/ z0 (* z1 z1))) (fabs z2)) z3))
(* z1 (* (/ z1 z0) (/ -1.0 (fabs z2)))))))double code(double z2, double z0, double z1, double z3) {
double tmp;
if (fabs(z2) <= 6e+242) {
tmp = -fabs(z2) / (((fabs(z2) * (z0 / (z1 * z1))) * fabs(z2)) + z3);
} else {
tmp = z1 * ((z1 / z0) * (-1.0 / fabs(z2)));
}
return copysign(1.0, z2) * tmp;
}
public static double code(double z2, double z0, double z1, double z3) {
double tmp;
if (Math.abs(z2) <= 6e+242) {
tmp = -Math.abs(z2) / (((Math.abs(z2) * (z0 / (z1 * z1))) * Math.abs(z2)) + z3);
} else {
tmp = z1 * ((z1 / z0) * (-1.0 / Math.abs(z2)));
}
return Math.copySign(1.0, z2) * tmp;
}
def code(z2, z0, z1, z3): tmp = 0 if math.fabs(z2) <= 6e+242: tmp = -math.fabs(z2) / (((math.fabs(z2) * (z0 / (z1 * z1))) * math.fabs(z2)) + z3) else: tmp = z1 * ((z1 / z0) * (-1.0 / math.fabs(z2))) return math.copysign(1.0, z2) * tmp
function code(z2, z0, z1, z3) tmp = 0.0 if (abs(z2) <= 6e+242) tmp = Float64(Float64(-abs(z2)) / Float64(Float64(Float64(abs(z2) * Float64(z0 / Float64(z1 * z1))) * abs(z2)) + z3)); else tmp = Float64(z1 * Float64(Float64(z1 / z0) * Float64(-1.0 / abs(z2)))); end return Float64(copysign(1.0, z2) * tmp) end
function tmp_2 = code(z2, z0, z1, z3) tmp = 0.0; if (abs(z2) <= 6e+242) tmp = -abs(z2) / (((abs(z2) * (z0 / (z1 * z1))) * abs(z2)) + z3); else tmp = z1 * ((z1 / z0) * (-1.0 / abs(z2))); end tmp_2 = (sign(z2) * abs(1.0)) * tmp; end
code[z2_, z0_, z1_, z3_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z2], $MachinePrecision], 6e+242], N[((-N[Abs[z2], $MachinePrecision]) / N[(N[(N[(N[Abs[z2], $MachinePrecision] * N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[z2], $MachinePrecision]), $MachinePrecision] + z3), $MachinePrecision]), $MachinePrecision], N[(z1 * N[(N[(z1 / z0), $MachinePrecision] * N[(-1.0 / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, z2\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z2\right| \leq 6 \cdot 10^{+242}:\\
\;\;\;\;\frac{-\left|z2\right|}{\left(\left|z2\right| \cdot \frac{z0}{z1 \cdot z1}\right) \cdot \left|z2\right| + z3}\\
\mathbf{else}:\\
\;\;\;\;z1 \cdot \left(\frac{z1}{z0} \cdot \frac{-1}{\left|z2\right|}\right)\\
\end{array}
if z2 < 6.0000000000000001e242Initial program 83.1%
if 6.0000000000000001e242 < z2 Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
Taylor expanded in z2 around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6443.6%
Applied rewrites43.6%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
lift-*.f64N/A
associate-/l*N/A
lift-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6450.8%
Applied rewrites50.8%
lift-neg.f64N/A
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-evalN/A
frac-2neg-revN/A
lower-/.f6450.8%
Applied rewrites50.8%
(FPCore (z2 z0 z1 z3)
:precision binary64
(let* ((t_0 (/ z0 (* z1 z1))))
(if (<= t_0 -2e+57)
(* (- z1) (/ z1 (* z0 z2)))
(if (<= t_0 2e+15) (/ (- z2) z3) (/ (* (/ (- z1) z0) z1) z2)))))double code(double z2, double z0, double z1, double z3) {
double t_0 = z0 / (z1 * z1);
double tmp;
if (t_0 <= -2e+57) {
tmp = -z1 * (z1 / (z0 * z2));
} else if (t_0 <= 2e+15) {
tmp = -z2 / z3;
} else {
tmp = ((-z1 / z0) * z1) / z2;
}
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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8) :: t_0
real(8) :: tmp
t_0 = z0 / (z1 * z1)
if (t_0 <= (-2d+57)) then
tmp = -z1 * (z1 / (z0 * z2))
else if (t_0 <= 2d+15) then
tmp = -z2 / z3
else
tmp = ((-z1 / z0) * z1) / z2
end if
code = tmp
end function
public static double code(double z2, double z0, double z1, double z3) {
double t_0 = z0 / (z1 * z1);
double tmp;
if (t_0 <= -2e+57) {
tmp = -z1 * (z1 / (z0 * z2));
} else if (t_0 <= 2e+15) {
tmp = -z2 / z3;
} else {
tmp = ((-z1 / z0) * z1) / z2;
}
return tmp;
}
def code(z2, z0, z1, z3): t_0 = z0 / (z1 * z1) tmp = 0 if t_0 <= -2e+57: tmp = -z1 * (z1 / (z0 * z2)) elif t_0 <= 2e+15: tmp = -z2 / z3 else: tmp = ((-z1 / z0) * z1) / z2 return tmp
function code(z2, z0, z1, z3) t_0 = Float64(z0 / Float64(z1 * z1)) tmp = 0.0 if (t_0 <= -2e+57) tmp = Float64(Float64(-z1) * Float64(z1 / Float64(z0 * z2))); elseif (t_0 <= 2e+15) tmp = Float64(Float64(-z2) / z3); else tmp = Float64(Float64(Float64(Float64(-z1) / z0) * z1) / z2); end return tmp end
function tmp_2 = code(z2, z0, z1, z3) t_0 = z0 / (z1 * z1); tmp = 0.0; if (t_0 <= -2e+57) tmp = -z1 * (z1 / (z0 * z2)); elseif (t_0 <= 2e+15) tmp = -z2 / z3; else tmp = ((-z1 / z0) * z1) / z2; end tmp_2 = tmp; end
code[z2_, z0_, z1_, z3_] := Block[{t$95$0 = N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+57], N[((-z1) * N[(z1 / N[(z0 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+15], N[((-z2) / z3), $MachinePrecision], N[(N[(N[((-z1) / z0), $MachinePrecision] * z1), $MachinePrecision] / z2), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{z0}{z1 \cdot z1}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+57}:\\
\;\;\;\;\left(-z1\right) \cdot \frac{z1}{z0 \cdot z2}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+15}:\\
\;\;\;\;\frac{-z2}{z3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-z1}{z0} \cdot z1}{z2}\\
\end{array}
if (/.f64 z0 (*.f64 z1 z1)) < -2.0000000000000001e57Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
Taylor expanded in z2 around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6443.6%
Applied rewrites43.6%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
mult-flipN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
mult-flip-revN/A
lower-/.f6446.9%
Applied rewrites46.9%
if -2.0000000000000001e57 < (/.f64 z0 (*.f64 z1 z1)) < 2e15Initial program 83.1%
Taylor expanded in z2 around 0
Applied rewrites51.9%
if 2e15 < (/.f64 z0 (*.f64 z1 z1)) Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
Taylor expanded in z2 around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6443.6%
Applied rewrites43.6%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
distribute-neg-frac2N/A
lift-*.f64N/A
associate-/l*N/A
lift-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6450.8%
Applied rewrites50.8%
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
distribute-neg-frac2N/A
distribute-neg-fracN/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-fracN/A
lift-neg.f64N/A
lower-/.f6449.0%
Applied rewrites49.0%
(FPCore (z2 z0 z1 z3)
:precision binary64
(let* ((t_0 (/ z0 (* z1 z1))))
(if (<= t_0 -2e+57)
(* (- z1) (/ z1 (* z0 z2)))
(if (<= t_0 2e+15) (/ (- z2) z3) (/ (* (- z1) z1) (* z0 z2))))))double code(double z2, double z0, double z1, double z3) {
double t_0 = z0 / (z1 * z1);
double tmp;
if (t_0 <= -2e+57) {
tmp = -z1 * (z1 / (z0 * z2));
} else if (t_0 <= 2e+15) {
tmp = -z2 / z3;
} else {
tmp = (-z1 * z1) / (z0 * z2);
}
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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8) :: t_0
real(8) :: tmp
t_0 = z0 / (z1 * z1)
if (t_0 <= (-2d+57)) then
tmp = -z1 * (z1 / (z0 * z2))
else if (t_0 <= 2d+15) then
tmp = -z2 / z3
else
tmp = (-z1 * z1) / (z0 * z2)
end if
code = tmp
end function
public static double code(double z2, double z0, double z1, double z3) {
double t_0 = z0 / (z1 * z1);
double tmp;
if (t_0 <= -2e+57) {
tmp = -z1 * (z1 / (z0 * z2));
} else if (t_0 <= 2e+15) {
tmp = -z2 / z3;
} else {
tmp = (-z1 * z1) / (z0 * z2);
}
return tmp;
}
def code(z2, z0, z1, z3): t_0 = z0 / (z1 * z1) tmp = 0 if t_0 <= -2e+57: tmp = -z1 * (z1 / (z0 * z2)) elif t_0 <= 2e+15: tmp = -z2 / z3 else: tmp = (-z1 * z1) / (z0 * z2) return tmp
function code(z2, z0, z1, z3) t_0 = Float64(z0 / Float64(z1 * z1)) tmp = 0.0 if (t_0 <= -2e+57) tmp = Float64(Float64(-z1) * Float64(z1 / Float64(z0 * z2))); elseif (t_0 <= 2e+15) tmp = Float64(Float64(-z2) / z3); else tmp = Float64(Float64(Float64(-z1) * z1) / Float64(z0 * z2)); end return tmp end
function tmp_2 = code(z2, z0, z1, z3) t_0 = z0 / (z1 * z1); tmp = 0.0; if (t_0 <= -2e+57) tmp = -z1 * (z1 / (z0 * z2)); elseif (t_0 <= 2e+15) tmp = -z2 / z3; else tmp = (-z1 * z1) / (z0 * z2); end tmp_2 = tmp; end
code[z2_, z0_, z1_, z3_] := Block[{t$95$0 = N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+57], N[((-z1) * N[(z1 / N[(z0 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+15], N[((-z2) / z3), $MachinePrecision], N[(N[((-z1) * z1), $MachinePrecision] / N[(z0 * z2), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{z0}{z1 \cdot z1}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+57}:\\
\;\;\;\;\left(-z1\right) \cdot \frac{z1}{z0 \cdot z2}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+15}:\\
\;\;\;\;\frac{-z2}{z3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-z1\right) \cdot z1}{z0 \cdot z2}\\
\end{array}
if (/.f64 z0 (*.f64 z1 z1)) < -2.0000000000000001e57Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
Taylor expanded in z2 around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6443.6%
Applied rewrites43.6%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
mult-flipN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
mult-flip-revN/A
lower-/.f6446.9%
Applied rewrites46.9%
if -2.0000000000000001e57 < (/.f64 z0 (*.f64 z1 z1)) < 2e15Initial program 83.1%
Taylor expanded in z2 around 0
Applied rewrites51.9%
if 2e15 < (/.f64 z0 (*.f64 z1 z1)) Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
Taylor expanded in z2 around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6443.6%
Applied rewrites43.6%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6443.6%
Applied rewrites43.6%
(FPCore (z2 z0 z1 z3) :precision binary64 (let* ((t_0 (/ z0 (* z1 z1))) (t_1 (* (- z1) (/ z1 (* z0 z2))))) (if (<= t_0 -2e+57) t_1 (if (<= t_0 2e+15) (/ (- z2) z3) t_1))))
double code(double z2, double z0, double z1, double z3) {
double t_0 = z0 / (z1 * z1);
double t_1 = -z1 * (z1 / (z0 * z2));
double tmp;
if (t_0 <= -2e+57) {
tmp = t_1;
} else if (t_0 <= 2e+15) {
tmp = -z2 / z3;
} 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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z0 / (z1 * z1)
t_1 = -z1 * (z1 / (z0 * z2))
if (t_0 <= (-2d+57)) then
tmp = t_1
else if (t_0 <= 2d+15) then
tmp = -z2 / z3
else
tmp = t_1
end if
code = tmp
end function
public static double code(double z2, double z0, double z1, double z3) {
double t_0 = z0 / (z1 * z1);
double t_1 = -z1 * (z1 / (z0 * z2));
double tmp;
if (t_0 <= -2e+57) {
tmp = t_1;
} else if (t_0 <= 2e+15) {
tmp = -z2 / z3;
} else {
tmp = t_1;
}
return tmp;
}
def code(z2, z0, z1, z3): t_0 = z0 / (z1 * z1) t_1 = -z1 * (z1 / (z0 * z2)) tmp = 0 if t_0 <= -2e+57: tmp = t_1 elif t_0 <= 2e+15: tmp = -z2 / z3 else: tmp = t_1 return tmp
function code(z2, z0, z1, z3) t_0 = Float64(z0 / Float64(z1 * z1)) t_1 = Float64(Float64(-z1) * Float64(z1 / Float64(z0 * z2))) tmp = 0.0 if (t_0 <= -2e+57) tmp = t_1; elseif (t_0 <= 2e+15) tmp = Float64(Float64(-z2) / z3); else tmp = t_1; end return tmp end
function tmp_2 = code(z2, z0, z1, z3) t_0 = z0 / (z1 * z1); t_1 = -z1 * (z1 / (z0 * z2)); tmp = 0.0; if (t_0 <= -2e+57) tmp = t_1; elseif (t_0 <= 2e+15) tmp = -z2 / z3; else tmp = t_1; end tmp_2 = tmp; end
code[z2_, z0_, z1_, z3_] := Block[{t$95$0 = N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-z1) * N[(z1 / N[(z0 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+57], t$95$1, If[LessEqual[t$95$0, 2e+15], N[((-z2) / z3), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \frac{z0}{z1 \cdot z1}\\
t_1 := \left(-z1\right) \cdot \frac{z1}{z0 \cdot z2}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+57}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+15}:\\
\;\;\;\;\frac{-z2}{z3}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 z0 (*.f64 z1 z1)) < -2.0000000000000001e57 or 2e15 < (/.f64 z0 (*.f64 z1 z1)) Initial program 83.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6492.9%
Applied rewrites92.9%
Taylor expanded in z2 around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f6443.6%
Applied rewrites43.6%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
mult-flipN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
mult-flip-revN/A
lower-/.f6446.9%
Applied rewrites46.9%
if -2.0000000000000001e57 < (/.f64 z0 (*.f64 z1 z1)) < 2e15Initial program 83.1%
Taylor expanded in z2 around 0
Applied rewrites51.9%
(FPCore (z2 z0 z1 z3) :precision binary64 (/ (- z2) z3))
double code(double z2, double z0, double z1, double z3) {
return -z2 / z3;
}
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(z2, z0, z1, z3)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
code = -z2 / z3
end function
public static double code(double z2, double z0, double z1, double z3) {
return -z2 / z3;
}
def code(z2, z0, z1, z3): return -z2 / z3
function code(z2, z0, z1, z3) return Float64(Float64(-z2) / z3) end
function tmp = code(z2, z0, z1, z3) tmp = -z2 / z3; end
code[z2_, z0_, z1_, z3_] := N[((-z2) / z3), $MachinePrecision]
\frac{-z2}{z3}
Initial program 83.1%
Taylor expanded in z2 around 0
Applied rewrites51.9%
herbie shell --seed 2025250
(FPCore (z2 z0 z1 z3)
:name "(/ (- z2) (+ (* (* z2 (/ z0 (* z1 z1))) z2) z3))"
:precision binary64
(/ (- z2) (+ (* (* z2 (/ z0 (* z1 z1))) z2) z3)))