
(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}
Sampling outcomes in binary64 precision:
Herbie found 9 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}
(FPCore (u v t1) :precision binary64 (/ (* t1 (/ v (+ u t1))) (- (- u) t1)))
double code(double u, double v, double t1) {
return (t1 * (v / (u + t1))) / (-u - t1);
}
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 / (u + t1))) / (-u - t1)
end function
public static double code(double u, double v, double t1) {
return (t1 * (v / (u + t1))) / (-u - t1);
}
def code(u, v, t1): return (t1 * (v / (u + t1))) / (-u - t1)
function code(u, v, t1) return Float64(Float64(t1 * Float64(v / Float64(u + t1))) / Float64(Float64(-u) - t1)) end
function tmp = code(u, v, t1) tmp = (t1 * (v / (u + t1))) / (-u - t1); end
code[u_, v_, t1_] := N[(N[(t1 * N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[((-u) - t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{t1 \cdot \frac{v}{u + t1}}{\left(-u\right) - t1}
\end{array}
Initial program 72.4%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6475.9
Applied rewrites75.9%
Applied rewrites98.5%
Final simplification98.5%
(FPCore (u v t1)
:precision binary64
(if (<= t1 -4.6e+203)
(/ (- v) t1)
(if (<= t1 7e+168)
(* (/ (/ v (+ u t1)) (+ u t1)) (- t1))
(/ (fma (/ v t1) u (- v)) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -4.6e+203) {
tmp = -v / t1;
} else if (t1 <= 7e+168) {
tmp = ((v / (u + t1)) / (u + t1)) * -t1;
} else {
tmp = fma((v / t1), u, -v) / (u + t1);
}
return tmp;
}
function code(u, v, t1) tmp = 0.0 if (t1 <= -4.6e+203) tmp = Float64(Float64(-v) / t1); elseif (t1 <= 7e+168) tmp = Float64(Float64(Float64(v / Float64(u + t1)) / Float64(u + t1)) * Float64(-t1)); else tmp = Float64(fma(Float64(v / t1), u, Float64(-v)) / Float64(u + t1)); end return tmp end
code[u_, v_, t1_] := If[LessEqual[t1, -4.6e+203], N[((-v) / t1), $MachinePrecision], If[LessEqual[t1, 7e+168], N[(N[(N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision] * (-t1)), $MachinePrecision], N[(N[(N[(v / t1), $MachinePrecision] * u + (-v)), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -4.6 \cdot 10^{+203}:\\
\;\;\;\;\frac{-v}{t1}\\
\mathbf{elif}\;t1 \leq 7 \cdot 10^{+168}:\\
\;\;\;\;\frac{\frac{v}{u + t1}}{u + t1} \cdot \left(-t1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{v}{t1}, u, -v\right)}{u + t1}\\
\end{array}
\end{array}
if t1 < -4.5999999999999998e203Initial program 34.5%
Taylor expanded in u around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
if -4.5999999999999998e203 < t1 < 7.0000000000000004e168Initial program 79.2%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6483.0
Applied rewrites83.0%
Applied rewrites93.2%
if 7.0000000000000004e168 < t1 Initial program 40.7%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6442.3
Applied rewrites42.3%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites95.3%
(FPCore (u v t1) :precision binary64 (if (or (<= t1 -2.7e+108) (not (<= t1 4.7e+141))) (/ (- v) (+ u t1)) (* (/ (- v) (* (+ u t1) (+ u t1))) t1)))
double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -2.7e+108) || !(t1 <= 4.7e+141)) {
tmp = -v / (u + t1);
} else {
tmp = (-v / ((u + t1) * (u + t1))) * t1;
}
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(u, v, t1)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
real(8) :: tmp
if ((t1 <= (-2.7d+108)) .or. (.not. (t1 <= 4.7d+141))) then
tmp = -v / (u + t1)
else
tmp = (-v / ((u + t1) * (u + t1))) * t1
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -2.7e+108) || !(t1 <= 4.7e+141)) {
tmp = -v / (u + t1);
} else {
tmp = (-v / ((u + t1) * (u + t1))) * t1;
}
return tmp;
}
def code(u, v, t1): tmp = 0 if (t1 <= -2.7e+108) or not (t1 <= 4.7e+141): tmp = -v / (u + t1) else: tmp = (-v / ((u + t1) * (u + t1))) * t1 return tmp
function code(u, v, t1) tmp = 0.0 if ((t1 <= -2.7e+108) || !(t1 <= 4.7e+141)) tmp = Float64(Float64(-v) / Float64(u + t1)); else tmp = Float64(Float64(Float64(-v) / Float64(Float64(u + t1) * Float64(u + t1))) * t1); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if ((t1 <= -2.7e+108) || ~((t1 <= 4.7e+141))) tmp = -v / (u + t1); else tmp = (-v / ((u + t1) * (u + t1))) * t1; end tmp_2 = tmp; end
code[u_, v_, t1_] := If[Or[LessEqual[t1, -2.7e+108], N[Not[LessEqual[t1, 4.7e+141]], $MachinePrecision]], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision], N[(N[((-v) / N[(N[(u + t1), $MachinePrecision] * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -2.7 \cdot 10^{+108} \lor \neg \left(t1 \leq 4.7 \cdot 10^{+141}\right):\\
\;\;\;\;\frac{-v}{u + t1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{\left(u + t1\right) \cdot \left(u + t1\right)} \cdot t1\\
\end{array}
\end{array}
if t1 < -2.7e108 or 4.69999999999999979e141 < t1 Initial program 47.9%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6451.3
Applied rewrites51.3%
Applied rewrites100.0%
Taylor expanded in u around 0
Applied rewrites94.0%
if -2.7e108 < t1 < 4.69999999999999979e141Initial program 81.4%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6484.9
Applied rewrites84.9%
Applied rewrites84.9%
Final simplification87.4%
(FPCore (u v t1) :precision binary64 (if (<= t1 -5e-30) (/ (* -1.0 v) (+ (- u) t1)) (if (<= t1 1.9e-62) (* (- v) (/ (/ t1 u) u)) (/ (- v) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -5e-30) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 1.9e-62) {
tmp = -v * ((t1 / u) / u);
} else {
tmp = -v / (u + t1);
}
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(u, v, t1)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
real(8) :: tmp
if (t1 <= (-5d-30)) then
tmp = ((-1.0d0) * v) / (-u + t1)
else if (t1 <= 1.9d-62) then
tmp = -v * ((t1 / u) / u)
else
tmp = -v / (u + t1)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if (t1 <= -5e-30) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 1.9e-62) {
tmp = -v * ((t1 / u) / u);
} else {
tmp = -v / (u + t1);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if t1 <= -5e-30: tmp = (-1.0 * v) / (-u + t1) elif t1 <= 1.9e-62: tmp = -v * ((t1 / u) / u) else: tmp = -v / (u + t1) return tmp
function code(u, v, t1) tmp = 0.0 if (t1 <= -5e-30) tmp = Float64(Float64(-1.0 * v) / Float64(Float64(-u) + t1)); elseif (t1 <= 1.9e-62) tmp = Float64(Float64(-v) * Float64(Float64(t1 / u) / u)); else tmp = Float64(Float64(-v) / Float64(u + t1)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if (t1 <= -5e-30) tmp = (-1.0 * v) / (-u + t1); elseif (t1 <= 1.9e-62) tmp = -v * ((t1 / u) / u); else tmp = -v / (u + t1); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[LessEqual[t1, -5e-30], N[(N[(-1.0 * v), $MachinePrecision] / N[((-u) + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 1.9e-62], N[((-v) * N[(N[(t1 / u), $MachinePrecision] / u), $MachinePrecision]), $MachinePrecision], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -5 \cdot 10^{-30}:\\
\;\;\;\;\frac{-1 \cdot v}{\left(-u\right) + t1}\\
\mathbf{elif}\;t1 \leq 1.9 \cdot 10^{-62}:\\
\;\;\;\;\left(-v\right) \cdot \frac{\frac{t1}{u}}{u}\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{u + t1}\\
\end{array}
\end{array}
if t1 < -4.99999999999999972e-30Initial program 68.6%
Applied rewrites99.4%
Taylor expanded in u around 0
Applied rewrites84.4%
if -4.99999999999999972e-30 < t1 < 1.90000000000000003e-62Initial program 80.6%
Taylor expanded in u around inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
times-fracN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-frac-negN/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6479.9
Applied rewrites79.9%
Applied rewrites79.8%
if 1.90000000000000003e-62 < t1 Initial program 64.3%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6467.2
Applied rewrites67.2%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites72.5%
Final simplification78.6%
(FPCore (u v t1) :precision binary64 (if (<= t1 -5e-30) (/ (* -1.0 v) (+ (- u) t1)) (if (<= t1 1.9e-62) (* v (/ (- t1) (* u u))) (/ (- v) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -5e-30) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 1.9e-62) {
tmp = v * (-t1 / (u * u));
} else {
tmp = -v / (u + t1);
}
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(u, v, t1)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
real(8) :: tmp
if (t1 <= (-5d-30)) then
tmp = ((-1.0d0) * v) / (-u + t1)
else if (t1 <= 1.9d-62) then
tmp = v * (-t1 / (u * u))
else
tmp = -v / (u + t1)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if (t1 <= -5e-30) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 1.9e-62) {
tmp = v * (-t1 / (u * u));
} else {
tmp = -v / (u + t1);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if t1 <= -5e-30: tmp = (-1.0 * v) / (-u + t1) elif t1 <= 1.9e-62: tmp = v * (-t1 / (u * u)) else: tmp = -v / (u + t1) return tmp
function code(u, v, t1) tmp = 0.0 if (t1 <= -5e-30) tmp = Float64(Float64(-1.0 * v) / Float64(Float64(-u) + t1)); elseif (t1 <= 1.9e-62) tmp = Float64(v * Float64(Float64(-t1) / Float64(u * u))); else tmp = Float64(Float64(-v) / Float64(u + t1)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if (t1 <= -5e-30) tmp = (-1.0 * v) / (-u + t1); elseif (t1 <= 1.9e-62) tmp = v * (-t1 / (u * u)); else tmp = -v / (u + t1); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[LessEqual[t1, -5e-30], N[(N[(-1.0 * v), $MachinePrecision] / N[((-u) + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 1.9e-62], N[(v * N[((-t1) / N[(u * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -5 \cdot 10^{-30}:\\
\;\;\;\;\frac{-1 \cdot v}{\left(-u\right) + t1}\\
\mathbf{elif}\;t1 \leq 1.9 \cdot 10^{-62}:\\
\;\;\;\;v \cdot \frac{-t1}{u \cdot u}\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{u + t1}\\
\end{array}
\end{array}
if t1 < -4.99999999999999972e-30Initial program 68.6%
Applied rewrites99.4%
Taylor expanded in u around 0
Applied rewrites84.4%
if -4.99999999999999972e-30 < t1 < 1.90000000000000003e-62Initial program 80.6%
Taylor expanded in u around inf
unpow2N/A
lower-*.f6470.4
Applied rewrites70.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6474.9
Applied rewrites74.9%
if 1.90000000000000003e-62 < t1 Initial program 64.3%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6467.2
Applied rewrites67.2%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites72.5%
Final simplification76.5%
(FPCore (u v t1) :precision binary64 (if (<= t1 -5e-30) (/ (* -1.0 v) (+ (- u) t1)) (if (<= t1 1.9e-62) (* (- t1) (/ v (* u u))) (/ (- v) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -5e-30) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 1.9e-62) {
tmp = -t1 * (v / (u * u));
} else {
tmp = -v / (u + t1);
}
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(u, v, t1)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: t1
real(8) :: tmp
if (t1 <= (-5d-30)) then
tmp = ((-1.0d0) * v) / (-u + t1)
else if (t1 <= 1.9d-62) then
tmp = -t1 * (v / (u * u))
else
tmp = -v / (u + t1)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if (t1 <= -5e-30) {
tmp = (-1.0 * v) / (-u + t1);
} else if (t1 <= 1.9e-62) {
tmp = -t1 * (v / (u * u));
} else {
tmp = -v / (u + t1);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if t1 <= -5e-30: tmp = (-1.0 * v) / (-u + t1) elif t1 <= 1.9e-62: tmp = -t1 * (v / (u * u)) else: tmp = -v / (u + t1) return tmp
function code(u, v, t1) tmp = 0.0 if (t1 <= -5e-30) tmp = Float64(Float64(-1.0 * v) / Float64(Float64(-u) + t1)); elseif (t1 <= 1.9e-62) tmp = Float64(Float64(-t1) * Float64(v / Float64(u * u))); else tmp = Float64(Float64(-v) / Float64(u + t1)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if (t1 <= -5e-30) tmp = (-1.0 * v) / (-u + t1); elseif (t1 <= 1.9e-62) tmp = -t1 * (v / (u * u)); else tmp = -v / (u + t1); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[LessEqual[t1, -5e-30], N[(N[(-1.0 * v), $MachinePrecision] / N[((-u) + t1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t1, 1.9e-62], N[((-t1) * N[(v / N[(u * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -5 \cdot 10^{-30}:\\
\;\;\;\;\frac{-1 \cdot v}{\left(-u\right) + t1}\\
\mathbf{elif}\;t1 \leq 1.9 \cdot 10^{-62}:\\
\;\;\;\;\left(-t1\right) \cdot \frac{v}{u \cdot u}\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{u + t1}\\
\end{array}
\end{array}
if t1 < -4.99999999999999972e-30Initial program 68.6%
Applied rewrites99.4%
Taylor expanded in u around 0
Applied rewrites84.4%
if -4.99999999999999972e-30 < t1 < 1.90000000000000003e-62Initial program 80.6%
Applied rewrites94.9%
Taylor expanded in u around inf
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6474.6
Applied rewrites74.6%
if 1.90000000000000003e-62 < t1 Initial program 64.3%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6467.2
Applied rewrites67.2%
Applied rewrites99.9%
Taylor expanded in u around 0
Applied rewrites72.5%
Final simplification76.4%
(FPCore (u v t1) :precision binary64 (/ (* -1.0 v) (+ (- u) t1)))
double code(double u, double v, double t1) {
return (-1.0 * v) / (-u + t1);
}
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 = ((-1.0d0) * v) / (-u + t1)
end function
public static double code(double u, double v, double t1) {
return (-1.0 * v) / (-u + t1);
}
def code(u, v, t1): return (-1.0 * v) / (-u + t1)
function code(u, v, t1) return Float64(Float64(-1.0 * v) / Float64(Float64(-u) + t1)) end
function tmp = code(u, v, t1) tmp = (-1.0 * v) / (-u + t1); end
code[u_, v_, t1_] := N[(N[(-1.0 * v), $MachinePrecision] / N[((-u) + t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1 \cdot v}{\left(-u\right) + t1}
\end{array}
Initial program 72.4%
Applied rewrites97.0%
Taylor expanded in u around 0
Applied rewrites58.9%
Final simplification58.9%
(FPCore (u v t1) :precision binary64 (/ (- v) (+ u t1)))
double code(double u, double v, double t1) {
return -v / (u + t1);
}
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 = -v / (u + t1)
end function
public static double code(double u, double v, double t1) {
return -v / (u + t1);
}
def code(u, v, t1): return -v / (u + t1)
function code(u, v, t1) return Float64(Float64(-v) / Float64(u + t1)) end
function tmp = code(u, v, t1) tmp = -v / (u + t1); end
code[u_, v_, t1_] := N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-v}{u + t1}
\end{array}
Initial program 72.4%
Taylor expanded in v around 0
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6475.9
Applied rewrites75.9%
Applied rewrites98.5%
Taylor expanded in u around 0
Applied rewrites58.7%
(FPCore (u v t1) :precision binary64 (/ (- v) t1))
double code(double u, double v, double t1) {
return -v / t1;
}
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 = -v / t1
end function
public static double code(double u, double v, double t1) {
return -v / t1;
}
def code(u, v, t1): return -v / t1
function code(u, v, t1) return Float64(Float64(-v) / t1) end
function tmp = code(u, v, t1) tmp = -v / t1; end
code[u_, v_, t1_] := N[((-v) / t1), $MachinePrecision]
\begin{array}{l}
\\
\frac{-v}{t1}
\end{array}
Initial program 72.4%
Taylor expanded in u around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6452.4
Applied rewrites52.4%
herbie shell --seed 2024350
(FPCore (u v t1)
:name "Rosa's DopplerBench"
:precision binary64
(/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))