
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2)))
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), $MachinePrecision]), $MachinePrecision]
\frac{\left(x + y\right) - z}{t \cdot 2}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2)))
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), $MachinePrecision]), $MachinePrecision]
\frac{\left(x + y\right) - z}{t \cdot 2}
(FPCore (x y z t) :precision binary64 (* (/ 1/2 t) (- (+ y x) z)))
double code(double x, double y, double z, double t) {
return (0.5 / t) * ((y + x) - z);
}
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 = (0.5d0 / t) * ((y + x) - z)
end function
public static double code(double x, double y, double z, double t) {
return (0.5 / t) * ((y + x) - z);
}
def code(x, y, z, t): return (0.5 / t) * ((y + x) - z)
function code(x, y, z, t) return Float64(Float64(0.5 / t) * Float64(Float64(y + x) - z)) end
function tmp = code(x, y, z, t) tmp = (0.5 / t) * ((y + x) - z); end
code[x_, y_, z_, t_] := N[(N[(1/2 / t), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\frac{\frac{1}{2}}{t} \cdot \left(\left(y + x\right) - z\right)
Initial program 99.9%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval99.7%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7%
Applied rewrites99.7%
(FPCore (x y z t)
:precision binary64
(if (<=
(+ (fmin x y) (fmax x y))
-4763410263543689/23817051317718446589520242536874132581700120107002038199303870846751188192899823151552628349788604516295066307994130118526061826166445047808)
(/ (- (fmin x y) z) (+ t t))
(/ (- (fmax x y) z) (+ t t))))double code(double x, double y, double z, double t) {
double tmp;
if ((fmin(x, y) + fmax(x, y)) <= -2e-124) {
tmp = (fmin(x, y) - z) / (t + t);
} else {
tmp = (fmax(x, 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 ((fmin(x, y) + fmax(x, y)) <= (-2d-124)) then
tmp = (fmin(x, y) - z) / (t + t)
else
tmp = (fmax(x, 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 ((fmin(x, y) + fmax(x, y)) <= -2e-124) {
tmp = (fmin(x, y) - z) / (t + t);
} else {
tmp = (fmax(x, y) - z) / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (fmin(x, y) + fmax(x, y)) <= -2e-124: tmp = (fmin(x, y) - z) / (t + t) else: tmp = (fmax(x, y) - z) / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(fmin(x, y) + fmax(x, y)) <= -2e-124) tmp = Float64(Float64(fmin(x, y) - z) / Float64(t + t)); else tmp = Float64(Float64(fmax(x, y) - z) / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((min(x, y) + max(x, y)) <= -2e-124) tmp = (min(x, y) - z) / (t + t); else tmp = (max(x, y) - z) / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[Min[x, y], $MachinePrecision] + N[Max[x, y], $MachinePrecision]), $MachinePrecision], -4763410263543689/23817051317718446589520242536874132581700120107002038199303870846751188192899823151552628349788604516295066307994130118526061826166445047808], N[(N[(N[Min[x, y], $MachinePrecision] - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Max[x, y], $MachinePrecision] - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(x, y\right) + \mathsf{max}\left(x, y\right) \leq \frac{-4763410263543689}{23817051317718446589520242536874132581700120107002038199303870846751188192899823151552628349788604516295066307994130118526061826166445047808}:\\
\;\;\;\;\frac{\mathsf{min}\left(x, y\right) - z}{t + t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right) - z}{t + t}\\
\end{array}
if (+.f64 x y) < -1.9999999999999999e-124Initial program 99.9%
Taylor expanded in y around 0
lower--.f6469.2%
Applied rewrites69.2%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6469.2%
Applied rewrites69.2%
if -1.9999999999999999e-124 < (+.f64 x y) Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites68.9%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6468.9%
Applied rewrites68.9%
(FPCore (x y z t)
:precision binary64
(if (<=
(+ (fmin x y) (fmax x y))
35681192317649/713623846352979940529142984724747568191373312)
(/ (- (fmin x y) z) (+ t t))
(/ (+ (fmax x y) (fmin x y)) (+ t t))))double code(double x, double y, double z, double t) {
double tmp;
if ((fmin(x, y) + fmax(x, y)) <= 5e-32) {
tmp = (fmin(x, y) - z) / (t + t);
} else {
tmp = (fmax(x, y) + fmin(x, 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 ((fmin(x, y) + fmax(x, y)) <= 5d-32) then
tmp = (fmin(x, y) - z) / (t + t)
else
tmp = (fmax(x, y) + fmin(x, y)) / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((fmin(x, y) + fmax(x, y)) <= 5e-32) {
tmp = (fmin(x, y) - z) / (t + t);
} else {
tmp = (fmax(x, y) + fmin(x, y)) / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (fmin(x, y) + fmax(x, y)) <= 5e-32: tmp = (fmin(x, y) - z) / (t + t) else: tmp = (fmax(x, y) + fmin(x, y)) / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(fmin(x, y) + fmax(x, y)) <= 5e-32) tmp = Float64(Float64(fmin(x, y) - z) / Float64(t + t)); else tmp = Float64(Float64(fmax(x, y) + fmin(x, y)) / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((min(x, y) + max(x, y)) <= 5e-32) tmp = (min(x, y) - z) / (t + t); else tmp = (max(x, y) + min(x, y)) / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[Min[x, y], $MachinePrecision] + N[Max[x, y], $MachinePrecision]), $MachinePrecision], 35681192317649/713623846352979940529142984724747568191373312], N[(N[(N[Min[x, y], $MachinePrecision] - z), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Max[x, y], $MachinePrecision] + N[Min[x, y], $MachinePrecision]), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(x, y\right) + \mathsf{max}\left(x, y\right) \leq \frac{35681192317649}{713623846352979940529142984724747568191373312}:\\
\;\;\;\;\frac{\mathsf{min}\left(x, y\right) - z}{t + t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right) + \mathsf{min}\left(x, y\right)}{t + t}\\
\end{array}
if (+.f64 x y) < 5.0000000000000004e-32Initial program 99.9%
Taylor expanded in y around 0
lower--.f6469.2%
Applied rewrites69.2%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6469.2%
Applied rewrites69.2%
if 5.0000000000000004e-32 < (+.f64 x y) Initial program 99.9%
Taylor expanded in z around 0
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6469.2%
Applied rewrites69.2%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6469.2%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6469.2%
Applied rewrites69.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* -1/2 (/ z t))))
(if (<=
z
-400000000000000013767621723724981123670855081189670989882774590700260391850525790215569063258979309273988716340589691660311326884836077678573431838001201286298701018431488)
t_1
(if (<=
z
35000000000000000067048628000713405767558429454281720390348123010978276347139606458643265078786311323648)
(/ (+ y x) (+ t t))
t_1))))double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (z / t);
double tmp;
if (z <= -4e+170) {
tmp = t_1;
} else if (z <= 3.5e+103) {
tmp = (y + x) / (t + t);
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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) :: t_1
real(8) :: tmp
t_1 = (-0.5d0) * (z / t)
if (z <= (-4d+170)) then
tmp = t_1
else if (z <= 3.5d+103) then
tmp = (y + x) / (t + t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (z / t);
double tmp;
if (z <= -4e+170) {
tmp = t_1;
} else if (z <= 3.5e+103) {
tmp = (y + x) / (t + t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -0.5 * (z / t) tmp = 0 if z <= -4e+170: tmp = t_1 elif z <= 3.5e+103: tmp = (y + x) / (t + t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(-0.5 * Float64(z / t)) tmp = 0.0 if (z <= -4e+170) tmp = t_1; elseif (z <= 3.5e+103) tmp = Float64(Float64(y + x) / Float64(t + t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -0.5 * (z / t); tmp = 0.0; if (z <= -4e+170) tmp = t_1; elseif (z <= 3.5e+103) tmp = (y + x) / (t + t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-1/2 * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -400000000000000013767621723724981123670855081189670989882774590700260391850525790215569063258979309273988716340589691660311326884836077678573431838001201286298701018431488], t$95$1, If[LessEqual[z, 35000000000000000067048628000713405767558429454281720390348123010978276347139606458643265078786311323648], N[(N[(y + x), $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \frac{-1}{2} \cdot \frac{z}{t}\\
\mathbf{if}\;z \leq -400000000000000013767621723724981123670855081189670989882774590700260391850525790215569063258979309273988716340589691660311326884836077678573431838001201286298701018431488:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 35000000000000000067048628000713405767558429454281720390348123010978276347139606458643265078786311323648:\\
\;\;\;\;\frac{y + x}{t + t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -4.0000000000000001e170 or 3.5e103 < z Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f6437.6%
Applied rewrites37.6%
if -4.0000000000000001e170 < z < 3.5e103Initial program 99.9%
Taylor expanded in z around 0
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6469.2%
Applied rewrites69.2%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6469.2%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6469.2%
Applied rewrites69.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (fmin x y) (fmax x y))))
(if (<=
t_1
-5265614583427859/26328072917139296674479506920917608079723773850137277813577744384)
(/ (fmin x y) (+ t t))
(if (<=
t_1
35681192317649/713623846352979940529142984724747568191373312)
(* -1/2 (/ z t))
(/ (fmax x y) (+ t t))))))double code(double x, double y, double z, double t) {
double t_1 = fmin(x, y) + fmax(x, y);
double tmp;
if (t_1 <= -2e-49) {
tmp = fmin(x, y) / (t + t);
} else if (t_1 <= 5e-32) {
tmp = -0.5 * (z / t);
} else {
tmp = fmax(x, 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) :: t_1
real(8) :: tmp
t_1 = fmin(x, y) + fmax(x, y)
if (t_1 <= (-2d-49)) then
tmp = fmin(x, y) / (t + t)
else if (t_1 <= 5d-32) then
tmp = (-0.5d0) * (z / t)
else
tmp = fmax(x, y) / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = fmin(x, y) + fmax(x, y);
double tmp;
if (t_1 <= -2e-49) {
tmp = fmin(x, y) / (t + t);
} else if (t_1 <= 5e-32) {
tmp = -0.5 * (z / t);
} else {
tmp = fmax(x, y) / (t + t);
}
return tmp;
}
def code(x, y, z, t): t_1 = fmin(x, y) + fmax(x, y) tmp = 0 if t_1 <= -2e-49: tmp = fmin(x, y) / (t + t) elif t_1 <= 5e-32: tmp = -0.5 * (z / t) else: tmp = fmax(x, y) / (t + t) return tmp
function code(x, y, z, t) t_1 = Float64(fmin(x, y) + fmax(x, y)) tmp = 0.0 if (t_1 <= -2e-49) tmp = Float64(fmin(x, y) / Float64(t + t)); elseif (t_1 <= 5e-32) tmp = Float64(-0.5 * Float64(z / t)); else tmp = Float64(fmax(x, y) / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = min(x, y) + max(x, y); tmp = 0.0; if (t_1 <= -2e-49) tmp = min(x, y) / (t + t); elseif (t_1 <= 5e-32) tmp = -0.5 * (z / t); else tmp = max(x, y) / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Min[x, y], $MachinePrecision] + N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5265614583427859/26328072917139296674479506920917608079723773850137277813577744384], N[(N[Min[x, y], $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 35681192317649/713623846352979940529142984724747568191373312], N[(-1/2 * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[Max[x, y], $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(x, y\right) + \mathsf{max}\left(x, y\right)\\
\mathbf{if}\;t\_1 \leq \frac{-5265614583427859}{26328072917139296674479506920917608079723773850137277813577744384}:\\
\;\;\;\;\frac{\mathsf{min}\left(x, y\right)}{t + t}\\
\mathbf{elif}\;t\_1 \leq \frac{35681192317649}{713623846352979940529142984724747568191373312}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{t + t}\\
\end{array}
if (+.f64 x y) < -1.9999999999999999e-49Initial program 99.9%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f6438.0%
Applied rewrites38.0%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f6438.0%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6438.0%
Applied rewrites38.0%
if -1.9999999999999999e-49 < (+.f64 x y) < 5.0000000000000004e-32Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f6437.6%
Applied rewrites37.6%
if 5.0000000000000004e-32 < (+.f64 x y) Initial program 99.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower-/.f6437.5%
Applied rewrites37.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
metadata-evalN/A
frac-timesN/A
*-commutativeN/A
metadata-evalN/A
count-2N/A
lift-+.f64N/A
mult-flipN/A
lower-/.f6437.5%
Applied rewrites37.5%
(FPCore (x y z t)
:precision binary64
(if (<=
(- (+ (fmin x y) (fmax x y)) z)
-4763410263543689/23817051317718446589520242536874132581700120107002038199303870846751188192899823151552628349788604516295066307994130118526061826166445047808)
(/ (fmin x y) (+ t t))
(/ (fmax x y) (+ t t))))double code(double x, double y, double z, double t) {
double tmp;
if (((fmin(x, y) + fmax(x, y)) - z) <= -2e-124) {
tmp = fmin(x, y) / (t + t);
} else {
tmp = fmax(x, 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 (((fmin(x, y) + fmax(x, y)) - z) <= (-2d-124)) then
tmp = fmin(x, y) / (t + t)
else
tmp = fmax(x, y) / (t + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((fmin(x, y) + fmax(x, y)) - z) <= -2e-124) {
tmp = fmin(x, y) / (t + t);
} else {
tmp = fmax(x, y) / (t + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((fmin(x, y) + fmax(x, y)) - z) <= -2e-124: tmp = fmin(x, y) / (t + t) else: tmp = fmax(x, y) / (t + t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(fmin(x, y) + fmax(x, y)) - z) <= -2e-124) tmp = Float64(fmin(x, y) / Float64(t + t)); else tmp = Float64(fmax(x, y) / Float64(t + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((min(x, y) + max(x, y)) - z) <= -2e-124) tmp = min(x, y) / (t + t); else tmp = max(x, y) / (t + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(N[Min[x, y], $MachinePrecision] + N[Max[x, y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], -4763410263543689/23817051317718446589520242536874132581700120107002038199303870846751188192899823151552628349788604516295066307994130118526061826166445047808], N[(N[Min[x, y], $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision], N[(N[Max[x, y], $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left(\mathsf{min}\left(x, y\right) + \mathsf{max}\left(x, y\right)\right) - z \leq \frac{-4763410263543689}{23817051317718446589520242536874132581700120107002038199303870846751188192899823151552628349788604516295066307994130118526061826166445047808}:\\
\;\;\;\;\frac{\mathsf{min}\left(x, y\right)}{t + t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{max}\left(x, y\right)}{t + t}\\
\end{array}
if (-.f64 (+.f64 x y) z) < -1.9999999999999999e-124Initial program 99.9%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f6438.0%
Applied rewrites38.0%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f6438.0%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6438.0%
Applied rewrites38.0%
if -1.9999999999999999e-124 < (-.f64 (+.f64 x y) z) Initial program 99.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower-/.f6437.5%
Applied rewrites37.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
metadata-evalN/A
frac-timesN/A
*-commutativeN/A
metadata-evalN/A
count-2N/A
lift-+.f64N/A
mult-flipN/A
lower-/.f6437.5%
Applied rewrites37.5%
(FPCore (x y z t) :precision binary64 (/ (fmin x y) (+ t t)))
double code(double x, double y, double z, double t) {
return fmin(x, y) / (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 = fmin(x, y) / (t + t)
end function
public static double code(double x, double y, double z, double t) {
return fmin(x, y) / (t + t);
}
def code(x, y, z, t): return fmin(x, y) / (t + t)
function code(x, y, z, t) return Float64(fmin(x, y) / Float64(t + t)) end
function tmp = code(x, y, z, t) tmp = min(x, y) / (t + t); end
code[x_, y_, z_, t_] := N[(N[Min[x, y], $MachinePrecision] / N[(t + t), $MachinePrecision]), $MachinePrecision]
\frac{\mathsf{min}\left(x, y\right)}{t + t}
Initial program 99.9%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f6438.0%
Applied rewrites38.0%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f6438.0%
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f6438.0%
Applied rewrites38.0%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
:precision binary64
(/ (- (+ x y) z) (* t 2)))