
(FPCore (u v t1) :precision binary64 (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))
double code(double u, double v, double t1) {
return (-t1 * v) / ((t1 + u) * (t1 + u));
}
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(u, v, t1)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
code = (-t1 * v) / ((t1 + u) * (t1 + u))
end function
public static double code(double u, double v, double t1) {
return (-t1 * v) / ((t1 + u) * (t1 + u));
}
def code(u, v, t1): return (-t1 * v) / ((t1 + u) * (t1 + u))
function code(u, v, t1) return Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u))) end
function tmp = code(u, v, t1) tmp = (-t1 * v) / ((t1 + u) * (t1 + u)); end
code[u_, v_, t1_] := N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (u v t1) :precision binary64 (/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))
double code(double u, double v, double t1) {
return (-t1 * v) / ((t1 + u) * (t1 + u));
}
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(u, v, t1)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
code = (-t1 * v) / ((t1 + u) * (t1 + u))
end function
public static double code(double u, double v, double t1) {
return (-t1 * v) / ((t1 + u) * (t1 + u));
}
def code(u, v, t1): return (-t1 * v) / ((t1 + u) * (t1 + u))
function code(u, v, t1) return Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u))) end
function tmp = code(u, v, t1) tmp = (-t1 * v) / ((t1 + u) * (t1 + u)); end
code[u_, v_, t1_] := N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}
\end{array}
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
:precision binary64
(let* ((t_1 (- (- t1) u)))
(*
v_s
(if (<= v_m 3.4e+125)
(* (/ v_m t_1) (/ t1 (+ u t1)))
(/ (* (/ t1 t_1) v_m) (+ u t1))))))v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
double t_1 = -t1 - u;
double tmp;
if (v_m <= 3.4e+125) {
tmp = (v_m / t_1) * (t1 / (u + t1));
} else {
tmp = ((t1 / t_1) * v_m) / (u + t1);
}
return v_s * tmp;
}
v\_m = private
v\_s = private
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(v_s, u, v_m, t1)
use fmin_fmax_functions
real(8), intent (in) :: v_s
real(8), intent (in) :: u
real(8), intent (in) :: v_m
real(8), intent (in) :: t1
real(8) :: t_1
real(8) :: tmp
t_1 = -t1 - u
if (v_m <= 3.4d+125) then
tmp = (v_m / t_1) * (t1 / (u + t1))
else
tmp = ((t1 / t_1) * v_m) / (u + t1)
end if
code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
double t_1 = -t1 - u;
double tmp;
if (v_m <= 3.4e+125) {
tmp = (v_m / t_1) * (t1 / (u + t1));
} else {
tmp = ((t1 / t_1) * v_m) / (u + t1);
}
return v_s * tmp;
}
v\_m = math.fabs(v) v\_s = math.copysign(1.0, v) def code(v_s, u, v_m, t1): t_1 = -t1 - u tmp = 0 if v_m <= 3.4e+125: tmp = (v_m / t_1) * (t1 / (u + t1)) else: tmp = ((t1 / t_1) * v_m) / (u + t1) return v_s * tmp
v\_m = abs(v) v\_s = copysign(1.0, v) function code(v_s, u, v_m, t1) t_1 = Float64(Float64(-t1) - u) tmp = 0.0 if (v_m <= 3.4e+125) tmp = Float64(Float64(v_m / t_1) * Float64(t1 / Float64(u + t1))); else tmp = Float64(Float64(Float64(t1 / t_1) * v_m) / Float64(u + t1)); end return Float64(v_s * tmp) end
v\_m = abs(v); v\_s = sign(v) * abs(1.0); function tmp_2 = code(v_s, u, v_m, t1) t_1 = -t1 - u; tmp = 0.0; if (v_m <= 3.4e+125) tmp = (v_m / t_1) * (t1 / (u + t1)); else tmp = ((t1 / t_1) * v_m) / (u + t1); end tmp_2 = v_s * tmp; end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[((-t1) - u), $MachinePrecision]}, N[(v$95$s * If[LessEqual[v$95$m, 3.4e+125], N[(N[(v$95$m / t$95$1), $MachinePrecision] * N[(t1 / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t1 / t$95$1), $MachinePrecision] * v$95$m), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)
\\
\begin{array}{l}
t_1 := \left(-t1\right) - u\\
v\_s \cdot \begin{array}{l}
\mathbf{if}\;v\_m \leq 3.4 \cdot 10^{+125}:\\
\;\;\;\;\frac{v\_m}{t\_1} \cdot \frac{t1}{u + t1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t1}{t\_1} \cdot v\_m}{u + t1}\\
\end{array}
\end{array}
\end{array}
if v < 3.3999999999999999e125Initial program 72.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f64N/A
lift-neg.f64N/A
frac-2neg-revN/A
lower-/.f6498.2
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.2
Applied rewrites98.2%
if 3.3999999999999999e125 < v Initial program 72.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-neg.f64N/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6498.3
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.3
Applied rewrites98.3%
v\_m = (fabs.f64 v) v\_s = (copysign.f64 #s(literal 1 binary64) v) (FPCore (v_s u v_m t1) :precision binary64 (* v_s (* (/ v_m (- (- t1) u)) (/ t1 (+ u t1)))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
return v_s * ((v_m / (-t1 - u)) * (t1 / (u + t1)));
}
v\_m = private
v\_s = private
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(v_s, u, v_m, t1)
use fmin_fmax_functions
real(8), intent (in) :: v_s
real(8), intent (in) :: u
real(8), intent (in) :: v_m
real(8), intent (in) :: t1
code = v_s * ((v_m / (-t1 - u)) * (t1 / (u + t1)))
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
return v_s * ((v_m / (-t1 - u)) * (t1 / (u + t1)));
}
v\_m = math.fabs(v) v\_s = math.copysign(1.0, v) def code(v_s, u, v_m, t1): return v_s * ((v_m / (-t1 - u)) * (t1 / (u + t1)))
v\_m = abs(v) v\_s = copysign(1.0, v) function code(v_s, u, v_m, t1) return Float64(v_s * Float64(Float64(v_m / Float64(Float64(-t1) - u)) * Float64(t1 / Float64(u + t1)))) end
v\_m = abs(v); v\_s = sign(v) * abs(1.0); function tmp = code(v_s, u, v_m, t1) tmp = v_s * ((v_m / (-t1 - u)) * (t1 / (u + t1))); end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := N[(v$95$s * N[(N[(v$95$m / N[((-t1) - u), $MachinePrecision]), $MachinePrecision] * N[(t1 / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)
\\
v\_s \cdot \left(\frac{v\_m}{\left(-t1\right) - u} \cdot \frac{t1}{u + t1}\right)
\end{array}
Initial program 72.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f64N/A
lift-neg.f64N/A
frac-2neg-revN/A
lower-/.f6498.2
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.2
Applied rewrites98.2%
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
:precision binary64
(*
v_s
(if (<= t1 -3.45e+142)
(/ (* -1.0 v_m) (+ u t1))
(if (<= t1 1.45e+165)
(* (/ t1 (* (- (- t1) u) (+ u t1))) v_m)
(* (/ (fma (/ u t1) 2.0 -1.0) t1) v_m)))))v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
double tmp;
if (t1 <= -3.45e+142) {
tmp = (-1.0 * v_m) / (u + t1);
} else if (t1 <= 1.45e+165) {
tmp = (t1 / ((-t1 - u) * (u + t1))) * v_m;
} else {
tmp = (fma((u / t1), 2.0, -1.0) / t1) * v_m;
}
return v_s * tmp;
}
v\_m = abs(v) v\_s = copysign(1.0, v) function code(v_s, u, v_m, t1) tmp = 0.0 if (t1 <= -3.45e+142) tmp = Float64(Float64(-1.0 * v_m) / Float64(u + t1)); elseif (t1 <= 1.45e+165) tmp = Float64(Float64(t1 / Float64(Float64(Float64(-t1) - u) * Float64(u + t1))) * v_m); else tmp = Float64(Float64(fma(Float64(u / t1), 2.0, -1.0) / t1) * v_m); end return Float64(v_s * tmp) end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := N[(v$95$s * If[LessEqual[t1, -3.45e+142], N[(N[(-1.0 * v$95$m), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 1.45e+165], N[(N[(t1 / N[(N[((-t1) - u), $MachinePrecision] * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * v$95$m), $MachinePrecision], N[(N[(N[(N[(u / t1), $MachinePrecision] * 2.0 + -1.0), $MachinePrecision] / t1), $MachinePrecision] * v$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)
\\
v\_s \cdot \begin{array}{l}
\mathbf{if}\;t1 \leq -3.45 \cdot 10^{+142}:\\
\;\;\;\;\frac{-1 \cdot v\_m}{u + t1}\\
\mathbf{elif}\;t1 \leq 1.45 \cdot 10^{+165}:\\
\;\;\;\;\frac{t1}{\left(\left(-t1\right) - u\right) \cdot \left(u + t1\right)} \cdot v\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{u}{t1}, 2, -1\right)}{t1} \cdot v\_m\\
\end{array}
\end{array}
if t1 < -3.4500000000000002e142Initial program 72.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-neg.f64N/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6498.3
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.3
Applied rewrites98.3%
Taylor expanded in u around 0
Applied rewrites62.3%
if -3.4500000000000002e142 < t1 < 1.45000000000000003e165Initial program 72.6%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites76.2%
if 1.45000000000000003e165 < t1 Initial program 72.6%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites76.2%
Taylor expanded in t1 around inf
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6452.8
Applied rewrites52.8%
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6452.8
Applied rewrites52.8%
v\_m = (fabs.f64 v) v\_s = (copysign.f64 #s(literal 1 binary64) v) (FPCore (v_s u v_m t1) :precision binary64 (let* ((t_1 (* (/ v_m (- (- t1) u)) (/ t1 u)))) (* v_s (if (<= u -2.7e-64) t_1 (if (<= u 1.3e-36) (/ (- v_m) t1) t_1)))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
double t_1 = (v_m / (-t1 - u)) * (t1 / u);
double tmp;
if (u <= -2.7e-64) {
tmp = t_1;
} else if (u <= 1.3e-36) {
tmp = -v_m / t1;
} else {
tmp = t_1;
}
return v_s * tmp;
}
v\_m = private
v\_s = private
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(v_s, u, v_m, t1)
use fmin_fmax_functions
real(8), intent (in) :: v_s
real(8), intent (in) :: u
real(8), intent (in) :: v_m
real(8), intent (in) :: t1
real(8) :: t_1
real(8) :: tmp
t_1 = (v_m / (-t1 - u)) * (t1 / u)
if (u <= (-2.7d-64)) then
tmp = t_1
else if (u <= 1.3d-36) then
tmp = -v_m / t1
else
tmp = t_1
end if
code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
double t_1 = (v_m / (-t1 - u)) * (t1 / u);
double tmp;
if (u <= -2.7e-64) {
tmp = t_1;
} else if (u <= 1.3e-36) {
tmp = -v_m / t1;
} else {
tmp = t_1;
}
return v_s * tmp;
}
v\_m = math.fabs(v) v\_s = math.copysign(1.0, v) def code(v_s, u, v_m, t1): t_1 = (v_m / (-t1 - u)) * (t1 / u) tmp = 0 if u <= -2.7e-64: tmp = t_1 elif u <= 1.3e-36: tmp = -v_m / t1 else: tmp = t_1 return v_s * tmp
v\_m = abs(v) v\_s = copysign(1.0, v) function code(v_s, u, v_m, t1) t_1 = Float64(Float64(v_m / Float64(Float64(-t1) - u)) * Float64(t1 / u)) tmp = 0.0 if (u <= -2.7e-64) tmp = t_1; elseif (u <= 1.3e-36) tmp = Float64(Float64(-v_m) / t1); else tmp = t_1; end return Float64(v_s * tmp) end
v\_m = abs(v); v\_s = sign(v) * abs(1.0); function tmp_2 = code(v_s, u, v_m, t1) t_1 = (v_m / (-t1 - u)) * (t1 / u); tmp = 0.0; if (u <= -2.7e-64) tmp = t_1; elseif (u <= 1.3e-36) tmp = -v_m / t1; else tmp = t_1; end tmp_2 = v_s * tmp; end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[(N[(v$95$m / N[((-t1) - u), $MachinePrecision]), $MachinePrecision] * N[(t1 / u), $MachinePrecision]), $MachinePrecision]}, N[(v$95$s * If[LessEqual[u, -2.7e-64], t$95$1, If[LessEqual[u, 1.3e-36], N[((-v$95$m) / t1), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)
\\
\begin{array}{l}
t_1 := \frac{v\_m}{\left(-t1\right) - u} \cdot \frac{t1}{u}\\
v\_s \cdot \begin{array}{l}
\mathbf{if}\;u \leq -2.7 \cdot 10^{-64}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;u \leq 1.3 \cdot 10^{-36}:\\
\;\;\;\;\frac{-v\_m}{t1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if u < -2.69999999999999986e-64 or 1.3e-36 < u Initial program 72.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f64N/A
lift-neg.f64N/A
frac-2neg-revN/A
lower-/.f6498.2
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.2
Applied rewrites98.2%
Taylor expanded in u around inf
lower-/.f6454.6
Applied rewrites54.6%
if -2.69999999999999986e-64 < u < 1.3e-36Initial program 72.6%
Taylor expanded in u around 0
lower-*.f64N/A
lower-/.f6454.9
Applied rewrites54.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6454.9
Applied rewrites54.9%
v\_m = (fabs.f64 v) v\_s = (copysign.f64 #s(literal 1 binary64) v) (FPCore (v_s u v_m t1) :precision binary64 (let* ((t_1 (* (/ v_m (* (- u) (+ u t1))) t1))) (* v_s (if (<= u -1.82e-50) t_1 (if (<= u 6e-36) (/ (- v_m) t1) t_1)))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
double t_1 = (v_m / (-u * (u + t1))) * t1;
double tmp;
if (u <= -1.82e-50) {
tmp = t_1;
} else if (u <= 6e-36) {
tmp = -v_m / t1;
} else {
tmp = t_1;
}
return v_s * tmp;
}
v\_m = private
v\_s = private
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(v_s, u, v_m, t1)
use fmin_fmax_functions
real(8), intent (in) :: v_s
real(8), intent (in) :: u
real(8), intent (in) :: v_m
real(8), intent (in) :: t1
real(8) :: t_1
real(8) :: tmp
t_1 = (v_m / (-u * (u + t1))) * t1
if (u <= (-1.82d-50)) then
tmp = t_1
else if (u <= 6d-36) then
tmp = -v_m / t1
else
tmp = t_1
end if
code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
double t_1 = (v_m / (-u * (u + t1))) * t1;
double tmp;
if (u <= -1.82e-50) {
tmp = t_1;
} else if (u <= 6e-36) {
tmp = -v_m / t1;
} else {
tmp = t_1;
}
return v_s * tmp;
}
v\_m = math.fabs(v) v\_s = math.copysign(1.0, v) def code(v_s, u, v_m, t1): t_1 = (v_m / (-u * (u + t1))) * t1 tmp = 0 if u <= -1.82e-50: tmp = t_1 elif u <= 6e-36: tmp = -v_m / t1 else: tmp = t_1 return v_s * tmp
v\_m = abs(v) v\_s = copysign(1.0, v) function code(v_s, u, v_m, t1) t_1 = Float64(Float64(v_m / Float64(Float64(-u) * Float64(u + t1))) * t1) tmp = 0.0 if (u <= -1.82e-50) tmp = t_1; elseif (u <= 6e-36) tmp = Float64(Float64(-v_m) / t1); else tmp = t_1; end return Float64(v_s * tmp) end
v\_m = abs(v); v\_s = sign(v) * abs(1.0); function tmp_2 = code(v_s, u, v_m, t1) t_1 = (v_m / (-u * (u + t1))) * t1; tmp = 0.0; if (u <= -1.82e-50) tmp = t_1; elseif (u <= 6e-36) tmp = -v_m / t1; else tmp = t_1; end tmp_2 = v_s * tmp; end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[(N[(v$95$m / N[((-u) * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t1), $MachinePrecision]}, N[(v$95$s * If[LessEqual[u, -1.82e-50], t$95$1, If[LessEqual[u, 6e-36], N[((-v$95$m) / t1), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)
\\
\begin{array}{l}
t_1 := \frac{v\_m}{\left(-u\right) \cdot \left(u + t1\right)} \cdot t1\\
v\_s \cdot \begin{array}{l}
\mathbf{if}\;u \leq -1.82 \cdot 10^{-50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;u \leq 6 \cdot 10^{-36}:\\
\;\;\;\;\frac{-v\_m}{t1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if u < -1.81999999999999995e-50 or 6.0000000000000003e-36 < u Initial program 72.6%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6472.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6472.6
Applied rewrites72.6%
Taylor expanded in u around inf
lower-*.f6445.7
Applied rewrites45.7%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites48.4%
if -1.81999999999999995e-50 < u < 6.0000000000000003e-36Initial program 72.6%
Taylor expanded in u around 0
lower-*.f64N/A
lower-/.f6454.9
Applied rewrites54.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6454.9
Applied rewrites54.9%
v\_m = (fabs.f64 v)
v\_s = (copysign.f64 #s(literal 1 binary64) v)
(FPCore (v_s u v_m t1)
:precision binary64
(let* ((t_1 (/ (* -1.0 v_m) (+ u t1))))
(*
v_s
(if (<= t1 -3.8e-77)
t_1
(if (<= t1 9.4e-5) (* (/ t1 (* (- u) (+ u t1))) v_m) t_1)))))v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
double t_1 = (-1.0 * v_m) / (u + t1);
double tmp;
if (t1 <= -3.8e-77) {
tmp = t_1;
} else if (t1 <= 9.4e-5) {
tmp = (t1 / (-u * (u + t1))) * v_m;
} else {
tmp = t_1;
}
return v_s * tmp;
}
v\_m = private
v\_s = private
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(v_s, u, v_m, t1)
use fmin_fmax_functions
real(8), intent (in) :: v_s
real(8), intent (in) :: u
real(8), intent (in) :: v_m
real(8), intent (in) :: t1
real(8) :: t_1
real(8) :: tmp
t_1 = ((-1.0d0) * v_m) / (u + t1)
if (t1 <= (-3.8d-77)) then
tmp = t_1
else if (t1 <= 9.4d-5) then
tmp = (t1 / (-u * (u + t1))) * v_m
else
tmp = t_1
end if
code = v_s * tmp
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
double t_1 = (-1.0 * v_m) / (u + t1);
double tmp;
if (t1 <= -3.8e-77) {
tmp = t_1;
} else if (t1 <= 9.4e-5) {
tmp = (t1 / (-u * (u + t1))) * v_m;
} else {
tmp = t_1;
}
return v_s * tmp;
}
v\_m = math.fabs(v) v\_s = math.copysign(1.0, v) def code(v_s, u, v_m, t1): t_1 = (-1.0 * v_m) / (u + t1) tmp = 0 if t1 <= -3.8e-77: tmp = t_1 elif t1 <= 9.4e-5: tmp = (t1 / (-u * (u + t1))) * v_m else: tmp = t_1 return v_s * tmp
v\_m = abs(v) v\_s = copysign(1.0, v) function code(v_s, u, v_m, t1) t_1 = Float64(Float64(-1.0 * v_m) / Float64(u + t1)) tmp = 0.0 if (t1 <= -3.8e-77) tmp = t_1; elseif (t1 <= 9.4e-5) tmp = Float64(Float64(t1 / Float64(Float64(-u) * Float64(u + t1))) * v_m); else tmp = t_1; end return Float64(v_s * tmp) end
v\_m = abs(v); v\_s = sign(v) * abs(1.0); function tmp_2 = code(v_s, u, v_m, t1) t_1 = (-1.0 * v_m) / (u + t1); tmp = 0.0; if (t1 <= -3.8e-77) tmp = t_1; elseif (t1 <= 9.4e-5) tmp = (t1 / (-u * (u + t1))) * v_m; else tmp = t_1; end tmp_2 = v_s * tmp; end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := Block[{t$95$1 = N[(N[(-1.0 * v$95$m), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]}, N[(v$95$s * If[LessEqual[t1, -3.8e-77], t$95$1, If[LessEqual[t1, 9.4e-5], N[(N[(t1 / N[((-u) * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * v$95$m), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)
\\
\begin{array}{l}
t_1 := \frac{-1 \cdot v\_m}{u + t1}\\
v\_s \cdot \begin{array}{l}
\mathbf{if}\;t1 \leq -3.8 \cdot 10^{-77}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t1 \leq 9.4 \cdot 10^{-5}:\\
\;\;\;\;\frac{t1}{\left(-u\right) \cdot \left(u + t1\right)} \cdot v\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if t1 < -3.7999999999999999e-77 or 9.39999999999999945e-5 < t1 Initial program 72.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-neg.f64N/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6498.3
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.3
Applied rewrites98.3%
Taylor expanded in u around 0
Applied rewrites62.3%
if -3.7999999999999999e-77 < t1 < 9.39999999999999945e-5Initial program 72.6%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6472.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6472.6
Applied rewrites72.6%
Taylor expanded in u around inf
lower-*.f6445.7
Applied rewrites45.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites46.2%
v\_m = (fabs.f64 v) v\_s = (copysign.f64 #s(literal 1 binary64) v) (FPCore (v_s u v_m t1) :precision binary64 (* v_s (/ (* -1.0 v_m) (+ u t1))))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
return v_s * ((-1.0 * v_m) / (u + t1));
}
v\_m = private
v\_s = private
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(v_s, u, v_m, t1)
use fmin_fmax_functions
real(8), intent (in) :: v_s
real(8), intent (in) :: u
real(8), intent (in) :: v_m
real(8), intent (in) :: t1
code = v_s * (((-1.0d0) * v_m) / (u + t1))
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
return v_s * ((-1.0 * v_m) / (u + t1));
}
v\_m = math.fabs(v) v\_s = math.copysign(1.0, v) def code(v_s, u, v_m, t1): return v_s * ((-1.0 * v_m) / (u + t1))
v\_m = abs(v) v\_s = copysign(1.0, v) function code(v_s, u, v_m, t1) return Float64(v_s * Float64(Float64(-1.0 * v_m) / Float64(u + t1))) end
v\_m = abs(v); v\_s = sign(v) * abs(1.0); function tmp = code(v_s, u, v_m, t1) tmp = v_s * ((-1.0 * v_m) / (u + t1)); end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := N[(v$95$s * N[(N[(-1.0 * v$95$m), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)
\\
v\_s \cdot \frac{-1 \cdot v\_m}{u + t1}
\end{array}
Initial program 72.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-neg.f64N/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6498.3
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.3
Applied rewrites98.3%
Taylor expanded in u around 0
Applied rewrites62.3%
v\_m = (fabs.f64 v) v\_s = (copysign.f64 #s(literal 1 binary64) v) (FPCore (v_s u v_m t1) :precision binary64 (* v_s (/ (- v_m) t1)))
v\_m = fabs(v);
v\_s = copysign(1.0, v);
double code(double v_s, double u, double v_m, double t1) {
return v_s * (-v_m / t1);
}
v\_m = private
v\_s = private
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(v_s, u, v_m, t1)
use fmin_fmax_functions
real(8), intent (in) :: v_s
real(8), intent (in) :: u
real(8), intent (in) :: v_m
real(8), intent (in) :: t1
code = v_s * (-v_m / t1)
end function
v\_m = Math.abs(v);
v\_s = Math.copySign(1.0, v);
public static double code(double v_s, double u, double v_m, double t1) {
return v_s * (-v_m / t1);
}
v\_m = math.fabs(v) v\_s = math.copysign(1.0, v) def code(v_s, u, v_m, t1): return v_s * (-v_m / t1)
v\_m = abs(v) v\_s = copysign(1.0, v) function code(v_s, u, v_m, t1) return Float64(v_s * Float64(Float64(-v_m) / t1)) end
v\_m = abs(v); v\_s = sign(v) * abs(1.0); function tmp = code(v_s, u, v_m, t1) tmp = v_s * (-v_m / t1); end
v\_m = N[Abs[v], $MachinePrecision]
v\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[v$95$s_, u_, v$95$m_, t1_] := N[(v$95$s * N[((-v$95$m) / t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
v\_m = \left|v\right|
\\
v\_s = \mathsf{copysign}\left(1, v\right)
\\
v\_s \cdot \frac{-v\_m}{t1}
\end{array}
Initial program 72.6%
Taylor expanded in u around 0
lower-*.f64N/A
lower-/.f6454.9
Applied rewrites54.9%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6454.9
Applied rewrites54.9%
herbie shell --seed 2025156
(FPCore (u v t1)
:name "Rosa's DopplerBench"
:precision binary64
(/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))