
(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 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}
(FPCore (u v t1) :precision binary64 (* (/ (- t1) (+ u t1)) (/ v (+ u t1))))
double code(double u, double v, double t1) {
return (-t1 / (u + t1)) * (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 = (-t1 / (u + t1)) * (v / (u + t1))
end function
public static double code(double u, double v, double t1) {
return (-t1 / (u + t1)) * (v / (u + t1));
}
def code(u, v, t1): return (-t1 / (u + t1)) * (v / (u + t1))
function code(u, v, t1) return Float64(Float64(Float64(-t1) / Float64(u + t1)) * Float64(v / Float64(u + t1))) end
function tmp = code(u, v, t1) tmp = (-t1 / (u + t1)) * (v / (u + t1)); end
code[u_, v_, t1_] := N[(N[((-t1) / N[(u + t1), $MachinePrecision]), $MachinePrecision] * N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-t1}{u + t1} \cdot \frac{v}{u + t1}
\end{array}
Initial program 76.3%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6499.0
Applied rewrites99.0%
(FPCore (u v t1) :precision binary64 (if (or (<= t1 -1.02e+77) (not (<= t1 3.3e+33))) (/ (- v) (+ u t1)) (* (- t1) (/ (/ v (+ u t1)) (+ u t1)))))
double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -1.02e+77) || !(t1 <= 3.3e+33)) {
tmp = -v / (u + t1);
} else {
tmp = -t1 * ((v / (u + t1)) / (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 <= (-1.02d+77)) .or. (.not. (t1 <= 3.3d+33))) then
tmp = -v / (u + t1)
else
tmp = -t1 * ((v / (u + t1)) / (u + t1))
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -1.02e+77) || !(t1 <= 3.3e+33)) {
tmp = -v / (u + t1);
} else {
tmp = -t1 * ((v / (u + t1)) / (u + t1));
}
return tmp;
}
def code(u, v, t1): tmp = 0 if (t1 <= -1.02e+77) or not (t1 <= 3.3e+33): tmp = -v / (u + t1) else: tmp = -t1 * ((v / (u + t1)) / (u + t1)) return tmp
function code(u, v, t1) tmp = 0.0 if ((t1 <= -1.02e+77) || !(t1 <= 3.3e+33)) tmp = Float64(Float64(-v) / Float64(u + t1)); else tmp = Float64(Float64(-t1) * Float64(Float64(v / Float64(u + t1)) / Float64(u + t1))); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if ((t1 <= -1.02e+77) || ~((t1 <= 3.3e+33))) tmp = -v / (u + t1); else tmp = -t1 * ((v / (u + t1)) / (u + t1)); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[Or[LessEqual[t1, -1.02e+77], N[Not[LessEqual[t1, 3.3e+33]], $MachinePrecision]], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision], N[((-t1) * N[(N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -1.02 \cdot 10^{+77} \lor \neg \left(t1 \leq 3.3 \cdot 10^{+33}\right):\\
\;\;\;\;\frac{-v}{u + t1}\\
\mathbf{else}:\\
\;\;\;\;\left(-t1\right) \cdot \frac{\frac{v}{u + t1}}{u + t1}\\
\end{array}
\end{array}
if t1 < -1.02e77 or 3.29999999999999976e33 < t1 Initial program 61.0%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6474.2
Applied rewrites74.2%
Taylor expanded in u around 0
mul-1-negN/A
lift-neg.f6492.0
Applied rewrites92.0%
if -1.02e77 < t1 < 3.29999999999999976e33Initial program 87.6%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6498.3
Applied rewrites98.3%
lift-*.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f6497.4
Applied rewrites97.4%
lift-+.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-+.f6491.3
Applied rewrites91.3%
Final simplification91.6%
(FPCore (u v t1) :precision binary64 (if (or (<= t1 -1.7e+36) (not (<= t1 3.6e+94))) (/ (- v) (+ u t1)) (/ (* (- t1) v) (* (+ t1 u) (+ t1 u)))))
double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -1.7e+36) || !(t1 <= 3.6e+94)) {
tmp = -v / (u + t1);
} else {
tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
}
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 <= (-1.7d+36)) .or. (.not. (t1 <= 3.6d+94))) then
tmp = -v / (u + t1)
else
tmp = (-t1 * v) / ((t1 + u) * (t1 + u))
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -1.7e+36) || !(t1 <= 3.6e+94)) {
tmp = -v / (u + t1);
} else {
tmp = (-t1 * v) / ((t1 + u) * (t1 + u));
}
return tmp;
}
def code(u, v, t1): tmp = 0 if (t1 <= -1.7e+36) or not (t1 <= 3.6e+94): tmp = -v / (u + t1) else: tmp = (-t1 * v) / ((t1 + u) * (t1 + u)) return tmp
function code(u, v, t1) tmp = 0.0 if ((t1 <= -1.7e+36) || !(t1 <= 3.6e+94)) tmp = Float64(Float64(-v) / Float64(u + t1)); else tmp = Float64(Float64(Float64(-t1) * v) / Float64(Float64(t1 + u) * Float64(t1 + u))); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if ((t1 <= -1.7e+36) || ~((t1 <= 3.6e+94))) tmp = -v / (u + t1); else tmp = (-t1 * v) / ((t1 + u) * (t1 + u)); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[Or[LessEqual[t1, -1.7e+36], N[Not[LessEqual[t1, 3.6e+94]], $MachinePrecision]], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision], N[(N[((-t1) * v), $MachinePrecision] / N[(N[(t1 + u), $MachinePrecision] * N[(t1 + u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -1.7 \cdot 10^{+36} \lor \neg \left(t1 \leq 3.6 \cdot 10^{+94}\right):\\
\;\;\;\;\frac{-v}{u + t1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-t1\right) \cdot v}{\left(t1 + u\right) \cdot \left(t1 + u\right)}\\
\end{array}
\end{array}
if t1 < -1.6999999999999999e36 or 3.59999999999999992e94 < t1 Initial program 56.4%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6471.4
Applied rewrites71.4%
Taylor expanded in u around 0
mul-1-negN/A
lift-neg.f6490.4
Applied rewrites90.4%
if -1.6999999999999999e36 < t1 < 3.59999999999999992e94Initial program 89.4%
Final simplification89.8%
(FPCore (u v t1) :precision binary64 (if (or (<= t1 -2.2e-67) (not (<= t1 1.05e+33))) (/ (- v) (+ u t1)) (* (/ (- v) u) (/ t1 u))))
double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -2.2e-67) || !(t1 <= 1.05e+33)) {
tmp = -v / (u + t1);
} else {
tmp = (-v / u) * (t1 / u);
}
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.2d-67)) .or. (.not. (t1 <= 1.05d+33))) then
tmp = -v / (u + t1)
else
tmp = (-v / u) * (t1 / u)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -2.2e-67) || !(t1 <= 1.05e+33)) {
tmp = -v / (u + t1);
} else {
tmp = (-v / u) * (t1 / u);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if (t1 <= -2.2e-67) or not (t1 <= 1.05e+33): tmp = -v / (u + t1) else: tmp = (-v / u) * (t1 / u) return tmp
function code(u, v, t1) tmp = 0.0 if ((t1 <= -2.2e-67) || !(t1 <= 1.05e+33)) tmp = Float64(Float64(-v) / Float64(u + t1)); else tmp = Float64(Float64(Float64(-v) / u) * Float64(t1 / u)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if ((t1 <= -2.2e-67) || ~((t1 <= 1.05e+33))) tmp = -v / (u + t1); else tmp = (-v / u) * (t1 / u); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[Or[LessEqual[t1, -2.2e-67], N[Not[LessEqual[t1, 1.05e+33]], $MachinePrecision]], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision], N[(N[((-v) / u), $MachinePrecision] * N[(t1 / u), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -2.2 \cdot 10^{-67} \lor \neg \left(t1 \leq 1.05 \cdot 10^{+33}\right):\\
\;\;\;\;\frac{-v}{u + t1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-v}{u} \cdot \frac{t1}{u}\\
\end{array}
\end{array}
if t1 < -2.2000000000000001e-67 or 1.05e33 < t1 Initial program 66.6%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6478.5
Applied rewrites78.5%
Taylor expanded in u around 0
mul-1-negN/A
lift-neg.f6489.8
Applied rewrites89.8%
if -2.2000000000000001e-67 < t1 < 1.05e33Initial program 87.2%
Taylor expanded in u around inf
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
unpow2N/A
times-fracN/A
mul-1-negN/A
associate-*r/N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6481.2
Applied rewrites81.2%
Final simplification85.8%
(FPCore (u v t1) :precision binary64 (if (or (<= t1 -2.2e-67) (not (<= t1 9.5e-6))) (/ (- v) (+ u t1)) (* (- t1) (/ (/ v u) u))))
double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -2.2e-67) || !(t1 <= 9.5e-6)) {
tmp = -v / (u + t1);
} else {
tmp = -t1 * ((v / u) / u);
}
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.2d-67)) .or. (.not. (t1 <= 9.5d-6))) then
tmp = -v / (u + t1)
else
tmp = -t1 * ((v / u) / u)
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -2.2e-67) || !(t1 <= 9.5e-6)) {
tmp = -v / (u + t1);
} else {
tmp = -t1 * ((v / u) / u);
}
return tmp;
}
def code(u, v, t1): tmp = 0 if (t1 <= -2.2e-67) or not (t1 <= 9.5e-6): tmp = -v / (u + t1) else: tmp = -t1 * ((v / u) / u) return tmp
function code(u, v, t1) tmp = 0.0 if ((t1 <= -2.2e-67) || !(t1 <= 9.5e-6)) tmp = Float64(Float64(-v) / Float64(u + t1)); else tmp = Float64(Float64(-t1) * Float64(Float64(v / u) / u)); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if ((t1 <= -2.2e-67) || ~((t1 <= 9.5e-6))) tmp = -v / (u + t1); else tmp = -t1 * ((v / u) / u); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[Or[LessEqual[t1, -2.2e-67], N[Not[LessEqual[t1, 9.5e-6]], $MachinePrecision]], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision], N[((-t1) * N[(N[(v / u), $MachinePrecision] / u), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -2.2 \cdot 10^{-67} \lor \neg \left(t1 \leq 9.5 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{-v}{u + t1}\\
\mathbf{else}:\\
\;\;\;\;\left(-t1\right) \cdot \frac{\frac{v}{u}}{u}\\
\end{array}
\end{array}
if t1 < -2.2000000000000001e-67 or 9.5000000000000005e-6 < t1 Initial program 67.7%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6479.2
Applied rewrites79.2%
Taylor expanded in u around 0
mul-1-negN/A
lift-neg.f6487.2
Applied rewrites87.2%
if -2.2000000000000001e-67 < t1 < 9.5000000000000005e-6Initial program 87.5%
Taylor expanded in u around inf
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
unpow2N/A
times-fracN/A
mul-1-negN/A
associate-*r/N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6483.1
Applied rewrites83.1%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
unpow2N/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6478.6
Applied rewrites78.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6480.4
Applied rewrites80.4%
Final simplification84.3%
(FPCore (u v t1) :precision binary64 (if (or (<= t1 -2.2e-67) (not (<= t1 7.5e-10))) (/ (- v) (+ u t1)) (* (- t1) (/ v (* u u)))))
double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -2.2e-67) || !(t1 <= 7.5e-10)) {
tmp = -v / (u + t1);
} else {
tmp = -t1 * (v / (u * u));
}
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.2d-67)) .or. (.not. (t1 <= 7.5d-10))) then
tmp = -v / (u + t1)
else
tmp = -t1 * (v / (u * u))
end if
code = tmp
end function
public static double code(double u, double v, double t1) {
double tmp;
if ((t1 <= -2.2e-67) || !(t1 <= 7.5e-10)) {
tmp = -v / (u + t1);
} else {
tmp = -t1 * (v / (u * u));
}
return tmp;
}
def code(u, v, t1): tmp = 0 if (t1 <= -2.2e-67) or not (t1 <= 7.5e-10): tmp = -v / (u + t1) else: tmp = -t1 * (v / (u * u)) return tmp
function code(u, v, t1) tmp = 0.0 if ((t1 <= -2.2e-67) || !(t1 <= 7.5e-10)) tmp = Float64(Float64(-v) / Float64(u + t1)); else tmp = Float64(Float64(-t1) * Float64(v / Float64(u * u))); end return tmp end
function tmp_2 = code(u, v, t1) tmp = 0.0; if ((t1 <= -2.2e-67) || ~((t1 <= 7.5e-10))) tmp = -v / (u + t1); else tmp = -t1 * (v / (u * u)); end tmp_2 = tmp; end
code[u_, v_, t1_] := If[Or[LessEqual[t1, -2.2e-67], N[Not[LessEqual[t1, 7.5e-10]], $MachinePrecision]], N[((-v) / N[(u + t1), $MachinePrecision]), $MachinePrecision], N[((-t1) * N[(v / N[(u * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -2.2 \cdot 10^{-67} \lor \neg \left(t1 \leq 7.5 \cdot 10^{-10}\right):\\
\;\;\;\;\frac{-v}{u + t1}\\
\mathbf{else}:\\
\;\;\;\;\left(-t1\right) \cdot \frac{v}{u \cdot u}\\
\end{array}
\end{array}
if t1 < -2.2000000000000001e-67 or 7.49999999999999995e-10 < t1 Initial program 67.7%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6479.2
Applied rewrites79.2%
Taylor expanded in u around 0
mul-1-negN/A
lift-neg.f6487.2
Applied rewrites87.2%
if -2.2000000000000001e-67 < t1 < 7.49999999999999995e-10Initial program 87.5%
Taylor expanded in u around inf
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
unpow2N/A
times-fracN/A
mul-1-negN/A
associate-*r/N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6483.1
Applied rewrites83.1%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
unpow2N/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6478.6
Applied rewrites78.6%
Final simplification83.5%
(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 76.3%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6484.5
Applied rewrites84.5%
Taylor expanded in u around 0
mul-1-negN/A
lift-neg.f6463.9
Applied rewrites63.9%
(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 76.3%
Taylor expanded in u around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6453.8
Applied rewrites53.8%
herbie shell --seed 2025057
(FPCore (u v t1)
:name "Rosa's DopplerBench"
:precision binary64
(/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))