
(FPCore (z2 z3 z0 z1) :precision binary64 (/ -1.0 (+ (/ z2 (* z3 z3)) (/ z0 (* z1 z1)))))
double code(double z2, double z3, double z0, double z1) {
return -1.0 / ((z2 / (z3 * z3)) + (z0 / (z1 * z1)));
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
code = (-1.0d0) / ((z2 / (z3 * z3)) + (z0 / (z1 * z1)))
end function
public static double code(double z2, double z3, double z0, double z1) {
return -1.0 / ((z2 / (z3 * z3)) + (z0 / (z1 * z1)));
}
def code(z2, z3, z0, z1): return -1.0 / ((z2 / (z3 * z3)) + (z0 / (z1 * z1)))
function code(z2, z3, z0, z1) return Float64(-1.0 / Float64(Float64(z2 / Float64(z3 * z3)) + Float64(z0 / Float64(z1 * z1)))) end
function tmp = code(z2, z3, z0, z1) tmp = -1.0 / ((z2 / (z3 * z3)) + (z0 / (z1 * z1))); end
code[z2_, z3_, z0_, z1_] := N[(-1.0 / N[(N[(z2 / N[(z3 * z3), $MachinePrecision]), $MachinePrecision] + N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{-1}{\frac{z2}{z3 \cdot z3} + \frac{z0}{z1 \cdot z1}}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z2 z3 z0 z1) :precision binary64 (/ -1.0 (+ (/ z2 (* z3 z3)) (/ z0 (* z1 z1)))))
double code(double z2, double z3, double z0, double z1) {
return -1.0 / ((z2 / (z3 * z3)) + (z0 / (z1 * z1)));
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
code = (-1.0d0) / ((z2 / (z3 * z3)) + (z0 / (z1 * z1)))
end function
public static double code(double z2, double z3, double z0, double z1) {
return -1.0 / ((z2 / (z3 * z3)) + (z0 / (z1 * z1)));
}
def code(z2, z3, z0, z1): return -1.0 / ((z2 / (z3 * z3)) + (z0 / (z1 * z1)))
function code(z2, z3, z0, z1) return Float64(-1.0 / Float64(Float64(z2 / Float64(z3 * z3)) + Float64(z0 / Float64(z1 * z1)))) end
function tmp = code(z2, z3, z0, z1) tmp = -1.0 / ((z2 / (z3 * z3)) + (z0 / (z1 * z1))); end
code[z2_, z3_, z0_, z1_] := N[(-1.0 / N[(N[(z2 / N[(z3 * z3), $MachinePrecision]), $MachinePrecision] + N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{-1}{\frac{z2}{z3 \cdot z3} + \frac{z0}{z1 \cdot z1}}
(FPCore (z2 z3 z0 z1) :precision binary64 (if (<= (* z1 z1) 5e-251) (* (* (/ -1.0 (+ (* z1 (/ z2 z3)) (* (/ z0 z1) z3))) z3) z1) (/ -1.0 (+ (/ (/ z2 z3) z3) (/ (/ z0 z1) z1)))))
double code(double z2, double z3, double z0, double z1) {
double tmp;
if ((z1 * z1) <= 5e-251) {
tmp = ((-1.0 / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1;
} else {
tmp = -1.0 / (((z2 / z3) / z3) + ((z0 / z1) / z1));
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8) :: tmp
if ((z1 * z1) <= 5d-251) then
tmp = (((-1.0d0) / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1
else
tmp = (-1.0d0) / (((z2 / z3) / z3) + ((z0 / z1) / z1))
end if
code = tmp
end function
public static double code(double z2, double z3, double z0, double z1) {
double tmp;
if ((z1 * z1) <= 5e-251) {
tmp = ((-1.0 / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1;
} else {
tmp = -1.0 / (((z2 / z3) / z3) + ((z0 / z1) / z1));
}
return tmp;
}
def code(z2, z3, z0, z1): tmp = 0 if (z1 * z1) <= 5e-251: tmp = ((-1.0 / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1 else: tmp = -1.0 / (((z2 / z3) / z3) + ((z0 / z1) / z1)) return tmp
function code(z2, z3, z0, z1) tmp = 0.0 if (Float64(z1 * z1) <= 5e-251) tmp = Float64(Float64(Float64(-1.0 / Float64(Float64(z1 * Float64(z2 / z3)) + Float64(Float64(z0 / z1) * z3))) * z3) * z1); else tmp = Float64(-1.0 / Float64(Float64(Float64(z2 / z3) / z3) + Float64(Float64(z0 / z1) / z1))); end return tmp end
function tmp_2 = code(z2, z3, z0, z1) tmp = 0.0; if ((z1 * z1) <= 5e-251) tmp = ((-1.0 / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1; else tmp = -1.0 / (((z2 / z3) / z3) + ((z0 / z1) / z1)); end tmp_2 = tmp; end
code[z2_, z3_, z0_, z1_] := If[LessEqual[N[(z1 * z1), $MachinePrecision], 5e-251], N[(N[(N[(-1.0 / N[(N[(z1 * N[(z2 / z3), $MachinePrecision]), $MachinePrecision] + N[(N[(z0 / z1), $MachinePrecision] * z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision] * z1), $MachinePrecision], N[(-1.0 / N[(N[(N[(z2 / z3), $MachinePrecision] / z3), $MachinePrecision] + N[(N[(z0 / z1), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z1 \cdot z1 \leq 5 \cdot 10^{-251}:\\
\;\;\;\;\left(\frac{-1}{z1 \cdot \frac{z2}{z3} + \frac{z0}{z1} \cdot z3} \cdot z3\right) \cdot z1\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\frac{z2}{z3}}{z3} + \frac{\frac{z0}{z1}}{z1}}\\
\end{array}
if (*.f64 z1 z1) < 5.0000000000000003e-251Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.5%
Applied rewrites94.5%
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
common-denominatorN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6484.4%
Applied rewrites84.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6487.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.1%
Applied rewrites87.1%
if 5.0000000000000003e-251 < (*.f64 z1 z1) Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.5%
Applied rewrites94.5%
(FPCore (z2 z3 z0 z1) :precision binary64 (if (<= (* z1 z1) 5e-251) (* (* (/ -1.0 (+ (* z1 (/ z2 z3)) (* (/ z0 z1) z3))) z3) z1) (/ -1.0 (+ (/ (/ z2 z3) z3) (/ z0 (* z1 z1))))))
double code(double z2, double z3, double z0, double z1) {
double tmp;
if ((z1 * z1) <= 5e-251) {
tmp = ((-1.0 / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1;
} else {
tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (z1 * z1)));
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8) :: tmp
if ((z1 * z1) <= 5d-251) then
tmp = (((-1.0d0) / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1
else
tmp = (-1.0d0) / (((z2 / z3) / z3) + (z0 / (z1 * z1)))
end if
code = tmp
end function
public static double code(double z2, double z3, double z0, double z1) {
double tmp;
if ((z1 * z1) <= 5e-251) {
tmp = ((-1.0 / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1;
} else {
tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (z1 * z1)));
}
return tmp;
}
def code(z2, z3, z0, z1): tmp = 0 if (z1 * z1) <= 5e-251: tmp = ((-1.0 / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1 else: tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (z1 * z1))) return tmp
function code(z2, z3, z0, z1) tmp = 0.0 if (Float64(z1 * z1) <= 5e-251) tmp = Float64(Float64(Float64(-1.0 / Float64(Float64(z1 * Float64(z2 / z3)) + Float64(Float64(z0 / z1) * z3))) * z3) * z1); else tmp = Float64(-1.0 / Float64(Float64(Float64(z2 / z3) / z3) + Float64(z0 / Float64(z1 * z1)))); end return tmp end
function tmp_2 = code(z2, z3, z0, z1) tmp = 0.0; if ((z1 * z1) <= 5e-251) tmp = ((-1.0 / ((z1 * (z2 / z3)) + ((z0 / z1) * z3))) * z3) * z1; else tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (z1 * z1))); end tmp_2 = tmp; end
code[z2_, z3_, z0_, z1_] := If[LessEqual[N[(z1 * z1), $MachinePrecision], 5e-251], N[(N[(N[(-1.0 / N[(N[(z1 * N[(z2 / z3), $MachinePrecision]), $MachinePrecision] + N[(N[(z0 / z1), $MachinePrecision] * z3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision] * z1), $MachinePrecision], N[(-1.0 / N[(N[(N[(z2 / z3), $MachinePrecision] / z3), $MachinePrecision] + N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z1 \cdot z1 \leq 5 \cdot 10^{-251}:\\
\;\;\;\;\left(\frac{-1}{z1 \cdot \frac{z2}{z3} + \frac{z0}{z1} \cdot z3} \cdot z3\right) \cdot z1\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\frac{z2}{z3}}{z3} + \frac{z0}{z1 \cdot z1}}\\
\end{array}
if (*.f64 z1 z1) < 5.0000000000000003e-251Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.5%
Applied rewrites94.5%
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
common-denominatorN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6484.4%
Applied rewrites84.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6487.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6487.1%
Applied rewrites87.1%
if 5.0000000000000003e-251 < (*.f64 z1 z1) Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
(FPCore (z2 z3 z0 z1) :precision binary64 (if (<= (fabs z1) 1e-125) (/ (* (fabs z1) z3) (- (+ (* (fabs z1) (/ z2 z3)) (* (/ z0 (fabs z1)) z3)))) (/ -1.0 (+ (/ (/ z2 z3) z3) (/ z0 (* (fabs z1) (fabs z1)))))))
double code(double z2, double z3, double z0, double z1) {
double tmp;
if (fabs(z1) <= 1e-125) {
tmp = (fabs(z1) * z3) / -((fabs(z1) * (z2 / z3)) + ((z0 / fabs(z1)) * z3));
} else {
tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (fabs(z1) * fabs(z1))));
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8) :: tmp
if (abs(z1) <= 1d-125) then
tmp = (abs(z1) * z3) / -((abs(z1) * (z2 / z3)) + ((z0 / abs(z1)) * z3))
else
tmp = (-1.0d0) / (((z2 / z3) / z3) + (z0 / (abs(z1) * abs(z1))))
end if
code = tmp
end function
public static double code(double z2, double z3, double z0, double z1) {
double tmp;
if (Math.abs(z1) <= 1e-125) {
tmp = (Math.abs(z1) * z3) / -((Math.abs(z1) * (z2 / z3)) + ((z0 / Math.abs(z1)) * z3));
} else {
tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (Math.abs(z1) * Math.abs(z1))));
}
return tmp;
}
def code(z2, z3, z0, z1): tmp = 0 if math.fabs(z1) <= 1e-125: tmp = (math.fabs(z1) * z3) / -((math.fabs(z1) * (z2 / z3)) + ((z0 / math.fabs(z1)) * z3)) else: tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (math.fabs(z1) * math.fabs(z1)))) return tmp
function code(z2, z3, z0, z1) tmp = 0.0 if (abs(z1) <= 1e-125) tmp = Float64(Float64(abs(z1) * z3) / Float64(-Float64(Float64(abs(z1) * Float64(z2 / z3)) + Float64(Float64(z0 / abs(z1)) * z3)))); else tmp = Float64(-1.0 / Float64(Float64(Float64(z2 / z3) / z3) + Float64(z0 / Float64(abs(z1) * abs(z1))))); end return tmp end
function tmp_2 = code(z2, z3, z0, z1) tmp = 0.0; if (abs(z1) <= 1e-125) tmp = (abs(z1) * z3) / -((abs(z1) * (z2 / z3)) + ((z0 / abs(z1)) * z3)); else tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (abs(z1) * abs(z1)))); end tmp_2 = tmp; end
code[z2_, z3_, z0_, z1_] := If[LessEqual[N[Abs[z1], $MachinePrecision], 1e-125], N[(N[(N[Abs[z1], $MachinePrecision] * z3), $MachinePrecision] / (-N[(N[(N[Abs[z1], $MachinePrecision] * N[(z2 / z3), $MachinePrecision]), $MachinePrecision] + N[(N[(z0 / N[Abs[z1], $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], N[(-1.0 / N[(N[(N[(z2 / z3), $MachinePrecision] / z3), $MachinePrecision] + N[(z0 / N[(N[Abs[z1], $MachinePrecision] * N[Abs[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z1\right| \leq 10^{-125}:\\
\;\;\;\;\frac{\left|z1\right| \cdot z3}{-\left(\left|z1\right| \cdot \frac{z2}{z3} + \frac{z0}{\left|z1\right|} \cdot z3\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\frac{z2}{z3}}{z3} + \frac{z0}{\left|z1\right| \cdot \left|z1\right|}}\\
\end{array}
if z1 < 1e-125Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.5%
Applied rewrites94.5%
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
common-denominatorN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6484.4%
Applied rewrites84.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
mult-flip-revN/A
lower-/.f64N/A
lower-neg.f6484.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6484.5%
Applied rewrites84.5%
if 1e-125 < z1 Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
(FPCore (z2 z3 z0 z1) :precision binary64 (if (<= (fabs z1) 4e-149) (* (/ (fabs z1) z0) (- (fabs z1))) (/ -1.0 (+ (/ (/ z2 z3) z3) (/ z0 (* (fabs z1) (fabs z1)))))))
double code(double z2, double z3, double z0, double z1) {
double tmp;
if (fabs(z1) <= 4e-149) {
tmp = (fabs(z1) / z0) * -fabs(z1);
} else {
tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (fabs(z1) * fabs(z1))));
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8) :: tmp
if (abs(z1) <= 4d-149) then
tmp = (abs(z1) / z0) * -abs(z1)
else
tmp = (-1.0d0) / (((z2 / z3) / z3) + (z0 / (abs(z1) * abs(z1))))
end if
code = tmp
end function
public static double code(double z2, double z3, double z0, double z1) {
double tmp;
if (Math.abs(z1) <= 4e-149) {
tmp = (Math.abs(z1) / z0) * -Math.abs(z1);
} else {
tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (Math.abs(z1) * Math.abs(z1))));
}
return tmp;
}
def code(z2, z3, z0, z1): tmp = 0 if math.fabs(z1) <= 4e-149: tmp = (math.fabs(z1) / z0) * -math.fabs(z1) else: tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (math.fabs(z1) * math.fabs(z1)))) return tmp
function code(z2, z3, z0, z1) tmp = 0.0 if (abs(z1) <= 4e-149) tmp = Float64(Float64(abs(z1) / z0) * Float64(-abs(z1))); else tmp = Float64(-1.0 / Float64(Float64(Float64(z2 / z3) / z3) + Float64(z0 / Float64(abs(z1) * abs(z1))))); end return tmp end
function tmp_2 = code(z2, z3, z0, z1) tmp = 0.0; if (abs(z1) <= 4e-149) tmp = (abs(z1) / z0) * -abs(z1); else tmp = -1.0 / (((z2 / z3) / z3) + (z0 / (abs(z1) * abs(z1)))); end tmp_2 = tmp; end
code[z2_, z3_, z0_, z1_] := If[LessEqual[N[Abs[z1], $MachinePrecision], 4e-149], N[(N[(N[Abs[z1], $MachinePrecision] / z0), $MachinePrecision] * (-N[Abs[z1], $MachinePrecision])), $MachinePrecision], N[(-1.0 / N[(N[(N[(z2 / z3), $MachinePrecision] / z3), $MachinePrecision] + N[(z0 / N[(N[Abs[z1], $MachinePrecision] * N[Abs[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z1\right| \leq 4 \cdot 10^{-149}:\\
\;\;\;\;\frac{\left|z1\right|}{z0} \cdot \left(-\left|z1\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\frac{z2}{z3}}{z3} + \frac{z0}{\left|z1\right| \cdot \left|z1\right|}}\\
\end{array}
if z1 < 3.9999999999999999e-149Initial program 81.3%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
distribute-neg-frac2N/A
div-flip-revN/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.5%
Applied rewrites68.5%
Taylor expanded in z2 around 0
Applied rewrites50.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.0%
Applied rewrites55.0%
if 3.9999999999999999e-149 < z1 Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
(FPCore (z2 z3 z0 z1)
:precision binary64
(let* ((t_0 (/ z2 (* z3 z3))))
(if (<= (+ t_0 (/ z0 (* z1 z1))) INFINITY)
(/ -1.0 (+ t_0 (/ (/ z0 z1) z1)))
(/ (* (* z1 z1) z3) (- (* z0 z3))))))double code(double z2, double z3, double z0, double z1) {
double t_0 = z2 / (z3 * z3);
double tmp;
if ((t_0 + (z0 / (z1 * z1))) <= ((double) INFINITY)) {
tmp = -1.0 / (t_0 + ((z0 / z1) / z1));
} else {
tmp = ((z1 * z1) * z3) / -(z0 * z3);
}
return tmp;
}
public static double code(double z2, double z3, double z0, double z1) {
double t_0 = z2 / (z3 * z3);
double tmp;
if ((t_0 + (z0 / (z1 * z1))) <= Double.POSITIVE_INFINITY) {
tmp = -1.0 / (t_0 + ((z0 / z1) / z1));
} else {
tmp = ((z1 * z1) * z3) / -(z0 * z3);
}
return tmp;
}
def code(z2, z3, z0, z1): t_0 = z2 / (z3 * z3) tmp = 0 if (t_0 + (z0 / (z1 * z1))) <= math.inf: tmp = -1.0 / (t_0 + ((z0 / z1) / z1)) else: tmp = ((z1 * z1) * z3) / -(z0 * z3) return tmp
function code(z2, z3, z0, z1) t_0 = Float64(z2 / Float64(z3 * z3)) tmp = 0.0 if (Float64(t_0 + Float64(z0 / Float64(z1 * z1))) <= Inf) tmp = Float64(-1.0 / Float64(t_0 + Float64(Float64(z0 / z1) / z1))); else tmp = Float64(Float64(Float64(z1 * z1) * z3) / Float64(-Float64(z0 * z3))); end return tmp end
function tmp_2 = code(z2, z3, z0, z1) t_0 = z2 / (z3 * z3); tmp = 0.0; if ((t_0 + (z0 / (z1 * z1))) <= Inf) tmp = -1.0 / (t_0 + ((z0 / z1) / z1)); else tmp = ((z1 * z1) * z3) / -(z0 * z3); end tmp_2 = tmp; end
code[z2_, z3_, z0_, z1_] := Block[{t$95$0 = N[(z2 / N[(z3 * z3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 + N[(z0 / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(-1.0 / N[(t$95$0 + N[(N[(z0 / z1), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z1 * z1), $MachinePrecision] * z3), $MachinePrecision] / (-N[(z0 * z3), $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{z2}{z3 \cdot z3}\\
\mathbf{if}\;t\_0 + \frac{z0}{z1 \cdot z1} \leq \infty:\\
\;\;\;\;\frac{-1}{t\_0 + \frac{\frac{z0}{z1}}{z1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(z1 \cdot z1\right) \cdot z3}{-z0 \cdot z3}\\
\end{array}
if (+.f64 (/.f64 z2 (*.f64 z3 z3)) (/.f64 z0 (*.f64 z1 z1))) < +inf.0Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6488.0%
Applied rewrites88.0%
if +inf.0 < (+.f64 (/.f64 z2 (*.f64 z3 z3)) (/.f64 z0 (*.f64 z1 z1))) Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
common-denominatorN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6463.0%
Applied rewrites63.0%
Taylor expanded in z2 around 0
lower-*.f6442.6%
Applied rewrites42.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
mult-flip-revN/A
lower-/.f64N/A
lower-neg.f6442.9%
Applied rewrites42.9%
(FPCore (z2 z3 z0 z1) :precision binary64 (if (<= (fabs z1) 5.5e-123) (* (/ (fabs z1) z0) (- (fabs z1))) (/ 1.0 (- (/ z2 (* (- z3) z3)) (/ z0 (* (fabs z1) (fabs z1)))))))
double code(double z2, double z3, double z0, double z1) {
double tmp;
if (fabs(z1) <= 5.5e-123) {
tmp = (fabs(z1) / z0) * -fabs(z1);
} else {
tmp = 1.0 / ((z2 / (-z3 * z3)) - (z0 / (fabs(z1) * fabs(z1))));
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8) :: tmp
if (abs(z1) <= 5.5d-123) then
tmp = (abs(z1) / z0) * -abs(z1)
else
tmp = 1.0d0 / ((z2 / (-z3 * z3)) - (z0 / (abs(z1) * abs(z1))))
end if
code = tmp
end function
public static double code(double z2, double z3, double z0, double z1) {
double tmp;
if (Math.abs(z1) <= 5.5e-123) {
tmp = (Math.abs(z1) / z0) * -Math.abs(z1);
} else {
tmp = 1.0 / ((z2 / (-z3 * z3)) - (z0 / (Math.abs(z1) * Math.abs(z1))));
}
return tmp;
}
def code(z2, z3, z0, z1): tmp = 0 if math.fabs(z1) <= 5.5e-123: tmp = (math.fabs(z1) / z0) * -math.fabs(z1) else: tmp = 1.0 / ((z2 / (-z3 * z3)) - (z0 / (math.fabs(z1) * math.fabs(z1)))) return tmp
function code(z2, z3, z0, z1) tmp = 0.0 if (abs(z1) <= 5.5e-123) tmp = Float64(Float64(abs(z1) / z0) * Float64(-abs(z1))); else tmp = Float64(1.0 / Float64(Float64(z2 / Float64(Float64(-z3) * z3)) - Float64(z0 / Float64(abs(z1) * abs(z1))))); end return tmp end
function tmp_2 = code(z2, z3, z0, z1) tmp = 0.0; if (abs(z1) <= 5.5e-123) tmp = (abs(z1) / z0) * -abs(z1); else tmp = 1.0 / ((z2 / (-z3 * z3)) - (z0 / (abs(z1) * abs(z1)))); end tmp_2 = tmp; end
code[z2_, z3_, z0_, z1_] := If[LessEqual[N[Abs[z1], $MachinePrecision], 5.5e-123], N[(N[(N[Abs[z1], $MachinePrecision] / z0), $MachinePrecision] * (-N[Abs[z1], $MachinePrecision])), $MachinePrecision], N[(1.0 / N[(N[(z2 / N[((-z3) * z3), $MachinePrecision]), $MachinePrecision] - N[(z0 / N[(N[Abs[z1], $MachinePrecision] * N[Abs[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z1\right| \leq 5.5 \cdot 10^{-123}:\\
\;\;\;\;\frac{\left|z1\right|}{z0} \cdot \left(-\left|z1\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z2}{\left(-z3\right) \cdot z3} - \frac{z0}{\left|z1\right| \cdot \left|z1\right|}}\\
\end{array}
if z1 < 5.5e-123Initial program 81.3%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
distribute-neg-frac2N/A
div-flip-revN/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.5%
Applied rewrites68.5%
Taylor expanded in z2 around 0
Applied rewrites50.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.0%
Applied rewrites55.0%
if 5.5e-123 < z1 Initial program 81.3%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
fp-cancel-sign-sub-invN/A
sub-negateN/A
lower--.f64N/A
Applied rewrites81.3%
(FPCore (z2 z3 z0 z1) :precision binary64 (if (<= (fabs z1) 5.5e-123) (* (/ (fabs z1) z0) (- (fabs z1))) (/ -1.0 (+ (/ z2 (* z3 z3)) (/ z0 (* (fabs z1) (fabs z1)))))))
double code(double z2, double z3, double z0, double z1) {
double tmp;
if (fabs(z1) <= 5.5e-123) {
tmp = (fabs(z1) / z0) * -fabs(z1);
} else {
tmp = -1.0 / ((z2 / (z3 * z3)) + (z0 / (fabs(z1) * fabs(z1))));
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8) :: tmp
if (abs(z1) <= 5.5d-123) then
tmp = (abs(z1) / z0) * -abs(z1)
else
tmp = (-1.0d0) / ((z2 / (z3 * z3)) + (z0 / (abs(z1) * abs(z1))))
end if
code = tmp
end function
public static double code(double z2, double z3, double z0, double z1) {
double tmp;
if (Math.abs(z1) <= 5.5e-123) {
tmp = (Math.abs(z1) / z0) * -Math.abs(z1);
} else {
tmp = -1.0 / ((z2 / (z3 * z3)) + (z0 / (Math.abs(z1) * Math.abs(z1))));
}
return tmp;
}
def code(z2, z3, z0, z1): tmp = 0 if math.fabs(z1) <= 5.5e-123: tmp = (math.fabs(z1) / z0) * -math.fabs(z1) else: tmp = -1.0 / ((z2 / (z3 * z3)) + (z0 / (math.fabs(z1) * math.fabs(z1)))) return tmp
function code(z2, z3, z0, z1) tmp = 0.0 if (abs(z1) <= 5.5e-123) tmp = Float64(Float64(abs(z1) / z0) * Float64(-abs(z1))); else tmp = Float64(-1.0 / Float64(Float64(z2 / Float64(z3 * z3)) + Float64(z0 / Float64(abs(z1) * abs(z1))))); end return tmp end
function tmp_2 = code(z2, z3, z0, z1) tmp = 0.0; if (abs(z1) <= 5.5e-123) tmp = (abs(z1) / z0) * -abs(z1); else tmp = -1.0 / ((z2 / (z3 * z3)) + (z0 / (abs(z1) * abs(z1)))); end tmp_2 = tmp; end
code[z2_, z3_, z0_, z1_] := If[LessEqual[N[Abs[z1], $MachinePrecision], 5.5e-123], N[(N[(N[Abs[z1], $MachinePrecision] / z0), $MachinePrecision] * (-N[Abs[z1], $MachinePrecision])), $MachinePrecision], N[(-1.0 / N[(N[(z2 / N[(z3 * z3), $MachinePrecision]), $MachinePrecision] + N[(z0 / N[(N[Abs[z1], $MachinePrecision] * N[Abs[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z1\right| \leq 5.5 \cdot 10^{-123}:\\
\;\;\;\;\frac{\left|z1\right|}{z0} \cdot \left(-\left|z1\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{z2}{z3 \cdot z3} + \frac{z0}{\left|z1\right| \cdot \left|z1\right|}}\\
\end{array}
if z1 < 5.5e-123Initial program 81.3%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
distribute-neg-frac2N/A
div-flip-revN/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.5%
Applied rewrites68.5%
Taylor expanded in z2 around 0
Applied rewrites50.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.0%
Applied rewrites55.0%
if 5.5e-123 < z1 Initial program 81.3%
(FPCore (z2 z3 z0 z1)
:precision binary64
(let* ((t_0 (/ z2 (* z3 z3)))
(t_1 (* (* -1.0 (/ z3 (* z1 z2))) (* z1 z3))))
(if (<= t_0 -1e+200)
t_1
(if (<= t_0 2e-5) (* (/ z1 z0) (- z1)) t_1))))double code(double z2, double z3, double z0, double z1) {
double t_0 = z2 / (z3 * z3);
double t_1 = (-1.0 * (z3 / (z1 * z2))) * (z1 * z3);
double tmp;
if (t_0 <= -1e+200) {
tmp = t_1;
} else if (t_0 <= 2e-5) {
tmp = (z1 / z0) * -z1;
} 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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z2 / (z3 * z3)
t_1 = ((-1.0d0) * (z3 / (z1 * z2))) * (z1 * z3)
if (t_0 <= (-1d+200)) then
tmp = t_1
else if (t_0 <= 2d-5) then
tmp = (z1 / z0) * -z1
else
tmp = t_1
end if
code = tmp
end function
public static double code(double z2, double z3, double z0, double z1) {
double t_0 = z2 / (z3 * z3);
double t_1 = (-1.0 * (z3 / (z1 * z2))) * (z1 * z3);
double tmp;
if (t_0 <= -1e+200) {
tmp = t_1;
} else if (t_0 <= 2e-5) {
tmp = (z1 / z0) * -z1;
} else {
tmp = t_1;
}
return tmp;
}
def code(z2, z3, z0, z1): t_0 = z2 / (z3 * z3) t_1 = (-1.0 * (z3 / (z1 * z2))) * (z1 * z3) tmp = 0 if t_0 <= -1e+200: tmp = t_1 elif t_0 <= 2e-5: tmp = (z1 / z0) * -z1 else: tmp = t_1 return tmp
function code(z2, z3, z0, z1) t_0 = Float64(z2 / Float64(z3 * z3)) t_1 = Float64(Float64(-1.0 * Float64(z3 / Float64(z1 * z2))) * Float64(z1 * z3)) tmp = 0.0 if (t_0 <= -1e+200) tmp = t_1; elseif (t_0 <= 2e-5) tmp = Float64(Float64(z1 / z0) * Float64(-z1)); else tmp = t_1; end return tmp end
function tmp_2 = code(z2, z3, z0, z1) t_0 = z2 / (z3 * z3); t_1 = (-1.0 * (z3 / (z1 * z2))) * (z1 * z3); tmp = 0.0; if (t_0 <= -1e+200) tmp = t_1; elseif (t_0 <= 2e-5) tmp = (z1 / z0) * -z1; else tmp = t_1; end tmp_2 = tmp; end
code[z2_, z3_, z0_, z1_] := Block[{t$95$0 = N[(z2 / N[(z3 * z3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-1.0 * N[(z3 / N[(z1 * z2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z1 * z3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+200], t$95$1, If[LessEqual[t$95$0, 2e-5], N[(N[(z1 / z0), $MachinePrecision] * (-z1)), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \frac{z2}{z3 \cdot z3}\\
t_1 := \left(-1 \cdot \frac{z3}{z1 \cdot z2}\right) \cdot \left(z1 \cdot z3\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+200}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\frac{z1}{z0} \cdot \left(-z1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 z2 (*.f64 z3 z3)) < -9.9999999999999997e199 or 2.0000000000000002e-5 < (/.f64 z2 (*.f64 z3 z3)) Initial program 81.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.6%
Applied rewrites87.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6494.5%
Applied rewrites94.5%
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
common-denominatorN/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6484.4%
Applied rewrites84.4%
Taylor expanded in z2 around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6446.5%
Applied rewrites46.5%
if -9.9999999999999997e199 < (/.f64 z2 (*.f64 z3 z3)) < 2.0000000000000002e-5Initial program 81.3%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
distribute-neg-frac2N/A
div-flip-revN/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.5%
Applied rewrites68.5%
Taylor expanded in z2 around 0
Applied rewrites50.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.0%
Applied rewrites55.0%
(FPCore (z2 z3 z0 z1) :precision binary64 (* (/ z1 z0) (- z1)))
double code(double z2, double z3, double z0, double z1) {
return (z1 / z0) * -z1;
}
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, z3, z0, z1)
use fmin_fmax_functions
real(8), intent (in) :: z2
real(8), intent (in) :: z3
real(8), intent (in) :: z0
real(8), intent (in) :: z1
code = (z1 / z0) * -z1
end function
public static double code(double z2, double z3, double z0, double z1) {
return (z1 / z0) * -z1;
}
def code(z2, z3, z0, z1): return (z1 / z0) * -z1
function code(z2, z3, z0, z1) return Float64(Float64(z1 / z0) * Float64(-z1)) end
function tmp = code(z2, z3, z0, z1) tmp = (z1 / z0) * -z1; end
code[z2_, z3_, z0_, z1_] := N[(N[(z1 / z0), $MachinePrecision] * (-z1)), $MachinePrecision]
\frac{z1}{z0} \cdot \left(-z1\right)
Initial program 81.3%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
distribute-neg-frac2N/A
div-flip-revN/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.5%
Applied rewrites68.5%
Taylor expanded in z2 around 0
Applied rewrites50.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6455.0%
Applied rewrites55.0%
herbie shell --seed 2025250
(FPCore (z2 z3 z0 z1)
:name "(/ -1 (+ (/ z2 (* z3 z3)) (/ z0 (* z1 z1))))"
:precision binary64
(/ -1.0 (+ (/ z2 (* z3 z3)) (/ z0 (* z1 z1)))))