
(FPCore (z0) :precision binary64 (/ (- (- (+ z0 z0) -2.0) (/ -1.3333333333333333 z0)) (* z0 z0)))
double code(double z0) {
return (((z0 + z0) - -2.0) - (-1.3333333333333333 / z0)) / (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) - (-2.0d0)) - ((-1.3333333333333333d0) / z0)) / (z0 * z0)
end function
public static double code(double z0) {
return (((z0 + z0) - -2.0) - (-1.3333333333333333 / z0)) / (z0 * z0);
}
def code(z0): return (((z0 + z0) - -2.0) - (-1.3333333333333333 / z0)) / (z0 * z0)
function code(z0) return Float64(Float64(Float64(Float64(z0 + z0) - -2.0) - Float64(-1.3333333333333333 / z0)) / Float64(z0 * z0)) end
function tmp = code(z0) tmp = (((z0 + z0) - -2.0) - (-1.3333333333333333 / z0)) / (z0 * z0); end
code[z0_] := N[(N[(N[(N[(z0 + z0), $MachinePrecision] - -2.0), $MachinePrecision] - N[(-1.3333333333333333 / z0), $MachinePrecision]), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]
\frac{\left(\left(z0 + z0\right) - -2\right) - \frac{-1.3333333333333333}{z0}}{z0 \cdot z0}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0) :precision binary64 (/ (- (- (+ z0 z0) -2.0) (/ -1.3333333333333333 z0)) (* z0 z0)))
double code(double z0) {
return (((z0 + z0) - -2.0) - (-1.3333333333333333 / z0)) / (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) - (-2.0d0)) - ((-1.3333333333333333d0) / z0)) / (z0 * z0)
end function
public static double code(double z0) {
return (((z0 + z0) - -2.0) - (-1.3333333333333333 / z0)) / (z0 * z0);
}
def code(z0): return (((z0 + z0) - -2.0) - (-1.3333333333333333 / z0)) / (z0 * z0)
function code(z0) return Float64(Float64(Float64(Float64(z0 + z0) - -2.0) - Float64(-1.3333333333333333 / z0)) / Float64(z0 * z0)) end
function tmp = code(z0) tmp = (((z0 + z0) - -2.0) - (-1.3333333333333333 / z0)) / (z0 * z0); end
code[z0_] := N[(N[(N[(N[(z0 + z0), $MachinePrecision] - -2.0), $MachinePrecision] - N[(-1.3333333333333333 / z0), $MachinePrecision]), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]
\frac{\left(\left(z0 + z0\right) - -2\right) - \frac{-1.3333333333333333}{z0}}{z0 \cdot z0}
(FPCore (z0) :precision binary64 (- (/ 2.0 z0) (/ (- (+ z0 z0) -1.3333333333333333) (* (* (- z0) z0) z0))))
double code(double z0) {
return (2.0 / z0) - (((z0 + z0) - -1.3333333333333333) / ((-z0 * 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) - (((z0 + z0) - (-1.3333333333333333d0)) / ((-z0 * z0) * z0))
end function
public static double code(double z0) {
return (2.0 / z0) - (((z0 + z0) - -1.3333333333333333) / ((-z0 * z0) * z0));
}
def code(z0): return (2.0 / z0) - (((z0 + z0) - -1.3333333333333333) / ((-z0 * z0) * z0))
function code(z0) return Float64(Float64(2.0 / z0) - Float64(Float64(Float64(z0 + z0) - -1.3333333333333333) / Float64(Float64(Float64(-z0) * z0) * z0))) end
function tmp = code(z0) tmp = (2.0 / z0) - (((z0 + z0) - -1.3333333333333333) / ((-z0 * z0) * z0)); end
code[z0_] := N[(N[(2.0 / z0), $MachinePrecision] - N[(N[(N[(z0 + z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[(N[((-z0) * z0), $MachinePrecision] * z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{2}{z0} - \frac{\left(z0 + z0\right) - -1.3333333333333333}{\left(\left(-z0\right) \cdot z0\right) \cdot z0}
Initial program 76.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
count-2N/A
sub-to-fraction-revN/A
div-subN/A
associate-/r*N/A
lift-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lift-/.f64N/A
frac-2negN/A
add-to-fractionN/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.9%
(FPCore (z0) :precision binary64 (/ (- 2.0 (/ (- (+ z0 z0) -1.3333333333333333) (* (- z0) z0))) z0))
double code(double z0) {
return (2.0 - (((z0 + z0) - -1.3333333333333333) / (-z0 * 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 + z0) - (-1.3333333333333333d0)) / (-z0 * z0))) / z0
end function
public static double code(double z0) {
return (2.0 - (((z0 + z0) - -1.3333333333333333) / (-z0 * z0))) / z0;
}
def code(z0): return (2.0 - (((z0 + z0) - -1.3333333333333333) / (-z0 * z0))) / z0
function code(z0) return Float64(Float64(2.0 - Float64(Float64(Float64(z0 + z0) - -1.3333333333333333) / Float64(Float64(-z0) * z0))) / z0) end
function tmp = code(z0) tmp = (2.0 - (((z0 + z0) - -1.3333333333333333) / (-z0 * z0))) / z0; end
code[z0_] := N[(N[(2.0 - N[(N[(N[(z0 + z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[((-z0) * z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z0), $MachinePrecision]
\frac{2 - \frac{\left(z0 + z0\right) - -1.3333333333333333}{\left(-z0\right) \cdot z0}}{z0}
Initial program 76.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.9%
(FPCore (z0)
:precision binary64
(let* ((t_0 (/ (- 2.0 (/ -2.0 z0)) z0)))
(if (<= z0 -540.0)
t_0
(if (<= z0 115000000.0)
(/ (- (* 2.0 z0) -1.3333333333333333) (* (* z0 z0) z0))
t_0))))double code(double z0) {
double t_0 = (2.0 - (-2.0 / z0)) / z0;
double tmp;
if (z0 <= -540.0) {
tmp = t_0;
} else if (z0 <= 115000000.0) {
tmp = ((2.0 * z0) - -1.3333333333333333) / ((z0 * z0) * 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 = (2.0d0 - ((-2.0d0) / z0)) / z0
if (z0 <= (-540.0d0)) then
tmp = t_0
else if (z0 <= 115000000.0d0) then
tmp = ((2.0d0 * z0) - (-1.3333333333333333d0)) / ((z0 * z0) * z0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double z0) {
double t_0 = (2.0 - (-2.0 / z0)) / z0;
double tmp;
if (z0 <= -540.0) {
tmp = t_0;
} else if (z0 <= 115000000.0) {
tmp = ((2.0 * z0) - -1.3333333333333333) / ((z0 * z0) * z0);
} else {
tmp = t_0;
}
return tmp;
}
def code(z0): t_0 = (2.0 - (-2.0 / z0)) / z0 tmp = 0 if z0 <= -540.0: tmp = t_0 elif z0 <= 115000000.0: tmp = ((2.0 * z0) - -1.3333333333333333) / ((z0 * z0) * z0) else: tmp = t_0 return tmp
function code(z0) t_0 = Float64(Float64(2.0 - Float64(-2.0 / z0)) / z0) tmp = 0.0 if (z0 <= -540.0) tmp = t_0; elseif (z0 <= 115000000.0) tmp = Float64(Float64(Float64(2.0 * z0) - -1.3333333333333333) / Float64(Float64(z0 * z0) * z0)); else tmp = t_0; end return tmp end
function tmp_2 = code(z0) t_0 = (2.0 - (-2.0 / z0)) / z0; tmp = 0.0; if (z0 <= -540.0) tmp = t_0; elseif (z0 <= 115000000.0) tmp = ((2.0 * z0) - -1.3333333333333333) / ((z0 * z0) * z0); else tmp = t_0; end tmp_2 = tmp; end
code[z0_] := Block[{t$95$0 = N[(N[(2.0 - N[(-2.0 / z0), $MachinePrecision]), $MachinePrecision] / z0), $MachinePrecision]}, If[LessEqual[z0, -540.0], t$95$0, If[LessEqual[z0, 115000000.0], N[(N[(N[(2.0 * z0), $MachinePrecision] - -1.3333333333333333), $MachinePrecision] / N[(N[(z0 * z0), $MachinePrecision] * z0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{2 - \frac{-2}{z0}}{z0}\\
\mathbf{if}\;z0 \leq -540:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z0 \leq 115000000:\\
\;\;\;\;\frac{2 \cdot z0 - -1.3333333333333333}{\left(z0 \cdot z0\right) \cdot z0}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z0 < -540 or 1.15e8 < z0 Initial program 76.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in z0 around 0
Applied rewrites97.9%
Taylor expanded in z0 around inf
lower-/.f6463.9%
Applied rewrites63.9%
if -540 < z0 < 1.15e8Initial program 76.1%
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
associate-/l/N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.2%
Applied rewrites66.2%
Taylor expanded in z0 around 0
Applied rewrites51.8%
(FPCore (z0)
:precision binary64
(let* ((t_0 (/ (- 2.0 (/ -2.0 z0)) z0)))
(if (<= z0 -3800.0)
t_0
(if (<= z0 115000000.0)
(/ (/ 1.3333333333333333 z0) (* z0 z0))
t_0))))double code(double z0) {
double t_0 = (2.0 - (-2.0 / z0)) / z0;
double tmp;
if (z0 <= -3800.0) {
tmp = t_0;
} else if (z0 <= 115000000.0) {
tmp = (1.3333333333333333 / z0) / (z0 * 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 = (2.0d0 - ((-2.0d0) / z0)) / z0
if (z0 <= (-3800.0d0)) then
tmp = t_0
else if (z0 <= 115000000.0d0) then
tmp = (1.3333333333333333d0 / z0) / (z0 * z0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double z0) {
double t_0 = (2.0 - (-2.0 / z0)) / z0;
double tmp;
if (z0 <= -3800.0) {
tmp = t_0;
} else if (z0 <= 115000000.0) {
tmp = (1.3333333333333333 / z0) / (z0 * z0);
} else {
tmp = t_0;
}
return tmp;
}
def code(z0): t_0 = (2.0 - (-2.0 / z0)) / z0 tmp = 0 if z0 <= -3800.0: tmp = t_0 elif z0 <= 115000000.0: tmp = (1.3333333333333333 / z0) / (z0 * z0) else: tmp = t_0 return tmp
function code(z0) t_0 = Float64(Float64(2.0 - Float64(-2.0 / z0)) / z0) tmp = 0.0 if (z0 <= -3800.0) tmp = t_0; elseif (z0 <= 115000000.0) tmp = Float64(Float64(1.3333333333333333 / z0) / Float64(z0 * z0)); else tmp = t_0; end return tmp end
function tmp_2 = code(z0) t_0 = (2.0 - (-2.0 / z0)) / z0; tmp = 0.0; if (z0 <= -3800.0) tmp = t_0; elseif (z0 <= 115000000.0) tmp = (1.3333333333333333 / z0) / (z0 * z0); else tmp = t_0; end tmp_2 = tmp; end
code[z0_] := Block[{t$95$0 = N[(N[(2.0 - N[(-2.0 / z0), $MachinePrecision]), $MachinePrecision] / z0), $MachinePrecision]}, If[LessEqual[z0, -3800.0], t$95$0, If[LessEqual[z0, 115000000.0], N[(N[(1.3333333333333333 / z0), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{2 - \frac{-2}{z0}}{z0}\\
\mathbf{if}\;z0 \leq -3800:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z0 \leq 115000000:\\
\;\;\;\;\frac{\frac{1.3333333333333333}{z0}}{z0 \cdot z0}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z0 < -3800 or 1.15e8 < z0 Initial program 76.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in z0 around 0
Applied rewrites97.9%
Taylor expanded in z0 around inf
lower-/.f6463.9%
Applied rewrites63.9%
if -3800 < z0 < 1.15e8Initial program 76.1%
Taylor expanded in z0 around 0
lower-/.f6451.5%
Applied rewrites51.5%
(FPCore (z0) :precision binary64 (/ (+ (/ 1.3333333333333333 (* z0 z0)) 2.0) z0))
double code(double z0) {
return ((1.3333333333333333 / (z0 * 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 * z0)) + 2.0d0) / z0
end function
public static double code(double z0) {
return ((1.3333333333333333 / (z0 * z0)) + 2.0) / z0;
}
def code(z0): return ((1.3333333333333333 / (z0 * z0)) + 2.0) / z0
function code(z0) return Float64(Float64(Float64(1.3333333333333333 / Float64(z0 * z0)) + 2.0) / z0) end
function tmp = code(z0) tmp = ((1.3333333333333333 / (z0 * z0)) + 2.0) / z0; end
code[z0_] := N[(N[(N[(1.3333333333333333 / N[(z0 * z0), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / z0), $MachinePrecision]
\frac{\frac{1.3333333333333333}{z0 \cdot z0} + 2}{z0}
Initial program 76.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in z0 around 0
Applied rewrites97.9%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lower-+.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
distribute-rgt-neg-outN/A
lift-neg.f64N/A
sqr-neg-revN/A
lift-*.f64N/A
lower-/.f6497.9%
Applied rewrites97.9%
(FPCore (z0)
:precision binary64
(let* ((t_0 (- (+ z0 z0) -2.0)))
(if (<= (/ (- t_0 (/ -1.3333333333333333 z0)) (* z0 z0)) 5e-40)
(/ 2.0 z0)
(/ t_0 (* z0 z0)))))double code(double z0) {
double t_0 = (z0 + z0) - -2.0;
double tmp;
if (((t_0 - (-1.3333333333333333 / z0)) / (z0 * z0)) <= 5e-40) {
tmp = 2.0 / z0;
} else {
tmp = t_0 / (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) :: t_0
real(8) :: tmp
t_0 = (z0 + z0) - (-2.0d0)
if (((t_0 - ((-1.3333333333333333d0) / z0)) / (z0 * z0)) <= 5d-40) then
tmp = 2.0d0 / z0
else
tmp = t_0 / (z0 * z0)
end if
code = tmp
end function
public static double code(double z0) {
double t_0 = (z0 + z0) - -2.0;
double tmp;
if (((t_0 - (-1.3333333333333333 / z0)) / (z0 * z0)) <= 5e-40) {
tmp = 2.0 / z0;
} else {
tmp = t_0 / (z0 * z0);
}
return tmp;
}
def code(z0): t_0 = (z0 + z0) - -2.0 tmp = 0 if ((t_0 - (-1.3333333333333333 / z0)) / (z0 * z0)) <= 5e-40: tmp = 2.0 / z0 else: tmp = t_0 / (z0 * z0) return tmp
function code(z0) t_0 = Float64(Float64(z0 + z0) - -2.0) tmp = 0.0 if (Float64(Float64(t_0 - Float64(-1.3333333333333333 / z0)) / Float64(z0 * z0)) <= 5e-40) tmp = Float64(2.0 / z0); else tmp = Float64(t_0 / Float64(z0 * z0)); end return tmp end
function tmp_2 = code(z0) t_0 = (z0 + z0) - -2.0; tmp = 0.0; if (((t_0 - (-1.3333333333333333 / z0)) / (z0 * z0)) <= 5e-40) tmp = 2.0 / z0; else tmp = t_0 / (z0 * z0); end tmp_2 = tmp; end
code[z0_] := Block[{t$95$0 = N[(N[(z0 + z0), $MachinePrecision] - -2.0), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 - N[(-1.3333333333333333 / z0), $MachinePrecision]), $MachinePrecision] / N[(z0 * z0), $MachinePrecision]), $MachinePrecision], 5e-40], N[(2.0 / z0), $MachinePrecision], N[(t$95$0 / N[(z0 * z0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(z0 + z0\right) - -2\\
\mathbf{if}\;\frac{t\_0 - \frac{-1.3333333333333333}{z0}}{z0 \cdot z0} \leq 5 \cdot 10^{-40}:\\
\;\;\;\;\frac{2}{z0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{z0 \cdot z0}\\
\end{array}
if (/.f64 (-.f64 (-.f64 (+.f64 z0 z0) #s(literal -2 binary64)) (/.f64 #s(literal -13333333333333333/10000000000000000 binary64) z0)) (*.f64 z0 z0)) < 4.9999999999999996e-40Initial program 76.1%
Taylor expanded in z0 around inf
lower-/.f6452.7%
Applied rewrites52.7%
if 4.9999999999999996e-40 < (/.f64 (-.f64 (-.f64 (+.f64 z0 z0) #s(literal -2 binary64)) (/.f64 #s(literal -13333333333333333/10000000000000000 binary64) z0)) (*.f64 z0 z0)) Initial program 76.1%
Taylor expanded in z0 around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f6463.9%
Applied rewrites63.9%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
add-to-fractionN/A
count-2N/A
lift-+.f64N/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f6440.1%
Applied rewrites40.1%
(FPCore (z0) :precision binary64 (/ (- 2.0 (/ -2.0 z0)) z0))
double code(double z0) {
return (2.0 - (-2.0 / 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 - ((-2.0d0) / z0)) / z0
end function
public static double code(double z0) {
return (2.0 - (-2.0 / z0)) / z0;
}
def code(z0): return (2.0 - (-2.0 / z0)) / z0
function code(z0) return Float64(Float64(2.0 - Float64(-2.0 / z0)) / z0) end
function tmp = code(z0) tmp = (2.0 - (-2.0 / z0)) / z0; end
code[z0_] := N[(N[(2.0 - N[(-2.0 / z0), $MachinePrecision]), $MachinePrecision] / z0), $MachinePrecision]
\frac{2 - \frac{-2}{z0}}{z0}
Initial program 76.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in z0 around 0
Applied rewrites97.9%
Taylor expanded in z0 around inf
lower-/.f6463.9%
Applied rewrites63.9%
(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-/.f6452.7%
Applied rewrites52.7%
herbie shell --seed 2025250
(FPCore (z0)
:name "(/ (- (- (+ z0 z0) -2) (/ -13333333333333333/10000000000000000 z0)) (* z0 z0))"
:precision binary64
(/ (- (- (+ z0 z0) -2.0) (/ -1.3333333333333333 z0)) (* z0 z0)))