
(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) (* -1.0 (+ u t1))))
double code(double u, double v, double t1) {
return ((t1 / (u + t1)) * v) / (-1.0 * (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) / ((-1.0d0) * (u + t1))
end function
public static double code(double u, double v, double t1) {
return ((t1 / (u + t1)) * v) / (-1.0 * (u + t1));
}
def code(u, v, t1): return ((t1 / (u + t1)) * v) / (-1.0 * (u + t1))
function code(u, v, t1) return Float64(Float64(Float64(t1 / Float64(u + t1)) * v) / Float64(-1.0 * Float64(u + t1))) end
function tmp = code(u, v, t1) tmp = ((t1 / (u + t1)) * v) / (-1.0 * (u + t1)); end
code[u_, v_, t1_] := N[(N[(N[(t1 / N[(u + t1), $MachinePrecision]), $MachinePrecision] * v), $MachinePrecision] / N[(-1.0 * N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{t1}{u + t1} \cdot v}{-1 \cdot \left(u + t1\right)}
\end{array}
Initial program 71.5%
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
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6498.0
Applied rewrites98.0%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
lift-+.f6498.3
Applied rewrites98.3%
Final simplification98.3%
(FPCore (u v t1) :precision binary64 (/ (* (/ (* -1.0 t1) (* (+ (/ u t1) 1.0) t1)) v) (+ u t1)))
double code(double u, double v, double t1) {
return (((-1.0 * t1) / (((u / t1) + 1.0) * 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 = ((((-1.0d0) * t1) / (((u / t1) + 1.0d0) * t1)) * v) / (u + t1)
end function
public static double code(double u, double v, double t1) {
return (((-1.0 * t1) / (((u / t1) + 1.0) * t1)) * v) / (u + t1);
}
def code(u, v, t1): return (((-1.0 * t1) / (((u / t1) + 1.0) * t1)) * v) / (u + t1)
function code(u, v, t1) return Float64(Float64(Float64(Float64(-1.0 * t1) / Float64(Float64(Float64(u / t1) + 1.0) * t1)) * v) / Float64(u + t1)) end
function tmp = code(u, v, t1) tmp = (((-1.0 * t1) / (((u / t1) + 1.0) * t1)) * v) / (u + t1); end
code[u_, v_, t1_] := N[(N[(N[(N[(-1.0 * t1), $MachinePrecision] / N[(N[(N[(u / t1), $MachinePrecision] + 1.0), $MachinePrecision] * t1), $MachinePrecision]), $MachinePrecision] * v), $MachinePrecision] / N[(u + t1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1 \cdot t1}{\left(\frac{u}{t1} + 1\right) \cdot t1} \cdot v}{u + t1}
\end{array}
Initial program 71.5%
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
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6498.0
Applied rewrites98.0%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-+.f64N/A
lift-+.f6498.3
Applied rewrites98.3%
Taylor expanded in t1 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f6498.3
Applied rewrites98.3%
Final simplification98.3%
(FPCore (u v t1) :precision binary64 (* (/ t1 (+ u t1)) (/ (* -1.0 v) (* (+ (/ u t1) 1.0) t1))))
double code(double u, double v, double t1) {
return (t1 / (u + t1)) * ((-1.0 * v) / (((u / t1) + 1.0) * 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)) * (((-1.0d0) * v) / (((u / t1) + 1.0d0) * t1))
end function
public static double code(double u, double v, double t1) {
return (t1 / (u + t1)) * ((-1.0 * v) / (((u / t1) + 1.0) * t1));
}
def code(u, v, t1): return (t1 / (u + t1)) * ((-1.0 * v) / (((u / t1) + 1.0) * t1))
function code(u, v, t1) return Float64(Float64(t1 / Float64(u + t1)) * Float64(Float64(-1.0 * v) / Float64(Float64(Float64(u / t1) + 1.0) * t1))) end
function tmp = code(u, v, t1) tmp = (t1 / (u + t1)) * ((-1.0 * v) / (((u / t1) + 1.0) * t1)); end
code[u_, v_, t1_] := N[(N[(t1 / N[(u + t1), $MachinePrecision]), $MachinePrecision] * N[(N[(-1.0 * v), $MachinePrecision] / N[(N[(N[(u / t1), $MachinePrecision] + 1.0), $MachinePrecision] * t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{t1}{u + t1} \cdot \frac{-1 \cdot v}{\left(\frac{u}{t1} + 1\right) \cdot t1}
\end{array}
Initial program 71.5%
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
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6498.0
Applied rewrites98.0%
Taylor expanded in t1 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
Final simplification98.0%
(FPCore (u v t1) :precision binary64 (if (<= t1 4.2e+194) (* (/ t1 (+ u t1)) (/ (* -1.0 v) (* (+ (/ t1 u) 1.0) u))) (fma (/ 2.0 t1) (* u (/ v t1)) (* (/ v t1) -1.0))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= 4.2e+194) {
tmp = (t1 / (u + t1)) * ((-1.0 * v) / (((t1 / u) + 1.0) * u));
} else {
tmp = fma((2.0 / t1), (u * (v / t1)), ((v / t1) * -1.0));
}
return tmp;
}
function code(u, v, t1) tmp = 0.0 if (t1 <= 4.2e+194) tmp = Float64(Float64(t1 / Float64(u + t1)) * Float64(Float64(-1.0 * v) / Float64(Float64(Float64(t1 / u) + 1.0) * u))); else tmp = fma(Float64(2.0 / t1), Float64(u * Float64(v / t1)), Float64(Float64(v / t1) * -1.0)); end return tmp end
code[u_, v_, t1_] := If[LessEqual[t1, 4.2e+194], N[(N[(t1 / N[(u + t1), $MachinePrecision]), $MachinePrecision] * N[(N[(-1.0 * v), $MachinePrecision] / N[(N[(N[(t1 / u), $MachinePrecision] + 1.0), $MachinePrecision] * u), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / t1), $MachinePrecision] * N[(u * N[(v / t1), $MachinePrecision]), $MachinePrecision] + N[(N[(v / t1), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq 4.2 \cdot 10^{+194}:\\
\;\;\;\;\frac{t1}{u + t1} \cdot \frac{-1 \cdot v}{\left(\frac{t1}{u} + 1\right) \cdot u}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{2}{t1}, u \cdot \frac{v}{t1}, \frac{v}{t1} \cdot -1\right)\\
\end{array}
\end{array}
if t1 < 4.20000000000000032e194Initial program 75.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
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6497.8
Applied rewrites97.8%
Taylor expanded in u around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f6493.1
Applied rewrites93.1%
if 4.20000000000000032e194 < t1 Initial program 38.9%
Taylor expanded in u around 0
+-commutativeN/A
associate-*r/N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6496.3
Applied rewrites96.3%
Final simplification93.4%
(FPCore (u v t1)
:precision binary64
(if (<= t1 -7.2e+138)
(* (- (* (/ u (* t1 t1)) 2.0) (pow t1 -1.0)) v)
(if (<= t1 7.5e+113)
(* (* -1.0 t1) (/ v (pow (+ u t1) 2.0)))
(fma (/ 2.0 t1) (* u (/ v t1)) (* (/ v t1) -1.0)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -7.2e+138) {
tmp = (((u / (t1 * t1)) * 2.0) - pow(t1, -1.0)) * v;
} else if (t1 <= 7.5e+113) {
tmp = (-1.0 * t1) * (v / pow((u + t1), 2.0));
} else {
tmp = fma((2.0 / t1), (u * (v / t1)), ((v / t1) * -1.0));
}
return tmp;
}
function code(u, v, t1) tmp = 0.0 if (t1 <= -7.2e+138) tmp = Float64(Float64(Float64(Float64(u / Float64(t1 * t1)) * 2.0) - (t1 ^ -1.0)) * v); elseif (t1 <= 7.5e+113) tmp = Float64(Float64(-1.0 * t1) * Float64(v / (Float64(u + t1) ^ 2.0))); else tmp = fma(Float64(2.0 / t1), Float64(u * Float64(v / t1)), Float64(Float64(v / t1) * -1.0)); end return tmp end
code[u_, v_, t1_] := If[LessEqual[t1, -7.2e+138], N[(N[(N[(N[(u / N[(t1 * t1), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] - N[Power[t1, -1.0], $MachinePrecision]), $MachinePrecision] * v), $MachinePrecision], If[LessEqual[t1, 7.5e+113], N[(N[(-1.0 * t1), $MachinePrecision] * N[(v / N[Power[N[(u + t1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / t1), $MachinePrecision] * N[(u * N[(v / t1), $MachinePrecision]), $MachinePrecision] + N[(N[(v / t1), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -7.2 \cdot 10^{+138}:\\
\;\;\;\;\left(\frac{u}{t1 \cdot t1} \cdot 2 - {t1}^{-1}\right) \cdot v\\
\mathbf{elif}\;t1 \leq 7.5 \cdot 10^{+113}:\\
\;\;\;\;\left(-1 \cdot t1\right) \cdot \frac{v}{{\left(u + t1\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{2}{t1}, u \cdot \frac{v}{t1}, \frac{v}{t1} \cdot -1\right)\\
\end{array}
\end{array}
if t1 < -7.2000000000000002e138Initial program 47.8%
Taylor expanded in u around 0
+-commutativeN/A
associate-*r/N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6481.3
Applied rewrites81.3%
Taylor expanded in v around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6483.2
Applied rewrites83.2%
if -7.2000000000000002e138 < t1 < 7.5000000000000001e113Initial program 82.3%
lift-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
+-commutativeN/A
lower-+.f6489.3
Applied rewrites89.3%
if 7.5000000000000001e113 < t1 Initial program 48.3%
Taylor expanded in u around 0
+-commutativeN/A
associate-*r/N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.0
Applied rewrites87.0%
(FPCore (u v t1)
:precision binary64
(if (<= t1 -1.9e-15)
(* (- (* (/ u (* t1 t1)) 2.0) (pow t1 -1.0)) v)
(if (<= t1 1.32e+16)
(* (* (- (/ t1 (* u u)) (pow u -1.0)) t1) (/ v (+ u t1)))
(fma (/ 2.0 t1) (* u (/ v t1)) (* (/ v t1) -1.0)))))
double code(double u, double v, double t1) {
double tmp;
if (t1 <= -1.9e-15) {
tmp = (((u / (t1 * t1)) * 2.0) - pow(t1, -1.0)) * v;
} else if (t1 <= 1.32e+16) {
tmp = (((t1 / (u * u)) - pow(u, -1.0)) * t1) * (v / (u + t1));
} else {
tmp = fma((2.0 / t1), (u * (v / t1)), ((v / t1) * -1.0));
}
return tmp;
}
function code(u, v, t1) tmp = 0.0 if (t1 <= -1.9e-15) tmp = Float64(Float64(Float64(Float64(u / Float64(t1 * t1)) * 2.0) - (t1 ^ -1.0)) * v); elseif (t1 <= 1.32e+16) tmp = Float64(Float64(Float64(Float64(t1 / Float64(u * u)) - (u ^ -1.0)) * t1) * Float64(v / Float64(u + t1))); else tmp = fma(Float64(2.0 / t1), Float64(u * Float64(v / t1)), Float64(Float64(v / t1) * -1.0)); end return tmp end
code[u_, v_, t1_] := If[LessEqual[t1, -1.9e-15], N[(N[(N[(N[(u / N[(t1 * t1), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] - N[Power[t1, -1.0], $MachinePrecision]), $MachinePrecision] * v), $MachinePrecision], If[LessEqual[t1, 1.32e+16], N[(N[(N[(N[(t1 / N[(u * u), $MachinePrecision]), $MachinePrecision] - N[Power[u, -1.0], $MachinePrecision]), $MachinePrecision] * t1), $MachinePrecision] * N[(v / N[(u + t1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / t1), $MachinePrecision] * N[(u * N[(v / t1), $MachinePrecision]), $MachinePrecision] + N[(N[(v / t1), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t1 \leq -1.9 \cdot 10^{-15}:\\
\;\;\;\;\left(\frac{u}{t1 \cdot t1} \cdot 2 - {t1}^{-1}\right) \cdot v\\
\mathbf{elif}\;t1 \leq 1.32 \cdot 10^{+16}:\\
\;\;\;\;\left(\left(\frac{t1}{u \cdot u} - {u}^{-1}\right) \cdot t1\right) \cdot \frac{v}{u + t1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{2}{t1}, u \cdot \frac{v}{t1}, \frac{v}{t1} \cdot -1\right)\\
\end{array}
\end{array}
if t1 < -1.9000000000000001e-15Initial program 58.2%
Taylor expanded in u around 0
+-commutativeN/A
associate-*r/N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.0
Applied rewrites80.0%
Taylor expanded in v around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6480.9
Applied rewrites80.9%
if -1.9000000000000001e-15 < t1 < 1.32e16Initial program 84.4%
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
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6496.2
Applied rewrites96.2%
Taylor expanded in t1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6478.5
Applied rewrites78.5%
if 1.32e16 < t1 Initial program 56.4%
Taylor expanded in u around 0
+-commutativeN/A
associate-*r/N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6483.4
Applied rewrites83.4%
(FPCore (u v t1) :precision binary64 (fma (/ 2.0 t1) (* u (/ v t1)) (* (/ v t1) -1.0)))
double code(double u, double v, double t1) {
return fma((2.0 / t1), (u * (v / t1)), ((v / t1) * -1.0));
}
function code(u, v, t1) return fma(Float64(2.0 / t1), Float64(u * Float64(v / t1)), Float64(Float64(v / t1) * -1.0)) end
code[u_, v_, t1_] := N[(N[(2.0 / t1), $MachinePrecision] * N[(u * N[(v / t1), $MachinePrecision]), $MachinePrecision] + N[(N[(v / t1), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{2}{t1}, u \cdot \frac{v}{t1}, \frac{v}{t1} \cdot -1\right)
\end{array}
Initial program 71.5%
Taylor expanded in u around 0
+-commutativeN/A
associate-*r/N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6447.1
Applied rewrites47.1%
(FPCore (u v t1) :precision binary64 (* (- (* (/ u (* t1 t1)) 2.0) (pow t1 -1.0)) v))
double code(double u, double v, double t1) {
return (((u / (t1 * t1)) * 2.0) - pow(t1, -1.0)) * v;
}
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 = (((u / (t1 * t1)) * 2.0d0) - (t1 ** (-1.0d0))) * v
end function
public static double code(double u, double v, double t1) {
return (((u / (t1 * t1)) * 2.0) - Math.pow(t1, -1.0)) * v;
}
def code(u, v, t1): return (((u / (t1 * t1)) * 2.0) - math.pow(t1, -1.0)) * v
function code(u, v, t1) return Float64(Float64(Float64(Float64(u / Float64(t1 * t1)) * 2.0) - (t1 ^ -1.0)) * v) end
function tmp = code(u, v, t1) tmp = (((u / (t1 * t1)) * 2.0) - (t1 ^ -1.0)) * v; end
code[u_, v_, t1_] := N[(N[(N[(N[(u / N[(t1 * t1), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] - N[Power[t1, -1.0], $MachinePrecision]), $MachinePrecision] * v), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{u}{t1 \cdot t1} \cdot 2 - {t1}^{-1}\right) \cdot v
\end{array}
Initial program 71.5%
Taylor expanded in u around 0
+-commutativeN/A
associate-*r/N/A
unpow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6447.1
Applied rewrites47.1%
Taylor expanded in v around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6446.3
Applied rewrites46.3%
herbie shell --seed 2025065
(FPCore (u v t1)
:name "Rosa's DopplerBench"
:precision binary64
(/ (* (- t1) v) (* (+ t1 u) (+ t1 u))))