
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * 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 * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * 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 * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (t_s y_s x y_m z t_m)
:precision binary64
(let* ((t_2 (* (* (- x z) y_m) t_m)) (t_3 (* (- (* x y_m) (* z y_m)) t_m)))
(*
t_s
(*
y_s
(if (<= t_3 -2e+28) t_2 (if (<= t_3 0.0) (* (* (- x z) t_m) y_m) t_2))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
assert(x < y_m && y_m < z && z < t_m);
double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double t_2 = ((x - z) * y_m) * t_m;
double t_3 = ((x * y_m) - (z * y_m)) * t_m;
double tmp;
if (t_3 <= -2e+28) {
tmp = t_2;
} else if (t_3 <= 0.0) {
tmp = ((x - z) * t_m) * y_m;
} else {
tmp = t_2;
}
return t_s * (y_s * tmp);
}
y\_m = private
y\_s = private
t\_m = private
t\_s = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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(t_s, y_s, x, y_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_2 = ((x - z) * y_m) * t_m
t_3 = ((x * y_m) - (z * y_m)) * t_m
if (t_3 <= (-2d+28)) then
tmp = t_2
else if (t_3 <= 0.0d0) then
tmp = ((x - z) * t_m) * y_m
else
tmp = t_2
end if
code = t_s * (y_s * tmp)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double t_2 = ((x - z) * y_m) * t_m;
double t_3 = ((x * y_m) - (z * y_m)) * t_m;
double tmp;
if (t_3 <= -2e+28) {
tmp = t_2;
} else if (t_3 <= 0.0) {
tmp = ((x - z) * t_m) * y_m;
} else {
tmp = t_2;
}
return t_s * (y_s * tmp);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(t_s, y_s, x, y_m, z, t_m): t_2 = ((x - z) * y_m) * t_m t_3 = ((x * y_m) - (z * y_m)) * t_m tmp = 0 if t_3 <= -2e+28: tmp = t_2 elif t_3 <= 0.0: tmp = ((x - z) * t_m) * y_m else: tmp = t_2 return t_s * (y_s * tmp)
y\_m = abs(y) y\_s = copysign(1.0, y) t\_m = abs(t) t\_s = copysign(1.0, t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(t_s, y_s, x, y_m, z, t_m) t_2 = Float64(Float64(Float64(x - z) * y_m) * t_m) t_3 = Float64(Float64(Float64(x * y_m) - Float64(z * y_m)) * t_m) tmp = 0.0 if (t_3 <= -2e+28) tmp = t_2; elseif (t_3 <= 0.0) tmp = Float64(Float64(Float64(x - z) * t_m) * y_m); else tmp = t_2; end return Float64(t_s * Float64(y_s * tmp)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(t_s, y_s, x, y_m, z, t_m)
t_2 = ((x - z) * y_m) * t_m;
t_3 = ((x * y_m) - (z * y_m)) * t_m;
tmp = 0.0;
if (t_3 <= -2e+28)
tmp = t_2;
elseif (t_3 <= 0.0)
tmp = ((x - z) * t_m) * y_m;
else
tmp = t_2;
end
tmp_2 = t_s * (y_s * tmp);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[t$95$s_, y$95$s_, x_, y$95$m_, z_, t$95$m_] := Block[{t$95$2 = N[(N[(N[(x - z), $MachinePrecision] * y$95$m), $MachinePrecision] * t$95$m), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(x * y$95$m), $MachinePrecision] - N[(z * y$95$m), $MachinePrecision]), $MachinePrecision] * t$95$m), $MachinePrecision]}, N[(t$95$s * N[(y$95$s * If[LessEqual[t$95$3, -2e+28], t$95$2, If[LessEqual[t$95$3, 0.0], N[(N[(N[(x - z), $MachinePrecision] * t$95$m), $MachinePrecision] * y$95$m), $MachinePrecision], t$95$2]]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
\begin{array}{l}
t_2 := \left(\left(x - z\right) \cdot y\_m\right) \cdot t\_m\\
t_3 := \left(x \cdot y\_m - z \cdot y\_m\right) \cdot t\_m\\
t\_s \cdot \left(y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -2 \cdot 10^{+28}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 0:\\
\;\;\;\;\left(\left(x - z\right) \cdot t\_m\right) \cdot y\_m\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\right)
\end{array}
\end{array}
if (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) < -1.99999999999999992e28 or -0.0 < (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) Initial program 98.9%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.6
Applied rewrites99.6%
if -1.99999999999999992e28 < (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) < -0.0Initial program 90.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.4
Applied rewrites99.4%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (t_s y_s x y_m z t_m)
:precision binary64
(let* ((t_2 (* (* y_m x) t_m)))
(*
t_s
(*
y_s
(if (<= x -8.7e+223)
t_2
(if (<= x 5.8e+149) (* (* (- x z) t_m) y_m) t_2))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
assert(x < y_m && y_m < z && z < t_m);
double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double t_2 = (y_m * x) * t_m;
double tmp;
if (x <= -8.7e+223) {
tmp = t_2;
} else if (x <= 5.8e+149) {
tmp = ((x - z) * t_m) * y_m;
} else {
tmp = t_2;
}
return t_s * (y_s * tmp);
}
y\_m = private
y\_s = private
t\_m = private
t\_s = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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(t_s, y_s, x, y_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
real(8) :: t_2
real(8) :: tmp
t_2 = (y_m * x) * t_m
if (x <= (-8.7d+223)) then
tmp = t_2
else if (x <= 5.8d+149) then
tmp = ((x - z) * t_m) * y_m
else
tmp = t_2
end if
code = t_s * (y_s * tmp)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double t_2 = (y_m * x) * t_m;
double tmp;
if (x <= -8.7e+223) {
tmp = t_2;
} else if (x <= 5.8e+149) {
tmp = ((x - z) * t_m) * y_m;
} else {
tmp = t_2;
}
return t_s * (y_s * tmp);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(t_s, y_s, x, y_m, z, t_m): t_2 = (y_m * x) * t_m tmp = 0 if x <= -8.7e+223: tmp = t_2 elif x <= 5.8e+149: tmp = ((x - z) * t_m) * y_m else: tmp = t_2 return t_s * (y_s * tmp)
y\_m = abs(y) y\_s = copysign(1.0, y) t\_m = abs(t) t\_s = copysign(1.0, t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(t_s, y_s, x, y_m, z, t_m) t_2 = Float64(Float64(y_m * x) * t_m) tmp = 0.0 if (x <= -8.7e+223) tmp = t_2; elseif (x <= 5.8e+149) tmp = Float64(Float64(Float64(x - z) * t_m) * y_m); else tmp = t_2; end return Float64(t_s * Float64(y_s * tmp)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(t_s, y_s, x, y_m, z, t_m)
t_2 = (y_m * x) * t_m;
tmp = 0.0;
if (x <= -8.7e+223)
tmp = t_2;
elseif (x <= 5.8e+149)
tmp = ((x - z) * t_m) * y_m;
else
tmp = t_2;
end
tmp_2 = t_s * (y_s * tmp);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[t$95$s_, y$95$s_, x_, y$95$m_, z_, t$95$m_] := Block[{t$95$2 = N[(N[(y$95$m * x), $MachinePrecision] * t$95$m), $MachinePrecision]}, N[(t$95$s * N[(y$95$s * If[LessEqual[x, -8.7e+223], t$95$2, If[LessEqual[x, 5.8e+149], N[(N[(N[(x - z), $MachinePrecision] * t$95$m), $MachinePrecision] * y$95$m), $MachinePrecision], t$95$2]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
\begin{array}{l}
t_2 := \left(y\_m \cdot x\right) \cdot t\_m\\
t\_s \cdot \left(y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -8.7 \cdot 10^{+223}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+149}:\\
\;\;\;\;\left(\left(x - z\right) \cdot t\_m\right) \cdot y\_m\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\right)
\end{array}
\end{array}
if x < -8.7000000000000001e223 or 5.8000000000000004e149 < x Initial program 98.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6490.6
Applied rewrites90.6%
if -8.7000000000000001e223 < x < 5.8000000000000004e149Initial program 96.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.7
Applied rewrites88.7%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (t_s y_s x y_m z t_m)
:precision binary64
(let* ((t_2 (* (* y_m x) t_m)))
(*
t_s
(*
y_s
(if (<= x -2.25e+24)
t_2
(if (<= x 4.2e-10) (* (* (- z) y_m) t_m) t_2))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
assert(x < y_m && y_m < z && z < t_m);
double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double t_2 = (y_m * x) * t_m;
double tmp;
if (x <= -2.25e+24) {
tmp = t_2;
} else if (x <= 4.2e-10) {
tmp = (-z * y_m) * t_m;
} else {
tmp = t_2;
}
return t_s * (y_s * tmp);
}
y\_m = private
y\_s = private
t\_m = private
t\_s = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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(t_s, y_s, x, y_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
real(8) :: t_2
real(8) :: tmp
t_2 = (y_m * x) * t_m
if (x <= (-2.25d+24)) then
tmp = t_2
else if (x <= 4.2d-10) then
tmp = (-z * y_m) * t_m
else
tmp = t_2
end if
code = t_s * (y_s * tmp)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double t_2 = (y_m * x) * t_m;
double tmp;
if (x <= -2.25e+24) {
tmp = t_2;
} else if (x <= 4.2e-10) {
tmp = (-z * y_m) * t_m;
} else {
tmp = t_2;
}
return t_s * (y_s * tmp);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(t_s, y_s, x, y_m, z, t_m): t_2 = (y_m * x) * t_m tmp = 0 if x <= -2.25e+24: tmp = t_2 elif x <= 4.2e-10: tmp = (-z * y_m) * t_m else: tmp = t_2 return t_s * (y_s * tmp)
y\_m = abs(y) y\_s = copysign(1.0, y) t\_m = abs(t) t\_s = copysign(1.0, t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(t_s, y_s, x, y_m, z, t_m) t_2 = Float64(Float64(y_m * x) * t_m) tmp = 0.0 if (x <= -2.25e+24) tmp = t_2; elseif (x <= 4.2e-10) tmp = Float64(Float64(Float64(-z) * y_m) * t_m); else tmp = t_2; end return Float64(t_s * Float64(y_s * tmp)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(t_s, y_s, x, y_m, z, t_m)
t_2 = (y_m * x) * t_m;
tmp = 0.0;
if (x <= -2.25e+24)
tmp = t_2;
elseif (x <= 4.2e-10)
tmp = (-z * y_m) * t_m;
else
tmp = t_2;
end
tmp_2 = t_s * (y_s * tmp);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[t$95$s_, y$95$s_, x_, y$95$m_, z_, t$95$m_] := Block[{t$95$2 = N[(N[(y$95$m * x), $MachinePrecision] * t$95$m), $MachinePrecision]}, N[(t$95$s * N[(y$95$s * If[LessEqual[x, -2.25e+24], t$95$2, If[LessEqual[x, 4.2e-10], N[(N[((-z) * y$95$m), $MachinePrecision] * t$95$m), $MachinePrecision], t$95$2]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
\begin{array}{l}
t_2 := \left(y\_m \cdot x\right) \cdot t\_m\\
t\_s \cdot \left(y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -2.25 \cdot 10^{+24}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-10}:\\
\;\;\;\;\left(\left(-z\right) \cdot y\_m\right) \cdot t\_m\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\right)
\end{array}
\end{array}
if x < -2.2500000000000001e24 or 4.2e-10 < x Initial program 98.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6479.0
Applied rewrites79.0%
if -2.2500000000000001e24 < x < 4.2e-10Initial program 94.7%
Taylor expanded in x around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f6478.8
Applied rewrites78.8%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
(FPCore (t_s y_s x y_m z t_m)
:precision binary64
(let* ((t_2 (* (* y_m x) t_m)))
(*
t_s
(*
y_s
(if (<= x -3.9e+24) t_2 (if (<= x 4.2e-10) (* (- z) (* t_m y_m)) t_2))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
assert(x < y_m && y_m < z && z < t_m);
double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double t_2 = (y_m * x) * t_m;
double tmp;
if (x <= -3.9e+24) {
tmp = t_2;
} else if (x <= 4.2e-10) {
tmp = -z * (t_m * y_m);
} else {
tmp = t_2;
}
return t_s * (y_s * tmp);
}
y\_m = private
y\_s = private
t\_m = private
t\_s = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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(t_s, y_s, x, y_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
real(8) :: t_2
real(8) :: tmp
t_2 = (y_m * x) * t_m
if (x <= (-3.9d+24)) then
tmp = t_2
else if (x <= 4.2d-10) then
tmp = -z * (t_m * y_m)
else
tmp = t_2
end if
code = t_s * (y_s * tmp)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double t_2 = (y_m * x) * t_m;
double tmp;
if (x <= -3.9e+24) {
tmp = t_2;
} else if (x <= 4.2e-10) {
tmp = -z * (t_m * y_m);
} else {
tmp = t_2;
}
return t_s * (y_s * tmp);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(t_s, y_s, x, y_m, z, t_m): t_2 = (y_m * x) * t_m tmp = 0 if x <= -3.9e+24: tmp = t_2 elif x <= 4.2e-10: tmp = -z * (t_m * y_m) else: tmp = t_2 return t_s * (y_s * tmp)
y\_m = abs(y) y\_s = copysign(1.0, y) t\_m = abs(t) t\_s = copysign(1.0, t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(t_s, y_s, x, y_m, z, t_m) t_2 = Float64(Float64(y_m * x) * t_m) tmp = 0.0 if (x <= -3.9e+24) tmp = t_2; elseif (x <= 4.2e-10) tmp = Float64(Float64(-z) * Float64(t_m * y_m)); else tmp = t_2; end return Float64(t_s * Float64(y_s * tmp)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(t_s, y_s, x, y_m, z, t_m)
t_2 = (y_m * x) * t_m;
tmp = 0.0;
if (x <= -3.9e+24)
tmp = t_2;
elseif (x <= 4.2e-10)
tmp = -z * (t_m * y_m);
else
tmp = t_2;
end
tmp_2 = t_s * (y_s * tmp);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[t$95$s_, y$95$s_, x_, y$95$m_, z_, t$95$m_] := Block[{t$95$2 = N[(N[(y$95$m * x), $MachinePrecision] * t$95$m), $MachinePrecision]}, N[(t$95$s * N[(y$95$s * If[LessEqual[x, -3.9e+24], t$95$2, If[LessEqual[x, 4.2e-10], N[((-z) * N[(t$95$m * y$95$m), $MachinePrecision]), $MachinePrecision], t$95$2]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
\begin{array}{l}
t_2 := \left(y\_m \cdot x\right) \cdot t\_m\\
t\_s \cdot \left(y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -3.9 \cdot 10^{+24}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-10}:\\
\;\;\;\;\left(-z\right) \cdot \left(t\_m \cdot y\_m\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}\right)
\end{array}
\end{array}
if x < -3.8999999999999998e24 or 4.2e-10 < x Initial program 98.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6479.1
Applied rewrites79.1%
if -3.8999999999999998e24 < x < 4.2e-10Initial program 94.7%
Applied rewrites74.2%
Taylor expanded in x around 0
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f64N/A
lift-*.f6476.5
Applied rewrites76.5%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) t\_m = (fabs.f64 t) t\_s = (copysign.f64 #s(literal 1 binary64) t) NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. (FPCore (t_s y_s x y_m z t_m) :precision binary64 (* t_s (* y_s (if (<= t_m 20000000000.0) (* (* y_m x) t_m) (* (* t_m y_m) x)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
assert(x < y_m && y_m < z && z < t_m);
double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double tmp;
if (t_m <= 20000000000.0) {
tmp = (y_m * x) * t_m;
} else {
tmp = (t_m * y_m) * x;
}
return t_s * (y_s * tmp);
}
y\_m = private
y\_s = private
t\_m = private
t\_s = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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(t_s, y_s, x, y_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
real(8) :: tmp
if (t_m <= 20000000000.0d0) then
tmp = (y_m * x) * t_m
else
tmp = (t_m * y_m) * x
end if
code = t_s * (y_s * tmp)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double tmp;
if (t_m <= 20000000000.0) {
tmp = (y_m * x) * t_m;
} else {
tmp = (t_m * y_m) * x;
}
return t_s * (y_s * tmp);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(t_s, y_s, x, y_m, z, t_m): tmp = 0 if t_m <= 20000000000.0: tmp = (y_m * x) * t_m else: tmp = (t_m * y_m) * x return t_s * (y_s * tmp)
y\_m = abs(y) y\_s = copysign(1.0, y) t\_m = abs(t) t\_s = copysign(1.0, t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(t_s, y_s, x, y_m, z, t_m) tmp = 0.0 if (t_m <= 20000000000.0) tmp = Float64(Float64(y_m * x) * t_m); else tmp = Float64(Float64(t_m * y_m) * x); end return Float64(t_s * Float64(y_s * tmp)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(t_s, y_s, x, y_m, z, t_m)
tmp = 0.0;
if (t_m <= 20000000000.0)
tmp = (y_m * x) * t_m;
else
tmp = (t_m * y_m) * x;
end
tmp_2 = t_s * (y_s * tmp);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[t$95$s_, y$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(t$95$s * N[(y$95$s * If[LessEqual[t$95$m, 20000000000.0], N[(N[(y$95$m * x), $MachinePrecision] * t$95$m), $MachinePrecision], N[(N[(t$95$m * y$95$m), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
t\_s \cdot \left(y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 20000000000:\\
\;\;\;\;\left(y\_m \cdot x\right) \cdot t\_m\\
\mathbf{else}:\\
\;\;\;\;\left(t\_m \cdot y\_m\right) \cdot x\\
\end{array}\right)
\end{array}
if t < 2e10Initial program 99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6464.8
Applied rewrites64.8%
if 2e10 < t Initial program 95.6%
Applied rewrites87.4%
Taylor expanded in x around inf
lift-*.f6454.1
Applied rewrites54.1%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) t\_m = (fabs.f64 t) t\_s = (copysign.f64 #s(literal 1 binary64) t) NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. (FPCore (t_s y_s x y_m z t_m) :precision binary64 (* t_s (* y_s (if (<= t_m 2.2e-6) (* (* t_m x) y_m) (* (* t_m y_m) x)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
assert(x < y_m && y_m < z && z < t_m);
double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double tmp;
if (t_m <= 2.2e-6) {
tmp = (t_m * x) * y_m;
} else {
tmp = (t_m * y_m) * x;
}
return t_s * (y_s * tmp);
}
y\_m = private
y\_s = private
t\_m = private
t\_s = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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(t_s, y_s, x, y_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
real(8) :: tmp
if (t_m <= 2.2d-6) then
tmp = (t_m * x) * y_m
else
tmp = (t_m * y_m) * x
end if
code = t_s * (y_s * tmp)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
double tmp;
if (t_m <= 2.2e-6) {
tmp = (t_m * x) * y_m;
} else {
tmp = (t_m * y_m) * x;
}
return t_s * (y_s * tmp);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(t_s, y_s, x, y_m, z, t_m): tmp = 0 if t_m <= 2.2e-6: tmp = (t_m * x) * y_m else: tmp = (t_m * y_m) * x return t_s * (y_s * tmp)
y\_m = abs(y) y\_s = copysign(1.0, y) t\_m = abs(t) t\_s = copysign(1.0, t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(t_s, y_s, x, y_m, z, t_m) tmp = 0.0 if (t_m <= 2.2e-6) tmp = Float64(Float64(t_m * x) * y_m); else tmp = Float64(Float64(t_m * y_m) * x); end return Float64(t_s * Float64(y_s * tmp)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(t_s, y_s, x, y_m, z, t_m)
tmp = 0.0;
if (t_m <= 2.2e-6)
tmp = (t_m * x) * y_m;
else
tmp = (t_m * y_m) * x;
end
tmp_2 = t_s * (y_s * tmp);
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[t$95$s_, y$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(t$95$s * N[(y$95$s * If[LessEqual[t$95$m, 2.2e-6], N[(N[(t$95$m * x), $MachinePrecision] * y$95$m), $MachinePrecision], N[(N[(t$95$m * y$95$m), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
t\_s \cdot \left(y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 2.2 \cdot 10^{-6}:\\
\;\;\;\;\left(t\_m \cdot x\right) \cdot y\_m\\
\mathbf{else}:\\
\;\;\;\;\left(t\_m \cdot y\_m\right) \cdot x\\
\end{array}\right)
\end{array}
if t < 2.2000000000000001e-6Initial program 99.7%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6465.0
Applied rewrites65.0%
if 2.2000000000000001e-6 < t Initial program 95.7%
Applied rewrites87.4%
Taylor expanded in x around inf
lift-*.f6454.4
Applied rewrites54.4%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) t\_m = (fabs.f64 t) t\_s = (copysign.f64 #s(literal 1 binary64) t) NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. (FPCore (t_s y_s x y_m z t_m) :precision binary64 (* t_s (* y_s (* (* t_m x) y_m))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
t\_m = fabs(t);
t\_s = copysign(1.0, t);
assert(x < y_m && y_m < z && z < t_m);
double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
return t_s * (y_s * ((t_m * x) * y_m));
}
y\_m = private
y\_s = private
t\_m = private
t\_s = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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(t_s, y_s, x, y_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: t_s
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
code = t_s * (y_s * ((t_m * x) * y_m))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double t_s, double y_s, double x, double y_m, double z, double t_m) {
return t_s * (y_s * ((t_m * x) * y_m));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(t_s, y_s, x, y_m, z, t_m): return t_s * (y_s * ((t_m * x) * y_m))
y\_m = abs(y) y\_s = copysign(1.0, y) t\_m = abs(t) t\_s = copysign(1.0, t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(t_s, y_s, x, y_m, z, t_m) return Float64(t_s * Float64(y_s * Float64(Float64(t_m * x) * y_m))) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
t\_m = abs(t);
t\_s = sign(t) * abs(1.0);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp = code(t_s, y_s, x, y_m, z, t_m)
tmp = t_s * (y_s * ((t_m * x) * y_m));
end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
code[t$95$s_, y$95$s_, x_, y$95$m_, z_, t$95$m_] := N[(t$95$s * N[(y$95$s * N[(N[(t$95$m * x), $MachinePrecision] * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
t\_s \cdot \left(y\_s \cdot \left(\left(t\_m \cdot x\right) \cdot y\_m\right)\right)
\end{array}
Initial program 96.7%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6450.3
Applied rewrites50.3%
herbie shell --seed 2025130
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
(* (- (* x y) (* z y)) t))