
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x + y) - z) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x + y) - z) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x + y) - z) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
Initial program 100.0%
(FPCore (x y z t) :precision binary64 (if (<= (/ (- (+ x y) z) (* t 2.0)) -2e-219) (/ x (+ t t)) (/ y (+ t t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((((x + y) - z) / (t * 2.0)) <= -2e-219) {
tmp = x / (t + t);
} else {
tmp = y / (t + t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((((x + y) - z) / (t * 2.0d0)) <= (-2d-219)) then
tmp = x / (t + t)
else
tmp = y / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((((x + y) - z) / (t * 2.0)) <= -2e-219) {
tmp = x / (t + t);
} else {
tmp = y / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (((x + y) - z) / (t * 2.0)) <= -2e-219: tmp = x / (t + t) else: tmp = y / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) <= -2e-219) tmp = Float64(x / Float64(t + t)); else tmp = Float64(y / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((((x + y) - z) / (t * 2.0)) <= -2e-219) tmp = x / (t + t); else tmp = y / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision], -2e-219], N[(x / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(y / N[(t + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\left(x + y\right) - z}{t \cdot 2} \leq -2 \cdot 10^{-219}:\\
\;\;\;\;\frac{x}{t + t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t + t}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 x y) z) (*.f64 t #s(literal 2 binary64))) < -2.0000000000000001e-219Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites38.2%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6438.2
Applied rewrites38.2%
if -2.0000000000000001e-219 < (/.f64 (-.f64 (+.f64 x y) z) (*.f64 t #s(literal 2 binary64))) Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites45.3%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6445.3
Applied rewrites45.3%
Taylor expanded in y around inf
Applied rewrites39.3%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -5e+20) (/ x (+ t t)) (if (<= (+ x y) 2000.0) (/ (- z) (+ t t)) (/ y (+ t t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e+20) {
tmp = x / (t + t);
} else if ((x + y) <= 2000.0) {
tmp = -z / (t + t);
} else {
tmp = y / (t + t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x + y) <= (-5d+20)) then
tmp = x / (t + t)
else if ((x + y) <= 2000.0d0) then
tmp = -z / (t + t)
else
tmp = y / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e+20) {
tmp = x / (t + t);
} else if ((x + y) <= 2000.0) {
tmp = -z / (t + t);
} else {
tmp = y / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -5e+20: tmp = x / (t + t) elif (x + y) <= 2000.0: tmp = -z / (t + t) else: tmp = y / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -5e+20) tmp = Float64(x / Float64(t + t)); elseif (Float64(x + y) <= 2000.0) tmp = Float64(Float64(-z) / Float64(t + t)); else tmp = Float64(y / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -5e+20) tmp = x / (t + t); elseif ((x + y) <= 2000.0) tmp = -z / (t + t); else tmp = y / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e+20], N[(x / N[(t + t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 2000.0], N[((-z) / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(y / N[(t + t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{+20}:\\
\;\;\;\;\frac{x}{t + t}\\
\mathbf{elif}\;x + y \leq 2000:\\
\;\;\;\;\frac{-z}{t + t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t + t}\\
\end{array}
\end{array}
if (+.f64 x y) < -5e20Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites43.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6443.0
Applied rewrites43.0%
if -5e20 < (+.f64 x y) < 2e3Initial program 100.0%
Taylor expanded in z around inf
Applied rewrites75.8%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6475.8
Applied rewrites75.8%
if 2e3 < (+.f64 x y) Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites52.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6452.7
Applied rewrites52.7%
Taylor expanded in y around inf
Applied rewrites40.3%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -5e+20) (/ x (+ t t)) (if (<= (+ x y) 2000.0) (* (/ -0.5 t) z) (/ y (+ t t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e+20) {
tmp = x / (t + t);
} else if ((x + y) <= 2000.0) {
tmp = (-0.5 / t) * z;
} else {
tmp = y / (t + t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x + y) <= (-5d+20)) then
tmp = x / (t + t)
else if ((x + y) <= 2000.0d0) then
tmp = ((-0.5d0) / t) * z
else
tmp = y / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e+20) {
tmp = x / (t + t);
} else if ((x + y) <= 2000.0) {
tmp = (-0.5 / t) * z;
} else {
tmp = y / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -5e+20: tmp = x / (t + t) elif (x + y) <= 2000.0: tmp = (-0.5 / t) * z else: tmp = y / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -5e+20) tmp = Float64(x / Float64(t + t)); elseif (Float64(x + y) <= 2000.0) tmp = Float64(Float64(-0.5 / t) * z); else tmp = Float64(y / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -5e+20) tmp = x / (t + t); elseif ((x + y) <= 2000.0) tmp = (-0.5 / t) * z; else tmp = y / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e+20], N[(x / N[(t + t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 2000.0], N[(N[(-0.5 / t), $MachinePrecision] * z), $MachinePrecision], N[(y / N[(t + t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{+20}:\\
\;\;\;\;\frac{x}{t + t}\\
\mathbf{elif}\;x + y \leq 2000:\\
\;\;\;\;\frac{-0.5}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t + t}\\
\end{array}
\end{array}
if (+.f64 x y) < -5e20Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites43.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6443.0
Applied rewrites43.0%
if -5e20 < (+.f64 x y) < 2e3Initial program 100.0%
Taylor expanded in z around inf
Applied rewrites75.6%
if 2e3 < (+.f64 x y) Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites52.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6452.7
Applied rewrites52.7%
Taylor expanded in y around inf
Applied rewrites40.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -8.6e+145) (not (<= z 4.5e+100))) (/ (- z) (+ t t)) (/ (+ y x) (+ t t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8.6e+145) || !(z <= 4.5e+100)) {
tmp = -z / (t + t);
} else {
tmp = (y + x) / (t + t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-8.6d+145)) .or. (.not. (z <= 4.5d+100))) then
tmp = -z / (t + t)
else
tmp = (y + x) / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8.6e+145) || !(z <= 4.5e+100)) {
tmp = -z / (t + t);
} else {
tmp = (y + x) / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -8.6e+145) or not (z <= 4.5e+100): tmp = -z / (t + t) else: tmp = (y + x) / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -8.6e+145) || !(z <= 4.5e+100)) tmp = Float64(Float64(-z) / Float64(t + t)); else tmp = Float64(Float64(y + x) / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -8.6e+145) || ~((z <= 4.5e+100))) tmp = -z / (t + t); else tmp = (y + x) / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -8.6e+145], N[Not[LessEqual[z, 4.5e+100]], $MachinePrecision]], N[((-z) / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(N[(y + x), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.6 \cdot 10^{+145} \lor \neg \left(z \leq 4.5 \cdot 10^{+100}\right):\\
\;\;\;\;\frac{-z}{t + t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y + x}{t + t}\\
\end{array}
\end{array}
if z < -8.59999999999999996e145 or 4.50000000000000036e100 < z Initial program 100.0%
Taylor expanded in z around inf
Applied rewrites74.5%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6474.5
Applied rewrites74.5%
if -8.59999999999999996e145 < z < 4.50000000000000036e100Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites53.4%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6453.4
Applied rewrites53.4%
Taylor expanded in z around 0
Applied rewrites86.3%
Final simplification82.6%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -5e-215) (/ (- x z) (+ t t)) (/ (- y z) (+ t t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-215) {
tmp = (x - z) / (t + t);
} else {
tmp = (y - z) / (t + t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x + y) <= (-5d-215)) then
tmp = (x - z) / (t + t)
else
tmp = (y - z) / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-215) {
tmp = (x - z) / (t + t);
} else {
tmp = (y - z) / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -5e-215: tmp = (x - z) / (t + t) else: tmp = (y - z) / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -5e-215) tmp = Float64(Float64(x - z) / Float64(t + t)); else tmp = Float64(Float64(y - z) / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -5e-215) tmp = (x - z) / (t + t); else tmp = (y - z) / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e-215], N[(N[(x - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{-215}:\\
\;\;\;\;\frac{x - z}{t + t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - z}{t + t}\\
\end{array}
\end{array}
if (+.f64 x y) < -4.99999999999999956e-215Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites71.9%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6471.9
Applied rewrites71.9%
if -4.99999999999999956e-215 < (+.f64 x y) Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites74.2%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6474.2
Applied rewrites74.2%
Taylor expanded in x around 0
Applied rewrites61.2%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) 2000.0) (/ (- x z) (+ t t)) (/ (+ y x) (+ t t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= 2000.0) {
tmp = (x - z) / (t + t);
} else {
tmp = (y + x) / (t + t);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x + y) <= 2000.0d0) then
tmp = (x - z) / (t + t)
else
tmp = (y + x) / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= 2000.0) {
tmp = (x - z) / (t + t);
} else {
tmp = (y + x) / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= 2000.0: tmp = (x - z) / (t + t) else: tmp = (y + x) / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= 2000.0) tmp = Float64(Float64(x - z) / Float64(t + t)); else tmp = Float64(Float64(y + x) / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= 2000.0) tmp = (x - z) / (t + t); else tmp = (y + x) / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], 2000.0], N[(N[(x - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(N[(y + x), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq 2000:\\
\;\;\;\;\frac{x - z}{t + t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y + x}{t + t}\\
\end{array}
\end{array}
if (+.f64 x y) < 2e3Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites76.8%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6476.8
Applied rewrites76.8%
if 2e3 < (+.f64 x y) Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites52.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6452.7
Applied rewrites52.7%
Taylor expanded in z around 0
Applied rewrites87.5%
(FPCore (x y z t) :precision binary64 (/ x (+ t t)))
double code(double x, double y, double z, double t) {
return x / (t + t);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / (t + t)
end function
public static double code(double x, double y, double z, double t) {
return x / (t + t);
}
def code(x, y, z, t): return x / (t + t)
function code(x, y, z, t) return Float64(x / Float64(t + t)) end
function tmp = code(x, y, z, t) tmp = x / (t + t); end
code[x_, y_, z_, t_] := N[(x / N[(t + t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{t + t}
\end{array}
Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites41.8%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6441.8
Applied rewrites41.8%
herbie shell --seed 2025018
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
:precision binary64
(/ (- (+ x y) z) (* t 2.0)))