
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (- (- y z) -1) z) x)))
(if (<= z -12000000000000)
t_0
(if (<=
z
8711228593176025/43556142965880123323311949751266331066368)
(/ (* x (+ 1 y)) z)
t_0))))double code(double x, double y, double z) {
double t_0 = (((y - z) - -1.0) / z) * x;
double tmp;
if (z <= -12000000000000.0) {
tmp = t_0;
} else if (z <= 2e-25) {
tmp = (x * (1.0 + y)) / z;
} 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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (((y - z) - (-1.0d0)) / z) * x
if (z <= (-12000000000000.0d0)) then
tmp = t_0
else if (z <= 2d-25) then
tmp = (x * (1.0d0 + y)) / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (((y - z) - -1.0) / z) * x;
double tmp;
if (z <= -12000000000000.0) {
tmp = t_0;
} else if (z <= 2e-25) {
tmp = (x * (1.0 + y)) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (((y - z) - -1.0) / z) * x tmp = 0 if z <= -12000000000000.0: tmp = t_0 elif z <= 2e-25: tmp = (x * (1.0 + y)) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y - z) - -1.0) / z) * x) tmp = 0.0 if (z <= -12000000000000.0) tmp = t_0; elseif (z <= 2e-25) tmp = Float64(Float64(x * Float64(1.0 + y)) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((y - z) - -1.0) / z) * x; tmp = 0.0; if (z <= -12000000000000.0) tmp = t_0; elseif (z <= 2e-25) tmp = (x * (1.0 + y)) / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y - z), $MachinePrecision] - -1), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -12000000000000], t$95$0, If[LessEqual[z, 8711228593176025/43556142965880123323311949751266331066368], N[(N[(x * N[(1 + y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{\left(y - z\right) - -1}{z} \cdot x\\
\mathbf{if}\;z \leq -12000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq \frac{8711228593176025}{43556142965880123323311949751266331066368}:\\
\;\;\;\;\frac{x \cdot \left(1 + y\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -1.2e13 or 2.0000000000000001e-25 < z Initial program 87.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
if -1.2e13 < z < 2.0000000000000001e-25Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
(FPCore (x y z)
:precision binary64
(*
(copysign 1 x)
(if (<=
(fabs x)
8711228593176025/87112285931760246646623899502532662132736)
(/ (* (fabs x) (+ (- y z) 1)) z)
(* (/ (- (- y z) -1) z) (fabs x)))))double code(double x, double y, double z) {
double tmp;
if (fabs(x) <= 1e-25) {
tmp = (fabs(x) * ((y - z) + 1.0)) / z;
} else {
tmp = (((y - z) - -1.0) / z) * fabs(x);
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(x) <= 1e-25) {
tmp = (Math.abs(x) * ((y - z) + 1.0)) / z;
} else {
tmp = (((y - z) - -1.0) / z) * Math.abs(x);
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(x) <= 1e-25: tmp = (math.fabs(x) * ((y - z) + 1.0)) / z else: tmp = (((y - z) - -1.0) / z) * math.fabs(x) return math.copysign(1.0, x) * tmp
function code(x, y, z) tmp = 0.0 if (abs(x) <= 1e-25) tmp = Float64(Float64(abs(x) * Float64(Float64(y - z) + 1.0)) / z); else tmp = Float64(Float64(Float64(Float64(y - z) - -1.0) / z) * abs(x)); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(x) <= 1e-25) tmp = (abs(x) * ((y - z) + 1.0)) / z; else tmp = (((y - z) - -1.0) / z) * abs(x); end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 8711228593176025/87112285931760246646623899502532662132736], N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(y - z), $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(y - z), $MachinePrecision] - -1), $MachinePrecision] / z), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq \frac{8711228593176025}{87112285931760246646623899502532662132736}:\\
\;\;\;\;\frac{\left|x\right| \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y - z\right) - -1}{z} \cdot \left|x\right|\\
\end{array}
if x < 1e-25Initial program 87.5%
if 1e-25 < x Initial program 87.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval96.0%
Applied rewrites96.0%
(FPCore (x y z) :precision binary64 (134-z0z1z2z3z4 (pow z -1) (- y z) x x -1))
\mathsf{134\_z0z1z2z3z4}\left(\left({z}^{-1}\right), \left(y - z\right), x, x, -1\right)
Initial program 87.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-134-z0z1z2z3z4N/A
lower-/.f64N/A
metadata-eval99.7%
Applied rewrites99.7%
lift-/.f64N/A
inv-powN/A
lower-pow.f6499.7%
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (134-z0z1z2z3z4 (/ 1 z) (- y z) x x -1))
\mathsf{134\_z0z1z2z3z4}\left(\left(\frac{1}{z}\right), \left(y - z\right), x, x, -1\right)
Initial program 87.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-134-z0z1z2z3z4N/A
lower-/.f64N/A
metadata-eval99.7%
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (fabs x) z) (- (- y z) -1)))
(t_1 (/ (* (fabs x) (+ (- y z) 1)) z)))
(*
(copysign 1 x)
(if (<=
t_1
-2404907604760405/4809815209520810450717656262224562232065397860164239095208531909697964083434718092213655548692006303809402830848)
t_0
(if (<=
t_1
-4825645764048353/24128228820241763395368498172630942708201009006994023127186460259846489377974909173483894312553062974832901700057603348659254161999916252716423678391067804088773420366831584139402736156236316721587153396424382337160349784305655085875761908966202683012582070411724897569696118189719975296519556940632582457459891765248)
(* (/ (- 1 z) z) (fabs x))
t_0)))))double code(double x, double y, double z) {
double t_0 = (fabs(x) / z) * ((y - z) - -1.0);
double t_1 = (fabs(x) * ((y - z) + 1.0)) / z;
double tmp;
if (t_1 <= -5e-97) {
tmp = t_0;
} else if (t_1 <= -2e-301) {
tmp = ((1.0 - z) / z) * fabs(x);
} else {
tmp = t_0;
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (Math.abs(x) / z) * ((y - z) - -1.0);
double t_1 = (Math.abs(x) * ((y - z) + 1.0)) / z;
double tmp;
if (t_1 <= -5e-97) {
tmp = t_0;
} else if (t_1 <= -2e-301) {
tmp = ((1.0 - z) / z) * Math.abs(x);
} else {
tmp = t_0;
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z): t_0 = (math.fabs(x) / z) * ((y - z) - -1.0) t_1 = (math.fabs(x) * ((y - z) + 1.0)) / z tmp = 0 if t_1 <= -5e-97: tmp = t_0 elif t_1 <= -2e-301: tmp = ((1.0 - z) / z) * math.fabs(x) else: tmp = t_0 return math.copysign(1.0, x) * tmp
function code(x, y, z) t_0 = Float64(Float64(abs(x) / z) * Float64(Float64(y - z) - -1.0)) t_1 = Float64(Float64(abs(x) * Float64(Float64(y - z) + 1.0)) / z) tmp = 0.0 if (t_1 <= -5e-97) tmp = t_0; elseif (t_1 <= -2e-301) tmp = Float64(Float64(Float64(1.0 - z) / z) * abs(x)); else tmp = t_0; end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y, z) t_0 = (abs(x) / z) * ((y - z) - -1.0); t_1 = (abs(x) * ((y - z) + 1.0)) / z; tmp = 0.0; if (t_1 <= -5e-97) tmp = t_0; elseif (t_1 <= -2e-301) tmp = ((1.0 - z) / z) * abs(x); else tmp = t_0; end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] / z), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(y - z), $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -2404907604760405/4809815209520810450717656262224562232065397860164239095208531909697964083434718092213655548692006303809402830848], t$95$0, If[LessEqual[t$95$1, -4825645764048353/24128228820241763395368498172630942708201009006994023127186460259846489377974909173483894312553062974832901700057603348659254161999916252716423678391067804088773420366831584139402736156236316721587153396424382337160349784305655085875761908966202683012582070411724897569696118189719975296519556940632582457459891765248], N[(N[(N[(1 - z), $MachinePrecision] / z), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{\left|x\right|}{z} \cdot \left(\left(y - z\right) - -1\right)\\
t_1 := \frac{\left|x\right| \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq \frac{-2404907604760405}{4809815209520810450717656262224562232065397860164239095208531909697964083434718092213655548692006303809402830848}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq \frac{-4825645764048353}{24128228820241763395368498172630942708201009006994023127186460259846489377974909173483894312553062974832901700057603348659254161999916252716423678391067804088773420366831584139402736156236316721587153396424382337160349784305655085875761908966202683012582070411724897569696118189719975296519556940632582457459891765248}:\\
\;\;\;\;\frac{1 - z}{z} \cdot \left|x\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) #s(literal 1 binary64))) z) < -4.9999999999999995e-97 or -2.0000000000000001e-301 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) #s(literal 1 binary64))) z) Initial program 87.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6488.2%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval88.2%
Applied rewrites88.2%
if -4.9999999999999995e-97 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) #s(literal 1 binary64))) z) < -2.0000000000000001e-301Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites57.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower--.f6466.5%
Applied rewrites66.5%
(FPCore (x y z)
:precision binary64
(if (<= z -3150000000000000000000)
(- x)
(if (<= z 4918143584404189/1329227995784915872903807060280344576)
(/ (* x (+ 1 y)) z)
(* (/ (- 1 z) z) x))))double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e+21) {
tmp = -x;
} else if (z <= 3.7e-21) {
tmp = (x * (1.0 + y)) / z;
} else {
tmp = ((1.0 - z) / z) * x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3.15d+21)) then
tmp = -x
else if (z <= 3.7d-21) then
tmp = (x * (1.0d0 + y)) / z
else
tmp = ((1.0d0 - z) / z) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e+21) {
tmp = -x;
} else if (z <= 3.7e-21) {
tmp = (x * (1.0 + y)) / z;
} else {
tmp = ((1.0 - z) / z) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.15e+21: tmp = -x elif z <= 3.7e-21: tmp = (x * (1.0 + y)) / z else: tmp = ((1.0 - z) / z) * x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.15e+21) tmp = Float64(-x); elseif (z <= 3.7e-21) tmp = Float64(Float64(x * Float64(1.0 + y)) / z); else tmp = Float64(Float64(Float64(1.0 - z) / z) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.15e+21) tmp = -x; elseif (z <= 3.7e-21) tmp = (x * (1.0 + y)) / z; else tmp = ((1.0 - z) / z) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3150000000000000000000], (-x), If[LessEqual[z, 4918143584404189/1329227995784915872903807060280344576], N[(N[(x * N[(1 + y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(1 - z), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -3150000000000000000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq \frac{4918143584404189}{1329227995784915872903807060280344576}:\\
\;\;\;\;\frac{x \cdot \left(1 + y\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - z}{z} \cdot x\\
\end{array}
if z < -3.15e21Initial program 87.5%
Taylor expanded in z around inf
lower-*.f6440.2%
Applied rewrites40.2%
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-neg.f64N/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identity40.2%
Applied rewrites40.2%
if -3.15e21 < z < 3.7000000000000002e-21Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
if 3.7000000000000002e-21 < z Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites57.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower--.f6466.5%
Applied rewrites66.5%
(FPCore (x y z)
:precision binary64
(if (<= z -3150000000000000000000)
(- x)
(if (<= z 4918143584404189/1329227995784915872903807060280344576)
(* (/ x z) (- y -1))
(* (/ (- 1 z) z) x))))double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e+21) {
tmp = -x;
} else if (z <= 3.7e-21) {
tmp = (x / z) * (y - -1.0);
} else {
tmp = ((1.0 - z) / z) * x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3.15d+21)) then
tmp = -x
else if (z <= 3.7d-21) then
tmp = (x / z) * (y - (-1.0d0))
else
tmp = ((1.0d0 - z) / z) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e+21) {
tmp = -x;
} else if (z <= 3.7e-21) {
tmp = (x / z) * (y - -1.0);
} else {
tmp = ((1.0 - z) / z) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.15e+21: tmp = -x elif z <= 3.7e-21: tmp = (x / z) * (y - -1.0) else: tmp = ((1.0 - z) / z) * x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.15e+21) tmp = Float64(-x); elseif (z <= 3.7e-21) tmp = Float64(Float64(x / z) * Float64(y - -1.0)); else tmp = Float64(Float64(Float64(1.0 - z) / z) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.15e+21) tmp = -x; elseif (z <= 3.7e-21) tmp = (x / z) * (y - -1.0); else tmp = ((1.0 - z) / z) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3150000000000000000000], (-x), If[LessEqual[z, 4918143584404189/1329227995784915872903807060280344576], N[(N[(x / z), $MachinePrecision] * N[(y - -1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1 - z), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -3150000000000000000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq \frac{4918143584404189}{1329227995784915872903807060280344576}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y - -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - z}{z} \cdot x\\
\end{array}
if z < -3.15e21Initial program 87.5%
Taylor expanded in z around inf
lower-*.f6440.2%
Applied rewrites40.2%
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-neg.f64N/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identity40.2%
Applied rewrites40.2%
if -3.15e21 < z < 3.7000000000000002e-21Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites57.7%
*-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-rgt-identity59.8%
Applied rewrites59.8%
if 3.7000000000000002e-21 < z Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites57.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower--.f6466.5%
Applied rewrites66.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x y) z)))
(if (<= y -3300000000000000000)
t_0
(if (<=
y
2200000000000000189688286884999471526568915431292882527929869723886775865828164117820624103549535503822869474291922439496983092451729859489061879010552451619328872153088)
(* (/ (- 1 z) z) x)
t_0))))double code(double x, double y, double z) {
double t_0 = (x * y) / z;
double tmp;
if (y <= -3.3e+18) {
tmp = t_0;
} else if (y <= 2.2e+168) {
tmp = ((1.0 - z) / z) * x;
} 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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x * y) / z
if (y <= (-3.3d+18)) then
tmp = t_0
else if (y <= 2.2d+168) then
tmp = ((1.0d0 - z) / z) * x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * y) / z;
double tmp;
if (y <= -3.3e+18) {
tmp = t_0;
} else if (y <= 2.2e+168) {
tmp = ((1.0 - z) / z) * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * y) / z tmp = 0 if y <= -3.3e+18: tmp = t_0 elif y <= 2.2e+168: tmp = ((1.0 - z) / z) * x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * y) / z) tmp = 0.0 if (y <= -3.3e+18) tmp = t_0; elseif (y <= 2.2e+168) tmp = Float64(Float64(Float64(1.0 - z) / z) * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * y) / z; tmp = 0.0; if (y <= -3.3e+18) tmp = t_0; elseif (y <= 2.2e+168) tmp = ((1.0 - z) / z) * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -3300000000000000000], t$95$0, If[LessEqual[y, 2200000000000000189688286884999471526568915431292882527929869723886775865828164117820624103549535503822869474291922439496983092451729859489061879010552451619328872153088], N[(N[(N[(1 - z), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{x \cdot y}{z}\\
\mathbf{if}\;y \leq -3300000000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2200000000000000189688286884999471526568915431292882527929869723886775865828164117820624103549535503822869474291922439496983092451729859489061879010552451619328872153088:\\
\;\;\;\;\frac{1 - z}{z} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -3.3e18 or 2.2000000000000002e168 < y Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
Taylor expanded in y around inf
lower-*.f6437.5%
Applied rewrites37.5%
if -3.3e18 < y < 2.2000000000000002e168Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites57.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower--.f6466.5%
Applied rewrites66.5%
(FPCore (x y z)
:precision binary64
(if (<= z -3150000000000000000000)
(- x)
(if (<=
z
3399725348521233/790633801981682102939434948120770730662330663141180149831645929794649763937481823796720248833738767559324522907487546528866440380413255769011771093518509804380927438580337349079948858367551626332967842494034160424070341732127705853976966233004529516956289283251401443563802400840744150516352841830648461966045733363646464)
(/ (* x y) z)
(if (<= z 3486039150627631/79228162514264337593543950336)
(/ (* x 1) z)
(- x)))))double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e+21) {
tmp = -x;
} else if (z <= 4.3e-306) {
tmp = (x * y) / z;
} else if (z <= 4.4e-14) {
tmp = (x * 1.0) / z;
} else {
tmp = -x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3.15d+21)) then
tmp = -x
else if (z <= 4.3d-306) then
tmp = (x * y) / z
else if (z <= 4.4d-14) then
tmp = (x * 1.0d0) / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e+21) {
tmp = -x;
} else if (z <= 4.3e-306) {
tmp = (x * y) / z;
} else if (z <= 4.4e-14) {
tmp = (x * 1.0) / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.15e+21: tmp = -x elif z <= 4.3e-306: tmp = (x * y) / z elif z <= 4.4e-14: tmp = (x * 1.0) / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.15e+21) tmp = Float64(-x); elseif (z <= 4.3e-306) tmp = Float64(Float64(x * y) / z); elseif (z <= 4.4e-14) tmp = Float64(Float64(x * 1.0) / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.15e+21) tmp = -x; elseif (z <= 4.3e-306) tmp = (x * y) / z; elseif (z <= 4.4e-14) tmp = (x * 1.0) / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3150000000000000000000], (-x), If[LessEqual[z, 3399725348521233/790633801981682102939434948120770730662330663141180149831645929794649763937481823796720248833738767559324522907487546528866440380413255769011771093518509804380927438580337349079948858367551626332967842494034160424070341732127705853976966233004529516956289283251401443563802400840744150516352841830648461966045733363646464], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 3486039150627631/79228162514264337593543950336], N[(N[(x * 1), $MachinePrecision] / z), $MachinePrecision], (-x)]]]
\begin{array}{l}
\mathbf{if}\;z \leq -3150000000000000000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq \frac{3399725348521233}{790633801981682102939434948120770730662330663141180149831645929794649763937481823796720248833738767559324522907487546528866440380413255769011771093518509804380927438580337349079948858367551626332967842494034160424070341732127705853976966233004529516956289283251401443563802400840744150516352841830648461966045733363646464}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;z \leq \frac{3486039150627631}{79228162514264337593543950336}:\\
\;\;\;\;\frac{x \cdot 1}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
if z < -3.15e21 or 4.4000000000000002e-14 < z Initial program 87.5%
Taylor expanded in z around inf
lower-*.f6440.2%
Applied rewrites40.2%
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-neg.f64N/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identity40.2%
Applied rewrites40.2%
if -3.15e21 < z < 4.2999999999999999e-306Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
Taylor expanded in y around inf
lower-*.f6437.5%
Applied rewrites37.5%
if 4.2999999999999999e-306 < z < 4.4000000000000002e-14Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
Taylor expanded in y around 0
Applied rewrites29.1%
(FPCore (x y z)
:precision binary64
(if (<= z -3150000000000000000000)
(- x)
(if (<= z 3486039150627631/79228162514264337593543950336)
(/ (* x y) z)
(- x))))double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e+21) {
tmp = -x;
} else if (z <= 4.4e-14) {
tmp = (x * y) / z;
} else {
tmp = -x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3.15d+21)) then
tmp = -x
else if (z <= 4.4d-14) then
tmp = (x * y) / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.15e+21) {
tmp = -x;
} else if (z <= 4.4e-14) {
tmp = (x * y) / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.15e+21: tmp = -x elif z <= 4.4e-14: tmp = (x * y) / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.15e+21) tmp = Float64(-x); elseif (z <= 4.4e-14) tmp = Float64(Float64(x * y) / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.15e+21) tmp = -x; elseif (z <= 4.4e-14) tmp = (x * y) / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3150000000000000000000], (-x), If[LessEqual[z, 3486039150627631/79228162514264337593543950336], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\mathbf{if}\;z \leq -3150000000000000000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq \frac{3486039150627631}{79228162514264337593543950336}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
if z < -3.15e21 or 4.4000000000000002e-14 < z Initial program 87.5%
Taylor expanded in z around inf
lower-*.f6440.2%
Applied rewrites40.2%
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-neg.f64N/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identity40.2%
Applied rewrites40.2%
if -3.15e21 < z < 4.4000000000000002e-14Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
Taylor expanded in y around inf
lower-*.f6437.5%
Applied rewrites37.5%
(FPCore (x y z)
:precision binary64
(*
(copysign 1 x)
(if (<=
(/ (* (fabs x) (+ (- y z) 1)) z)
-4825645764048353/24128228820241763395368498172630942708201009006994023127186460259846489377974909173483894312553062974832901700057603348659254161999916252716423678391067804088773420366831584139402736156236316721587153396424382337160349784305655085875761908966202683012582070411724897569696118189719975296519556940632582457459891765248)
(- (fabs x))
(* (/ y z) (fabs x)))))double code(double x, double y, double z) {
double tmp;
if (((fabs(x) * ((y - z) + 1.0)) / z) <= -2e-301) {
tmp = -fabs(x);
} else {
tmp = (y / z) * fabs(x);
}
return copysign(1.0, x) * tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (((Math.abs(x) * ((y - z) + 1.0)) / z) <= -2e-301) {
tmp = -Math.abs(x);
} else {
tmp = (y / z) * Math.abs(x);
}
return Math.copySign(1.0, x) * tmp;
}
def code(x, y, z): tmp = 0 if ((math.fabs(x) * ((y - z) + 1.0)) / z) <= -2e-301: tmp = -math.fabs(x) else: tmp = (y / z) * math.fabs(x) return math.copysign(1.0, x) * tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(abs(x) * Float64(Float64(y - z) + 1.0)) / z) <= -2e-301) tmp = Float64(-abs(x)); else tmp = Float64(Float64(y / z) * abs(x)); end return Float64(copysign(1.0, x) * tmp) end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((abs(x) * ((y - z) + 1.0)) / z) <= -2e-301) tmp = -abs(x); else tmp = (y / z) * abs(x); end tmp_2 = (sign(x) * abs(1.0)) * tmp; end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(N[Abs[x], $MachinePrecision] * N[(N[(y - z), $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], -4825645764048353/24128228820241763395368498172630942708201009006994023127186460259846489377974909173483894312553062974832901700057603348659254161999916252716423678391067804088773420366831584139402736156236316721587153396424382337160349784305655085875761908966202683012582070411724897569696118189719975296519556940632582457459891765248], (-N[Abs[x], $MachinePrecision]), N[(N[(y / z), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left|x\right| \cdot \left(\left(y - z\right) + 1\right)}{z} \leq \frac{-4825645764048353}{24128228820241763395368498172630942708201009006994023127186460259846489377974909173483894312553062974832901700057603348659254161999916252716423678391067804088773420366831584139402736156236316721587153396424382337160349784305655085875761908966202683012582070411724897569696118189719975296519556940632582457459891765248}:\\
\;\;\;\;-\left|x\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot \left|x\right|\\
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) #s(literal 1 binary64))) z) < -2.0000000000000001e-301Initial program 87.5%
Taylor expanded in z around inf
lower-*.f6440.2%
Applied rewrites40.2%
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-neg.f64N/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identity40.2%
Applied rewrites40.2%
if -2.0000000000000001e-301 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) #s(literal 1 binary64))) z) Initial program 87.5%
Taylor expanded in z around 0
lower-+.f6459.6%
Applied rewrites59.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites57.7%
Taylor expanded in y around inf
lower-/.f6435.7%
Applied rewrites35.7%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
-x
Initial program 87.5%
Taylor expanded in z around inf
lower-*.f6440.2%
Applied rewrites40.2%
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-neg.f64N/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identity40.2%
Applied rewrites40.2%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
(/ (* x (+ (- y z) 1)) z))