
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))) (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
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(c0, w, h, d, d_1, m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))) (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
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(c0, w, h, d, d_1, m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}
M_m = (fabs.f64 M) (FPCore (c0 w h D d M_m) :precision binary64 (if (or (<= M_m 3e-192) (not (<= M_m 1.65e-86))) (* (/ c0 (* 2.0 w)) (/ (/ (* (* (/ c0 h) d) (* (/ d w) 2.0)) D) D)) (/ (* c0 (* (* -1.0 c0) 0.0)) (* w 2.0))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if ((M_m <= 3e-192) || !(M_m <= 1.65e-86)) {
tmp = (c0 / (2.0 * w)) * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D);
} else {
tmp = (c0 * ((-1.0 * c0) * 0.0)) / (w * 2.0);
}
return tmp;
}
M_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(c0, w, h, d, d_1, m_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
real(8) :: tmp
if ((m_m <= 3d-192) .or. (.not. (m_m <= 1.65d-86))) then
tmp = (c0 / (2.0d0 * w)) * (((((c0 / h) * d_1) * ((d_1 / w) * 2.0d0)) / d) / d)
else
tmp = (c0 * (((-1.0d0) * c0) * 0.0d0)) / (w * 2.0d0)
end if
code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if ((M_m <= 3e-192) || !(M_m <= 1.65e-86)) {
tmp = (c0 / (2.0 * w)) * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D);
} else {
tmp = (c0 * ((-1.0 * c0) * 0.0)) / (w * 2.0);
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): tmp = 0 if (M_m <= 3e-192) or not (M_m <= 1.65e-86): tmp = (c0 / (2.0 * w)) * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D) else: tmp = (c0 * ((-1.0 * c0) * 0.0)) / (w * 2.0) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) tmp = 0.0 if ((M_m <= 3e-192) || !(M_m <= 1.65e-86)) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(Float64(Float64(c0 / h) * d) * Float64(Float64(d / w) * 2.0)) / D) / D)); else tmp = Float64(Float64(c0 * Float64(Float64(-1.0 * c0) * 0.0)) / Float64(w * 2.0)); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) tmp = 0.0; if ((M_m <= 3e-192) || ~((M_m <= 1.65e-86))) tmp = (c0 / (2.0 * w)) * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D); else tmp = (c0 * ((-1.0 * c0) * 0.0)) / (w * 2.0); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := If[Or[LessEqual[M$95$m, 3e-192], N[Not[LessEqual[M$95$m, 1.65e-86]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(c0 / h), $MachinePrecision] * d), $MachinePrecision] * N[(N[(d / w), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * N[(N[(-1.0 * c0), $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 3 \cdot 10^{-192} \lor \neg \left(M\_m \leq 1.65 \cdot 10^{-86}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{\frac{\left(\frac{c0}{h} \cdot d\right) \cdot \left(\frac{d}{w} \cdot 2\right)}{D}}{D}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0 \cdot \left(\left(-1 \cdot c0\right) \cdot 0\right)}{w \cdot 2}\\
\end{array}
\end{array}
if M < 2.9999999999999999e-192 or 1.64999999999999993e-86 < M Initial program 20.6%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6436.7
Applied rewrites36.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6439.5
Applied rewrites39.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites46.6%
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
lift-/.f64N/A
lift-/.f64N/A
lift-*.f6450.2
Applied rewrites50.2%
if 2.9999999999999999e-192 < M < 1.64999999999999993e-86Initial program 14.1%
Taylor expanded in c0 around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites14.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites56.9%
Final simplification51.0%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (* c0 (/ d (* (* h w) D))))
(t_1 (/ c0 (* 2.0 w)))
(t_2 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<= (* t_1 (+ t_2 (sqrt (- (* t_2 t_2) (* M_m M_m))))) INFINITY)
(* t_1 (fma t_0 (/ d D) (* t_0 (/ d D))))
(* t_1 (/ (/ (* (* (/ c0 h) d) (* (/ d w) 2.0)) D) D)))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 * (d / ((h * w) * D));
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_1 * (t_2 + sqrt(((t_2 * t_2) - (M_m * M_m))))) <= ((double) INFINITY)) {
tmp = t_1 * fma(t_0, (d / D), (t_0 * (d / D)));
} else {
tmp = t_1 * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D);
}
return tmp;
}
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(c0 * Float64(d / Float64(Float64(h * w) * D))) t_1 = Float64(c0 / Float64(2.0 * w)) t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_1 * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M_m * M_m))))) <= Inf) tmp = Float64(t_1 * fma(t_0, Float64(d / D), Float64(t_0 * Float64(d / D)))); else tmp = Float64(t_1 * Float64(Float64(Float64(Float64(Float64(c0 / h) * d) * Float64(Float64(d / w) * 2.0)) / D) / D)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 * N[(d / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 * N[(t$95$2 + N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$1 * N[(t$95$0 * N[(d / D), $MachinePrecision] + N[(t$95$0 * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(N[(N[(N[(c0 / h), $MachinePrecision] * d), $MachinePrecision] * N[(N[(d / w), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := c0 \cdot \frac{d}{\left(h \cdot w\right) \cdot D}\\
t_1 := \frac{c0}{2 \cdot w}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t\_1 \cdot \left(t\_2 + \sqrt{t\_2 \cdot t\_2 - M\_m \cdot M\_m}\right) \leq \infty:\\
\;\;\;\;t\_1 \cdot \mathsf{fma}\left(t\_0, \frac{d}{D}, t\_0 \cdot \frac{d}{D}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{\frac{\left(\frac{c0}{h} \cdot d\right) \cdot \left(\frac{d}{w} \cdot 2\right)}{D}}{D}\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 72.6%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6471.3
Applied rewrites71.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6472.2
Applied rewrites72.2%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6476.7
Applied rewrites76.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
count-2-revN/A
Applied rewrites82.4%
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 0.0%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6419.8
Applied rewrites19.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6422.6
Applied rewrites22.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites35.8%
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
lift-/.f64N/A
lift-/.f64N/A
lift-*.f6438.0
Applied rewrites38.0%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w))) (t_1 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M_m M_m))))) 4e-219)
(* t_0 (/ (/ (* (* (* c0 d) d) 2.0) (* (* h w) D)) D))
(* t_0 (/ (/ (* (* (/ c0 h) d) (* (/ d w) 2.0)) D) D)))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= 4e-219) {
tmp = t_0 * (((((c0 * d) * d) * 2.0) / ((h * w) * D)) / D);
} else {
tmp = t_0 * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D);
}
return tmp;
}
M_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(c0, w, h, d, d_1, m_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = c0 / (2.0d0 * w)
t_1 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (m_m * m_m))))) <= 4d-219) then
tmp = t_0 * (((((c0 * d_1) * d_1) * 2.0d0) / ((h * w) * d)) / d)
else
tmp = t_0 * (((((c0 / h) * d_1) * ((d_1 / w) * 2.0d0)) / d) / d)
end if
code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= 4e-219) {
tmp = t_0 * (((((c0 * d) * d) * 2.0) / ((h * w) * D)) / D);
} else {
tmp = t_0 * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D);
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): t_0 = c0 / (2.0 * w) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= 4e-219: tmp = t_0 * (((((c0 * d) * d) * 2.0) / ((h * w) * D)) / D) else: tmp = t_0 * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(c0 / Float64(2.0 * w)) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M_m * M_m))))) <= 4e-219) tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(c0 * d) * d) * 2.0) / Float64(Float64(h * w) * D)) / D)); else tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(c0 / h) * d) * Float64(Float64(d / w) * 2.0)) / D) / D)); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) t_0 = c0 / (2.0 * w); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= 4e-219) tmp = t_0 * (((((c0 * d) * d) * 2.0) / ((h * w) * D)) / D); else tmp = t_0 * (((((c0 / h) * d) * ((d / w) * 2.0)) / D) / D); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e-219], N[(t$95$0 * N[(N[(N[(N[(N[(c0 * d), $MachinePrecision] * d), $MachinePrecision] * 2.0), $MachinePrecision] / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(N[(N[(c0 / h), $MachinePrecision] * d), $MachinePrecision] * N[(N[(d / w), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t\_0 \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M\_m \cdot M\_m}\right) \leq 4 \cdot 10^{-219}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{\left(\left(c0 \cdot d\right) \cdot d\right) \cdot 2}{\left(h \cdot w\right) \cdot D}}{D}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{\left(\frac{c0}{h} \cdot d\right) \cdot \left(\frac{d}{w} \cdot 2\right)}{D}}{D}\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < 4.0000000000000001e-219Initial program 64.9%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6462.9
Applied rewrites62.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6467.2
Applied rewrites67.2%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6473.6
Applied rewrites73.6%
if 4.0000000000000001e-219 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 10.5%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6427.9
Applied rewrites27.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6430.4
Applied rewrites30.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites41.9%
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
lift-/.f64N/A
lift-/.f64N/A
lift-*.f6444.3
Applied rewrites44.3%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w))))
(if (<= c0 1.8e+23)
(* t_0 (/ (* (/ c0 h) (/ (* (* (/ d w) 2.0) d) D)) D))
(if (<= c0 5.3e+70)
(*
(fma
(* (/ (* D D) (* c0 c0)) (* (* M_m M_m) (/ h (* d d))))
0.25
(/ 0.0 w))
(* c0 c0))
(* t_0 (/ (* 2.0 (* (* c0 d) d)) (* (* (* D h) w) D)))))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 / (2.0 * w);
double tmp;
if (c0 <= 1.8e+23) {
tmp = t_0 * (((c0 / h) * ((((d / w) * 2.0) * d) / D)) / D);
} else if (c0 <= 5.3e+70) {
tmp = fma((((D * D) / (c0 * c0)) * ((M_m * M_m) * (h / (d * d)))), 0.25, (0.0 / w)) * (c0 * c0);
} else {
tmp = t_0 * ((2.0 * ((c0 * d) * d)) / (((D * h) * w) * D));
}
return tmp;
}
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(c0 / Float64(2.0 * w)) tmp = 0.0 if (c0 <= 1.8e+23) tmp = Float64(t_0 * Float64(Float64(Float64(c0 / h) * Float64(Float64(Float64(Float64(d / w) * 2.0) * d) / D)) / D)); elseif (c0 <= 5.3e+70) tmp = Float64(fma(Float64(Float64(Float64(D * D) / Float64(c0 * c0)) * Float64(Float64(M_m * M_m) * Float64(h / Float64(d * d)))), 0.25, Float64(0.0 / w)) * Float64(c0 * c0)); else tmp = Float64(t_0 * Float64(Float64(2.0 * Float64(Float64(c0 * d) * d)) / Float64(Float64(Float64(D * h) * w) * D))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c0, 1.8e+23], N[(t$95$0 * N[(N[(N[(c0 / h), $MachinePrecision] * N[(N[(N[(N[(d / w), $MachinePrecision] * 2.0), $MachinePrecision] * d), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision], If[LessEqual[c0, 5.3e+70], N[(N[(N[(N[(N[(D * D), $MachinePrecision] / N[(c0 * c0), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25 + N[(0.0 / w), $MachinePrecision]), $MachinePrecision] * N[(c0 * c0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(2.0 * N[(N[(c0 * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(D * h), $MachinePrecision] * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;c0 \leq 1.8 \cdot 10^{+23}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{c0}{h} \cdot \frac{\left(\frac{d}{w} \cdot 2\right) \cdot d}{D}}{D}\\
\mathbf{elif}\;c0 \leq 5.3 \cdot 10^{+70}:\\
\;\;\;\;\mathsf{fma}\left(\frac{D \cdot D}{c0 \cdot c0} \cdot \left(\left(M\_m \cdot M\_m\right) \cdot \frac{h}{d \cdot d}\right), 0.25, \frac{0}{w}\right) \cdot \left(c0 \cdot c0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{2 \cdot \left(\left(c0 \cdot d\right) \cdot d\right)}{\left(\left(D \cdot h\right) \cdot w\right) \cdot D}\\
\end{array}
\end{array}
if c0 < 1.7999999999999999e23Initial program 17.4%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6433.1
Applied rewrites33.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6436.9
Applied rewrites36.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites47.6%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6448.6
Applied rewrites48.6%
if 1.7999999999999999e23 < c0 < 5.3e70Initial program 15.8%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6417.5
Applied rewrites17.5%
Taylor expanded in c0 around -inf
Applied rewrites61.9%
if 5.3e70 < c0 Initial program 28.9%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6440.4
Applied rewrites40.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6444.0
Applied rewrites44.0%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6447.7
Applied rewrites47.7%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w))) (t_1 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M_m M_m))))) INFINITY)
(* t_0 (/ (/ (* (* (* c0 d) d) 2.0) (* (* h w) D)) D))
(* t_0 (/ (* (/ c0 h) (/ (* (* (/ d w) 2.0) d) D)) D)))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= ((double) INFINITY)) {
tmp = t_0 * (((((c0 * d) * d) * 2.0) / ((h * w) * D)) / D);
} else {
tmp = t_0 * (((c0 / h) * ((((d / w) * 2.0) * d) / D)) / D);
}
return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= Double.POSITIVE_INFINITY) {
tmp = t_0 * (((((c0 * d) * d) * 2.0) / ((h * w) * D)) / D);
} else {
tmp = t_0 * (((c0 / h) * ((((d / w) * 2.0) * d) / D)) / D);
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): t_0 = c0 / (2.0 * w) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= math.inf: tmp = t_0 * (((((c0 * d) * d) * 2.0) / ((h * w) * D)) / D) else: tmp = t_0 * (((c0 / h) * ((((d / w) * 2.0) * d) / D)) / D) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(c0 / Float64(2.0 * w)) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M_m * M_m))))) <= Inf) tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(c0 * d) * d) * 2.0) / Float64(Float64(h * w) * D)) / D)); else tmp = Float64(t_0 * Float64(Float64(Float64(c0 / h) * Float64(Float64(Float64(Float64(d / w) * 2.0) * d) / D)) / D)); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) t_0 = c0 / (2.0 * w); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= Inf) tmp = t_0 * (((((c0 * d) * d) * 2.0) / ((h * w) * D)) / D); else tmp = t_0 * (((c0 / h) * ((((d / w) * 2.0) * d) / D)) / D); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(N[(N[(N[(N[(c0 * d), $MachinePrecision] * d), $MachinePrecision] * 2.0), $MachinePrecision] / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(c0 / h), $MachinePrecision] * N[(N[(N[(N[(d / w), $MachinePrecision] * 2.0), $MachinePrecision] * d), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t\_0 \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M\_m \cdot M\_m}\right) \leq \infty:\\
\;\;\;\;t\_0 \cdot \frac{\frac{\left(\left(c0 \cdot d\right) \cdot d\right) \cdot 2}{\left(h \cdot w\right) \cdot D}}{D}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{c0}{h} \cdot \frac{\left(\frac{d}{w} \cdot 2\right) \cdot d}{D}}{D}\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 72.6%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6471.3
Applied rewrites71.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6474.1
Applied rewrites74.1%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6478.5
Applied rewrites78.5%
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 0.0%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6419.8
Applied rewrites19.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6422.6
Applied rewrites22.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites35.8%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.3
Applied rewrites36.3%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(if (<= w 1.08e-26)
(* (/ c0 (* 2.0 w)) (/ (* 2.0 (* (* c0 d) d)) (* (* (* D h) w) D)))
(if (<= w 1.35e+146)
(*
(fma
(* (/ (* D D) (* c0 c0)) (* (* M_m M_m) (/ h (* d d))))
0.25
(/ 0.0 w))
(* c0 c0))
(* (* c0 c0) (* d (/ d (* (* (* D h) (* D w)) w)))))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if (w <= 1.08e-26) {
tmp = (c0 / (2.0 * w)) * ((2.0 * ((c0 * d) * d)) / (((D * h) * w) * D));
} else if (w <= 1.35e+146) {
tmp = fma((((D * D) / (c0 * c0)) * ((M_m * M_m) * (h / (d * d)))), 0.25, (0.0 / w)) * (c0 * c0);
} else {
tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w)));
}
return tmp;
}
M_m = abs(M) function code(c0, w, h, D, d, M_m) tmp = 0.0 if (w <= 1.08e-26) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(2.0 * Float64(Float64(c0 * d) * d)) / Float64(Float64(Float64(D * h) * w) * D))); elseif (w <= 1.35e+146) tmp = Float64(fma(Float64(Float64(Float64(D * D) / Float64(c0 * c0)) * Float64(Float64(M_m * M_m) * Float64(h / Float64(d * d)))), 0.25, Float64(0.0 / w)) * Float64(c0 * c0)); else tmp = Float64(Float64(c0 * c0) * Float64(d * Float64(d / Float64(Float64(Float64(D * h) * Float64(D * w)) * w)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := If[LessEqual[w, 1.08e-26], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * N[(N[(c0 * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(D * h), $MachinePrecision] * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[w, 1.35e+146], N[(N[(N[(N[(N[(D * D), $MachinePrecision] / N[(c0 * c0), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25 + N[(0.0 / w), $MachinePrecision]), $MachinePrecision] * N[(c0 * c0), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * c0), $MachinePrecision] * N[(d * N[(d / N[(N[(N[(D * h), $MachinePrecision] * N[(D * w), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
\mathbf{if}\;w \leq 1.08 \cdot 10^{-26}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(c0 \cdot d\right) \cdot d\right)}{\left(\left(D \cdot h\right) \cdot w\right) \cdot D}\\
\mathbf{elif}\;w \leq 1.35 \cdot 10^{+146}:\\
\;\;\;\;\mathsf{fma}\left(\frac{D \cdot D}{c0 \cdot c0} \cdot \left(\left(M\_m \cdot M\_m\right) \cdot \frac{h}{d \cdot d}\right), 0.25, \frac{0}{w}\right) \cdot \left(c0 \cdot c0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot h\right) \cdot \left(D \cdot w\right)\right) \cdot w}\right)\\
\end{array}
\end{array}
if w < 1.07999999999999996e-26Initial program 24.2%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6440.1
Applied rewrites40.1%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6441.0
Applied rewrites41.0%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6444.0
Applied rewrites44.0%
if 1.07999999999999996e-26 < w < 1.34999999999999994e146Initial program 0.5%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f647.4
Applied rewrites7.4%
Taylor expanded in c0 around -inf
Applied rewrites32.8%
if 1.34999999999999994e146 < w Initial program 12.8%
Taylor expanded in c0 around inf
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f649.4
Applied rewrites9.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-/.f64N/A
associate-*r*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6418.7
Applied rewrites18.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6434.9
Applied rewrites34.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
*-commutativeN/A
associate-*l*N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f6444.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.2
Applied rewrites44.2%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (pow (* d c0) 1.0)))
(if (or (<= c0 -3.2e-158) (not (<= c0 3.7e-177)))
(* (* c0 c0) (* d (/ d (* (* (* D h) (* D w)) w))))
(/ (/ (* t_0 t_0) (* D D)) (* (* w w) h)))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = pow((d * c0), 1.0);
double tmp;
if ((c0 <= -3.2e-158) || !(c0 <= 3.7e-177)) {
tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w)));
} else {
tmp = ((t_0 * t_0) / (D * D)) / ((w * w) * h);
}
return tmp;
}
M_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(c0, w, h, d, d_1, m_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
real(8) :: t_0
real(8) :: tmp
t_0 = (d_1 * c0) ** 1.0d0
if ((c0 <= (-3.2d-158)) .or. (.not. (c0 <= 3.7d-177))) then
tmp = (c0 * c0) * (d_1 * (d_1 / (((d * h) * (d * w)) * w)))
else
tmp = ((t_0 * t_0) / (d * d)) / ((w * w) * h)
end if
code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = Math.pow((d * c0), 1.0);
double tmp;
if ((c0 <= -3.2e-158) || !(c0 <= 3.7e-177)) {
tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w)));
} else {
tmp = ((t_0 * t_0) / (D * D)) / ((w * w) * h);
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): t_0 = math.pow((d * c0), 1.0) tmp = 0 if (c0 <= -3.2e-158) or not (c0 <= 3.7e-177): tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w))) else: tmp = ((t_0 * t_0) / (D * D)) / ((w * w) * h) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(d * c0) ^ 1.0 tmp = 0.0 if ((c0 <= -3.2e-158) || !(c0 <= 3.7e-177)) tmp = Float64(Float64(c0 * c0) * Float64(d * Float64(d / Float64(Float64(Float64(D * h) * Float64(D * w)) * w)))); else tmp = Float64(Float64(Float64(t_0 * t_0) / Float64(D * D)) / Float64(Float64(w * w) * h)); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) t_0 = (d * c0) ^ 1.0; tmp = 0.0; if ((c0 <= -3.2e-158) || ~((c0 <= 3.7e-177))) tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w))); else tmp = ((t_0 * t_0) / (D * D)) / ((w * w) * h); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[Power[N[(d * c0), $MachinePrecision], 1.0], $MachinePrecision]}, If[Or[LessEqual[c0, -3.2e-158], N[Not[LessEqual[c0, 3.7e-177]], $MachinePrecision]], N[(N[(c0 * c0), $MachinePrecision] * N[(d * N[(d / N[(N[(N[(D * h), $MachinePrecision] * N[(D * w), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] / N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(w * w), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := {\left(d \cdot c0\right)}^{1}\\
\mathbf{if}\;c0 \leq -3.2 \cdot 10^{-158} \lor \neg \left(c0 \leq 3.7 \cdot 10^{-177}\right):\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot h\right) \cdot \left(D \cdot w\right)\right) \cdot w}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0 \cdot t\_0}{D \cdot D}}{\left(w \cdot w\right) \cdot h}\\
\end{array}
\end{array}
if c0 < -3.19999999999999996e-158 or 3.69999999999999993e-177 < c0 Initial program 20.6%
Taylor expanded in c0 around inf
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6427.4
Applied rewrites27.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-/.f64N/A
associate-*r*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6432.8
Applied rewrites32.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6436.4
Applied rewrites36.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
*-commutativeN/A
associate-*l*N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f6441.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.1
Applied rewrites41.1%
if -3.19999999999999996e-158 < c0 < 3.69999999999999993e-177Initial program 16.2%
Taylor expanded in c0 around inf
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-/.f64N/A
associate-*r*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f642.5
Applied rewrites2.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f644.8
Applied rewrites4.8%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
Applied rewrites29.9%
Final simplification39.2%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w))) (t_1 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M_m M_m))))) INFINITY)
(* t_0 (/ (* 2.0 (* (exp (* (log d) 2.0)) c0)) (* (* (* D h) w) D)))
(* (* c0 c0) (* d (/ d (* (* (* D h) (* D w)) w)))))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= ((double) INFINITY)) {
tmp = t_0 * ((2.0 * (exp((log(d) * 2.0)) * c0)) / (((D * h) * w) * D));
} else {
tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w)));
}
return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= Double.POSITIVE_INFINITY) {
tmp = t_0 * ((2.0 * (Math.exp((Math.log(d) * 2.0)) * c0)) / (((D * h) * w) * D));
} else {
tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w)));
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): t_0 = c0 / (2.0 * w) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= math.inf: tmp = t_0 * ((2.0 * (math.exp((math.log(d) * 2.0)) * c0)) / (((D * h) * w) * D)) else: tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w))) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(c0 / Float64(2.0 * w)) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M_m * M_m))))) <= Inf) tmp = Float64(t_0 * Float64(Float64(2.0 * Float64(exp(Float64(log(d) * 2.0)) * c0)) / Float64(Float64(Float64(D * h) * w) * D))); else tmp = Float64(Float64(c0 * c0) * Float64(d * Float64(d / Float64(Float64(Float64(D * h) * Float64(D * w)) * w)))); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) t_0 = c0 / (2.0 * w); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= Inf) tmp = t_0 * ((2.0 * (exp((log(d) * 2.0)) * c0)) / (((D * h) * w) * D)); else tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w))); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(N[(2.0 * N[(N[Exp[N[(N[Log[d], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * c0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(D * h), $MachinePrecision] * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * c0), $MachinePrecision] * N[(d * N[(d / N[(N[(N[(D * h), $MachinePrecision] * N[(D * w), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t\_0 \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M\_m \cdot M\_m}\right) \leq \infty:\\
\;\;\;\;t\_0 \cdot \frac{2 \cdot \left(e^{\log d \cdot 2} \cdot c0\right)}{\left(\left(D \cdot h\right) \cdot w\right) \cdot D}\\
\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot h\right) \cdot \left(D \cdot w\right)\right) \cdot w}\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 72.6%
Taylor expanded in c0 around inf
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6471.3
Applied rewrites71.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6472.2
Applied rewrites72.2%
lift-*.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6434.8
Applied rewrites34.8%
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 0.0%
Taylor expanded in c0 around inf
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6412.6
Applied rewrites12.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-/.f64N/A
associate-*r*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6418.8
Applied rewrites18.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6421.3
Applied rewrites21.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
*-commutativeN/A
associate-*l*N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f6426.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6426.7
Applied rewrites26.7%
M_m = (fabs.f64 M) (FPCore (c0 w h D d M_m) :precision binary64 (* (* c0 c0) (* d (/ d (* (* (* D h) (* D w)) w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
return (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w)));
}
M_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(c0, w, h, d, d_1, m_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
code = (c0 * c0) * (d_1 * (d_1 / (((d * h) * (d * w)) * w)))
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
return (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w)));
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): return (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w)))
M_m = abs(M) function code(c0, w, h, D, d, M_m) return Float64(Float64(c0 * c0) * Float64(d * Float64(d / Float64(Float64(Float64(D * h) * Float64(D * w)) * w)))) end
M_m = abs(M); function tmp = code(c0, w, h, D, d, M_m) tmp = (c0 * c0) * (d * (d / (((D * h) * (D * w)) * w))); end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := N[(N[(c0 * c0), $MachinePrecision] * N[(d * N[(d / N[(N[(N[(D * h), $MachinePrecision] * N[(D * w), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
\left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot h\right) \cdot \left(D \cdot w\right)\right) \cdot w}\right)
\end{array}
Initial program 19.8%
Taylor expanded in c0 around inf
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6422.7
Applied rewrites22.7%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-/.f64N/A
associate-*r*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6427.6
Applied rewrites27.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6431.0
Applied rewrites31.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
*-commutativeN/A
associate-*l*N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f6435.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.6
Applied rewrites35.6%
M_m = (fabs.f64 M) (FPCore (c0 w h D d M_m) :precision binary64 (* (* c0 c0) (* d (/ d (* (* (* D D) h) (* w w))))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
return (c0 * c0) * (d * (d / (((D * D) * h) * (w * w))));
}
M_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(c0, w, h, d, d_1, m_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
code = (c0 * c0) * (d_1 * (d_1 / (((d * d) * h) * (w * w))))
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
return (c0 * c0) * (d * (d / (((D * D) * h) * (w * w))));
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): return (c0 * c0) * (d * (d / (((D * D) * h) * (w * w))))
M_m = abs(M) function code(c0, w, h, D, d, M_m) return Float64(Float64(c0 * c0) * Float64(d * Float64(d / Float64(Float64(Float64(D * D) * h) * Float64(w * w))))) end
M_m = abs(M); function tmp = code(c0, w, h, D, d, M_m) tmp = (c0 * c0) * (d * (d / (((D * D) * h) * (w * w)))); end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := N[(N[(c0 * c0), $MachinePrecision] * N[(d * N[(d / N[(N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
\left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}\right)
\end{array}
Initial program 19.8%
Taylor expanded in c0 around inf
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6422.7
Applied rewrites22.7%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-/.f64N/A
associate-*r*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6427.6
Applied rewrites27.6%
herbie shell --seed 2025064
(FPCore (c0 w h D d M)
:name "Henrywood and Agarwal, Equation (13)"
:precision binary64
(* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))