
(FPCore (z0) :precision binary64 (/ (- (+ z0 z0) -1.3333333333333333) (* z0 z0)))
double code(double z0) {
return ((z0 + z0) - -1.3333333333333333) / (z0 * z0);
}
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(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = ((z0 + z0) - (-1.3333333333333333d0)) / (z0 * z0)
end function
public static double code(double z0) {
return ((z0 + z0) - -1.3333333333333333) / (z0 * z0);
}
def code(z0): return ((z0 + z0) - -1.3333333333333333) / (z0 * z0)
function code(z0) return Float64(Float64(Float64(z0 + z0) - -1.3333333333333333) / Float64(z0 * z0)) end
function tmp = code(z0) tmp = ((z0 + z0) - -1.3333333333333333) / (z0 * z0); end
code[z0_] := N[(N[(N[(z0 + z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]
\frac{\left(z0 + z0\right) - -1.3333333333333333}{z0 \cdot z0}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0) :precision binary64 (/ (- (+ z0 z0) -1.3333333333333333) (* z0 z0)))
double code(double z0) {
return ((z0 + z0) - -1.3333333333333333) / (z0 * z0);
}
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(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = ((z0 + z0) - (-1.3333333333333333d0)) / (z0 * z0)
end function
public static double code(double z0) {
return ((z0 + z0) - -1.3333333333333333) / (z0 * z0);
}
def code(z0): return ((z0 + z0) - -1.3333333333333333) / (z0 * z0)
function code(z0) return Float64(Float64(Float64(z0 + z0) - -1.3333333333333333) / Float64(z0 * z0)) end
function tmp = code(z0) tmp = ((z0 + z0) - -1.3333333333333333) / (z0 * z0); end
code[z0_] := N[(N[(N[(z0 + z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]
\frac{\left(z0 + z0\right) - -1.3333333333333333}{z0 \cdot z0}
(FPCore (z0) :precision binary64 (- (/ 2.0 z0) (/ -1.3333333333333333 (* z0 z0))))
double code(double z0) {
return (2.0 / z0) - (-1.3333333333333333 / (z0 * z0));
}
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(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = (2.0d0 / z0) - ((-1.3333333333333333d0) / (z0 * z0))
end function
public static double code(double z0) {
return (2.0 / z0) - (-1.3333333333333333 / (z0 * z0));
}
def code(z0): return (2.0 / z0) - (-1.3333333333333333 / (z0 * z0))
function code(z0) return Float64(Float64(2.0 / z0) - Float64(-1.3333333333333333 / Float64(z0 * z0))) end
function tmp = code(z0) tmp = (2.0 / z0) - (-1.3333333333333333 / (z0 * z0)); end
code[z0_] := N[(N[(2.0 / z0), $MachinePrecision] - N[(-1.3333333333333333 / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{2}{z0} - \frac{-1.3333333333333333}{z0 \cdot z0}
Initial program 76.1%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-+.f64N/A
count-2N/A
lift-*.f64N/A
times-fracN/A
*-inversesN/A
associate-*l/N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6499.9%
Applied rewrites99.9%
(FPCore (z0) :precision binary64 (/ (- (/ 1.3333333333333333 z0) -2.0) z0))
double code(double z0) {
return ((1.3333333333333333 / z0) - -2.0) / z0;
}
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(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = ((1.3333333333333333d0 / z0) - (-2.0d0)) / z0
end function
public static double code(double z0) {
return ((1.3333333333333333 / z0) - -2.0) / z0;
}
def code(z0): return ((1.3333333333333333 / z0) - -2.0) / z0
function code(z0) return Float64(Float64(Float64(1.3333333333333333 / z0) - -2.0) / z0) end
function tmp = code(z0) tmp = ((1.3333333333333333 / z0) - -2.0) / z0; end
code[z0_] := N[(N[(N[(1.3333333333333333 / z0), $MachinePrecision] - -2.0), $MachinePrecision] / z0), $MachinePrecision]
\frac{\frac{1.3333333333333333}{z0} - -2}{z0}
Initial program 76.1%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
lift-+.f64N/A
count-2N/A
lift-*.f64N/A
times-fracN/A
*-inversesN/A
associate-*l/N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6499.9%
Applied rewrites99.9%
lift--.f64N/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
distribute-neg-fracN/A
distribute-frac-negN/A
metadata-evalN/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
lower-/.f6499.9%
Applied rewrites99.9%
(FPCore (z0) :precision binary64 (let* ((t_0 (/ (- (+ z0 z0) -1.3333333333333333) (* z0 z0)))) (if (<= t_0 5e-40) (/ 2.0 z0) t_0)))
double code(double z0) {
double t_0 = ((z0 + z0) - -1.3333333333333333) / (z0 * z0);
double tmp;
if (t_0 <= 5e-40) {
tmp = 2.0 / z0;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8) :: t_0
real(8) :: tmp
t_0 = ((z0 + z0) - (-1.3333333333333333d0)) / (z0 * z0)
if (t_0 <= 5d-40) then
tmp = 2.0d0 / z0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double z0) {
double t_0 = ((z0 + z0) - -1.3333333333333333) / (z0 * z0);
double tmp;
if (t_0 <= 5e-40) {
tmp = 2.0 / z0;
} else {
tmp = t_0;
}
return tmp;
}
def code(z0): t_0 = ((z0 + z0) - -1.3333333333333333) / (z0 * z0) tmp = 0 if t_0 <= 5e-40: tmp = 2.0 / z0 else: tmp = t_0 return tmp
function code(z0) t_0 = Float64(Float64(Float64(z0 + z0) - -1.3333333333333333) / Float64(z0 * z0)) tmp = 0.0 if (t_0 <= 5e-40) tmp = Float64(2.0 / z0); else tmp = t_0; end return tmp end
function tmp_2 = code(z0) t_0 = ((z0 + z0) - -1.3333333333333333) / (z0 * z0); tmp = 0.0; if (t_0 <= 5e-40) tmp = 2.0 / z0; else tmp = t_0; end tmp_2 = tmp; end
code[z0_] := Block[{t$95$0 = N[(N[(N[(z0 + z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-40], N[(2.0 / z0), $MachinePrecision], t$95$0]]
\begin{array}{l}
t_0 := \frac{\left(z0 + z0\right) - -1.3333333333333333}{z0 \cdot z0}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-40}:\\
\;\;\;\;\frac{2}{z0}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (/.f64 (-.f64 (+.f64 z0 z0) #s(literal -13333333333333333/10000000000000000 binary64)) (*.f64 z0 z0)) < 4.9999999999999996e-40Initial program 76.1%
Taylor expanded in z0 around inf
lower-/.f6451.4%
Applied rewrites51.4%
if 4.9999999999999996e-40 < (/.f64 (-.f64 (+.f64 z0 z0) #s(literal -13333333333333333/10000000000000000 binary64)) (*.f64 z0 z0)) Initial program 76.1%
(FPCore (z0) :precision binary64 (if (<= (/ (- (+ z0 z0) -1.3333333333333333) (* z0 z0)) 5e-40) (/ 2.0 z0) (/ (- z0 (- -1.3333333333333333 z0)) (* z0 z0))))
double code(double z0) {
double tmp;
if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 5e-40) {
tmp = 2.0 / z0;
} else {
tmp = (z0 - (-1.3333333333333333 - z0)) / (z0 * z0);
}
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(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8) :: tmp
if ((((z0 + z0) - (-1.3333333333333333d0)) / (z0 * z0)) <= 5d-40) then
tmp = 2.0d0 / z0
else
tmp = (z0 - ((-1.3333333333333333d0) - z0)) / (z0 * z0)
end if
code = tmp
end function
public static double code(double z0) {
double tmp;
if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 5e-40) {
tmp = 2.0 / z0;
} else {
tmp = (z0 - (-1.3333333333333333 - z0)) / (z0 * z0);
}
return tmp;
}
def code(z0): tmp = 0 if (((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 5e-40: tmp = 2.0 / z0 else: tmp = (z0 - (-1.3333333333333333 - z0)) / (z0 * z0) return tmp
function code(z0) tmp = 0.0 if (Float64(Float64(Float64(z0 + z0) - -1.3333333333333333) / Float64(z0 * z0)) <= 5e-40) tmp = Float64(2.0 / z0); else tmp = Float64(Float64(z0 - Float64(-1.3333333333333333 - z0)) / Float64(z0 * z0)); end return tmp end
function tmp_2 = code(z0) tmp = 0.0; if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 5e-40) tmp = 2.0 / z0; else tmp = (z0 - (-1.3333333333333333 - z0)) / (z0 * z0); end tmp_2 = tmp; end
code[z0_] := If[LessEqual[N[(N[(N[(z0 + z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision], 5e-40], N[(2.0 / z0), $MachinePrecision], N[(N[(z0 - N[(-1.3333333333333333 - z0), $MachinePrecision]), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{\left(z0 + z0\right) - -1.3333333333333333}{z0 \cdot z0} \leq 5 \cdot 10^{-40}:\\
\;\;\;\;\frac{2}{z0}\\
\mathbf{else}:\\
\;\;\;\;\frac{z0 - \left(-1.3333333333333333 - z0\right)}{z0 \cdot z0}\\
\end{array}
if (/.f64 (-.f64 (+.f64 z0 z0) #s(literal -13333333333333333/10000000000000000 binary64)) (*.f64 z0 z0)) < 4.9999999999999996e-40Initial program 76.1%
Taylor expanded in z0 around inf
lower-/.f6451.4%
Applied rewrites51.4%
if 4.9999999999999996e-40 < (/.f64 (-.f64 (+.f64 z0 z0) #s(literal -13333333333333333/10000000000000000 binary64)) (*.f64 z0 z0)) Initial program 76.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6476.1%
Applied rewrites76.1%
(FPCore (z0) :precision binary64 (if (<= (/ (- (+ z0 z0) -1.3333333333333333) (* z0 z0)) 2e-8) (/ 2.0 z0) (/ (- z0 -1.3333333333333333) (* z0 z0))))
double code(double z0) {
double tmp;
if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 2e-8) {
tmp = 2.0 / z0;
} else {
tmp = (z0 - -1.3333333333333333) / (z0 * z0);
}
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(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8) :: tmp
if ((((z0 + z0) - (-1.3333333333333333d0)) / (z0 * z0)) <= 2d-8) then
tmp = 2.0d0 / z0
else
tmp = (z0 - (-1.3333333333333333d0)) / (z0 * z0)
end if
code = tmp
end function
public static double code(double z0) {
double tmp;
if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 2e-8) {
tmp = 2.0 / z0;
} else {
tmp = (z0 - -1.3333333333333333) / (z0 * z0);
}
return tmp;
}
def code(z0): tmp = 0 if (((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 2e-8: tmp = 2.0 / z0 else: tmp = (z0 - -1.3333333333333333) / (z0 * z0) return tmp
function code(z0) tmp = 0.0 if (Float64(Float64(Float64(z0 + z0) - -1.3333333333333333) / Float64(z0 * z0)) <= 2e-8) tmp = Float64(2.0 / z0); else tmp = Float64(Float64(z0 - -1.3333333333333333) / Float64(z0 * z0)); end return tmp end
function tmp_2 = code(z0) tmp = 0.0; if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 2e-8) tmp = 2.0 / z0; else tmp = (z0 - -1.3333333333333333) / (z0 * z0); end tmp_2 = tmp; end
code[z0_] := If[LessEqual[N[(N[(N[(z0 + z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision], 2e-8], N[(2.0 / z0), $MachinePrecision], N[(N[(z0 - -1.3333333333333333), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{\left(z0 + z0\right) - -1.3333333333333333}{z0 \cdot z0} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{2}{z0}\\
\mathbf{else}:\\
\;\;\;\;\frac{z0 - -1.3333333333333333}{z0 \cdot z0}\\
\end{array}
if (/.f64 (-.f64 (+.f64 z0 z0) #s(literal -13333333333333333/10000000000000000 binary64)) (*.f64 z0 z0)) < 2e-8Initial program 76.1%
Taylor expanded in z0 around inf
lower-/.f6451.4%
Applied rewrites51.4%
if 2e-8 < (/.f64 (-.f64 (+.f64 z0 z0) #s(literal -13333333333333333/10000000000000000 binary64)) (*.f64 z0 z0)) Initial program 76.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6476.1%
Applied rewrites76.1%
Taylor expanded in z0 around 0
Applied rewrites54.8%
(FPCore (z0) :precision binary64 (if (<= (/ (- (+ z0 z0) -1.3333333333333333) (* z0 z0)) 2e-8) (/ 2.0 z0) (/ 1.3333333333333333 (* z0 z0))))
double code(double z0) {
double tmp;
if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 2e-8) {
tmp = 2.0 / z0;
} else {
tmp = 1.3333333333333333 / (z0 * z0);
}
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(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8) :: tmp
if ((((z0 + z0) - (-1.3333333333333333d0)) / (z0 * z0)) <= 2d-8) then
tmp = 2.0d0 / z0
else
tmp = 1.3333333333333333d0 / (z0 * z0)
end if
code = tmp
end function
public static double code(double z0) {
double tmp;
if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 2e-8) {
tmp = 2.0 / z0;
} else {
tmp = 1.3333333333333333 / (z0 * z0);
}
return tmp;
}
def code(z0): tmp = 0 if (((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 2e-8: tmp = 2.0 / z0 else: tmp = 1.3333333333333333 / (z0 * z0) return tmp
function code(z0) tmp = 0.0 if (Float64(Float64(Float64(z0 + z0) - -1.3333333333333333) / Float64(z0 * z0)) <= 2e-8) tmp = Float64(2.0 / z0); else tmp = Float64(1.3333333333333333 / Float64(z0 * z0)); end return tmp end
function tmp_2 = code(z0) tmp = 0.0; if ((((z0 + z0) - -1.3333333333333333) / (z0 * z0)) <= 2e-8) tmp = 2.0 / z0; else tmp = 1.3333333333333333 / (z0 * z0); end tmp_2 = tmp; end
code[z0_] := If[LessEqual[N[(N[(N[(z0 + z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision], 2e-8], N[(2.0 / z0), $MachinePrecision], N[(1.3333333333333333 / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{\left(z0 + z0\right) - -1.3333333333333333}{z0 \cdot z0} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{2}{z0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1.3333333333333333}{z0 \cdot z0}\\
\end{array}
if (/.f64 (-.f64 (+.f64 z0 z0) #s(literal -13333333333333333/10000000000000000 binary64)) (*.f64 z0 z0)) < 2e-8Initial program 76.1%
Taylor expanded in z0 around inf
lower-/.f6451.4%
Applied rewrites51.4%
if 2e-8 < (/.f64 (-.f64 (+.f64 z0 z0) #s(literal -13333333333333333/10000000000000000 binary64)) (*.f64 z0 z0)) Initial program 76.1%
Taylor expanded in z0 around 0
Applied rewrites51.3%
(FPCore (z0) :precision binary64 (/ 2.0 z0))
double code(double z0) {
return 2.0 / z0;
}
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(z0)
use fmin_fmax_functions
real(8), intent (in) :: z0
code = 2.0d0 / z0
end function
public static double code(double z0) {
return 2.0 / z0;
}
def code(z0): return 2.0 / z0
function code(z0) return Float64(2.0 / z0) end
function tmp = code(z0) tmp = 2.0 / z0; end
code[z0_] := N[(2.0 / z0), $MachinePrecision]
\frac{2}{z0}
Initial program 76.1%
Taylor expanded in z0 around inf
lower-/.f6451.4%
Applied rewrites51.4%
herbie shell --seed 2025250
(FPCore (z0)
:name "(/ (- (+ z0 z0) -13333333333333333/10000000000000000) (* z0 z0))"
:precision binary64
(/ (- (+ z0 z0) -1.3333333333333333) (* z0 z0)))