
(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 11 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}
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
:precision binary64
(let* ((t_0 (/ (/ (pow (* d_m c0) 2.0) (* (* D w) (* D w))) h))
(t_1 (* (* d_m d_m) c0)))
(if (<= d_m 5.3e-160)
t_0
(if (<= d_m 1e+103)
(/ (* c0 (* (/ 2.0 (* (* h w) D)) (/ t_1 D))) (* w 2.0))
(if (<= d_m 1.4e+277)
t_0
(*
(/ c0 (* 2.0 w))
(* (* (* (* M D) (* M D)) (/ (* h w) t_1)) -0.5)))))))d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = (pow((d_m * c0), 2.0) / ((D * w) * (D * w))) / h;
double t_1 = (d_m * d_m) * c0;
double tmp;
if (d_m <= 5.3e-160) {
tmp = t_0;
} else if (d_m <= 1e+103) {
tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
} else if (d_m <= 1.4e+277) {
tmp = t_0;
} else {
tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
}
return tmp;
}
d_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_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_m
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m * c0) ** 2.0d0) / ((d * w) * (d * w))) / h
t_1 = (d_m * d_m) * c0
if (d_m <= 5.3d-160) then
tmp = t_0
else if (d_m <= 1d+103) then
tmp = (c0 * ((2.0d0 / ((h * w) * d)) * (t_1 / d))) / (w * 2.0d0)
else if (d_m <= 1.4d+277) then
tmp = t_0
else
tmp = (c0 / (2.0d0 * w)) * ((((m * d) * (m * d)) * ((h * w) / t_1)) * (-0.5d0))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = (Math.pow((d_m * c0), 2.0) / ((D * w) * (D * w))) / h;
double t_1 = (d_m * d_m) * c0;
double tmp;
if (d_m <= 5.3e-160) {
tmp = t_0;
} else if (d_m <= 1e+103) {
tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
} else if (d_m <= 1.4e+277) {
tmp = t_0;
} else {
tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
}
return tmp;
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): t_0 = (math.pow((d_m * c0), 2.0) / ((D * w) * (D * w))) / h t_1 = (d_m * d_m) * c0 tmp = 0 if d_m <= 5.3e-160: tmp = t_0 elif d_m <= 1e+103: tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0) elif d_m <= 1.4e+277: tmp = t_0 else: tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5) return tmp
d_m = abs(d) function code(c0, w, h, D, d_m, M) t_0 = Float64(Float64((Float64(d_m * c0) ^ 2.0) / Float64(Float64(D * w) * Float64(D * w))) / h) t_1 = Float64(Float64(d_m * d_m) * c0) tmp = 0.0 if (d_m <= 5.3e-160) tmp = t_0; elseif (d_m <= 1e+103) tmp = Float64(Float64(c0 * Float64(Float64(2.0 / Float64(Float64(h * w) * D)) * Float64(t_1 / D))) / Float64(w * 2.0)); elseif (d_m <= 1.4e+277) tmp = t_0; else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(Float64(h * w) / t_1)) * -0.5)); end return tmp end
d_m = abs(d); function tmp_2 = code(c0, w, h, D, d_m, M) t_0 = (((d_m * c0) ^ 2.0) / ((D * w) * (D * w))) / h; t_1 = (d_m * d_m) * c0; tmp = 0.0; if (d_m <= 5.3e-160) tmp = t_0; elseif (d_m <= 1e+103) tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0); elseif (d_m <= 1.4e+277) tmp = t_0; else tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m * c0), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(D * w), $MachinePrecision] * N[(D * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]}, If[LessEqual[d$95$m, 5.3e-160], t$95$0, If[LessEqual[d$95$m, 1e+103], N[(N[(c0 * N[(N[(2.0 / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d$95$m, 1.4e+277], t$95$0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(N[(h * w), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{\frac{{\left(d\_m \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h}\\
t_1 := \left(d\_m \cdot d\_m\right) \cdot c0\\
\mathbf{if}\;d\_m \leq 5.3 \cdot 10^{-160}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d\_m \leq 10^{+103}:\\
\;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_1}{D}\right)}{w \cdot 2}\\
\mathbf{elif}\;d\_m \leq 1.4 \cdot 10^{+277}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{t\_1}\right) \cdot -0.5\right)\\
\end{array}
\end{array}
if d < 5.3000000000000001e-160 or 1e103 < d < 1.39999999999999993e277Initial program 20.5%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6434.2
Applied rewrites34.2%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-/r*N/A
Applied rewrites42.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6442.2
Applied rewrites42.2%
if 5.3000000000000001e-160 < d < 1e103Initial program 37.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-*.f6454.6
Applied rewrites54.6%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites58.9%
if 1.39999999999999993e277 < d Initial program 26.3%
Taylor expanded in w around 0
lower-/.f64N/A
Applied rewrites21.5%
Taylor expanded in c0 around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
unpow-prod-downN/A
lower-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6447.8
Applied rewrites47.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
*-commutativeN/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6447.9
Applied rewrites47.9%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6447.9
Applied rewrites47.9%
Final simplification45.4%
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
:precision binary64
(let* ((t_0 (* (* d_m d_m) c0))
(t_1 (/ (* c0 (* d_m d_m)) (* (* w h) (* D D)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))
INFINITY)
(/ (* c0 (* (/ 2.0 (* (* h w) D)) (/ t_0 D))) (* w 2.0))
(/ (* c0 (* (/ (* (pow (* M D) 2.0) (* h w)) t_0) -0.5)) (* w 2.0)))))d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = (d_m * d_m) * c0;
double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_0 / D))) / (w * 2.0);
} else {
tmp = (c0 * (((pow((M * D), 2.0) * (h * w)) / t_0) * -0.5)) / (w * 2.0);
}
return tmp;
}
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = (d_m * d_m) * c0;
double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_0 / D))) / (w * 2.0);
} else {
tmp = (c0 * (((Math.pow((M * D), 2.0) * (h * w)) / t_0) * -0.5)) / (w * 2.0);
}
return tmp;
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): t_0 = (d_m * d_m) * c0 t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D)) tmp = 0 if ((c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf: tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_0 / D))) / (w * 2.0) else: tmp = (c0 * (((math.pow((M * D), 2.0) * (h * w)) / t_0) * -0.5)) / (w * 2.0) return tmp
d_m = abs(d) function code(c0, w, h, D, d_m, M) t_0 = Float64(Float64(d_m * d_m) * c0) t_1 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf) tmp = Float64(Float64(c0 * Float64(Float64(2.0 / Float64(Float64(h * w) * D)) * Float64(t_0 / D))) / Float64(w * 2.0)); else tmp = Float64(Float64(c0 * Float64(Float64(Float64((Float64(M * D) ^ 2.0) * Float64(h * w)) / t_0) * -0.5)) / Float64(w * 2.0)); end return tmp end
d_m = abs(d); function tmp_2 = code(c0, w, h, D, d_m, M) t_0 = (d_m * d_m) * c0; t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf) tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_0 / D))) / (w * 2.0); else tmp = (c0 * (((((M * D) ^ 2.0) * (h * w)) / t_0) * -0.5)) / (w * 2.0); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(c0 * N[(N[(2.0 / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * N[(N[(N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] * N[(h * w), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \left(d\_m \cdot d\_m\right) \cdot c0\\
t_1 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_0}{D}\right)}{w \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0 \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{t\_0} \cdot -0.5\right)}{w \cdot 2}\\
\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.3%
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-*.f6474.6
Applied rewrites74.6%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites78.3%
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 w around 0
lower-/.f64N/A
Applied rewrites6.4%
Taylor expanded in c0 around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
unpow-prod-downN/A
lower-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6427.6
Applied rewrites27.6%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
Applied rewrites33.5%
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
:precision binary64
(let* ((t_0 (* (* (* w w) h) (* D D)))
(t_1 (/ (* c0 (* d_m d_m)) (* (* w h) (* D D)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))
INFINITY)
(* c0 (/ (* (* d_m d_m) c0) t_0))
(* (* c0 c0) (* d_m (/ d_m t_0))))))d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = ((w * w) * h) * (D * D);
double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * (((d_m * d_m) * c0) / t_0);
} else {
tmp = (c0 * c0) * (d_m * (d_m / t_0));
}
return tmp;
}
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = ((w * w) * h) * (D * D);
double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 * (((d_m * d_m) * c0) / t_0);
} else {
tmp = (c0 * c0) * (d_m * (d_m / t_0));
}
return tmp;
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): t_0 = ((w * w) * h) * (D * D) t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D)) tmp = 0 if ((c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf: tmp = c0 * (((d_m * d_m) * c0) / t_0) else: tmp = (c0 * c0) * (d_m * (d_m / t_0)) return tmp
d_m = abs(d) function code(c0, w, h, D, d_m, M) t_0 = Float64(Float64(Float64(w * w) * h) * Float64(D * D)) t_1 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf) tmp = Float64(c0 * Float64(Float64(Float64(d_m * d_m) * c0) / t_0)); else tmp = Float64(Float64(c0 * c0) * Float64(d_m * Float64(d_m / t_0))); end return tmp end
d_m = abs(d); function tmp_2 = code(c0, w, h, D, d_m, M) t_0 = ((w * w) * h) * (D * D); t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf) tmp = c0 * (((d_m * d_m) * c0) / t_0); else tmp = (c0 * c0) * (d_m * (d_m / t_0)); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(N[(w * w), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(c0 * N[(N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * c0), $MachinePrecision] * N[(d$95$m * N[(d$95$m / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)\\
t_1 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{\left(d\_m \cdot d\_m\right) \cdot c0}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d\_m \cdot \frac{d\_m}{t\_0}\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.3%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6461.5
Applied rewrites61.5%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
pow2N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
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
Applied rewrites53.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
associate-/l*N/A
Applied rewrites63.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
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6423.1
Applied rewrites23.1%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
pow2N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
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
Applied rewrites11.1%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6423.4
Applied rewrites23.4%
Final simplification36.5%
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
:precision binary64
(let* ((t_0 (/ (pow (* d_m c0) 2.0) (* (* (* D w) (* D w)) h)))
(t_1 (* (* d_m d_m) c0)))
(if (<= d_m 3.1e-136)
t_0
(if (<= d_m 1.85e+104)
(/ (* c0 (* (/ 2.0 (* (* h w) D)) (/ t_1 D))) (* w 2.0))
(if (<= d_m 1.4e+277)
t_0
(*
(/ c0 (* 2.0 w))
(* (* (* (* M D) (* M D)) (/ (* h w) t_1)) -0.5)))))))d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = pow((d_m * c0), 2.0) / (((D * w) * (D * w)) * h);
double t_1 = (d_m * d_m) * c0;
double tmp;
if (d_m <= 3.1e-136) {
tmp = t_0;
} else if (d_m <= 1.85e+104) {
tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
} else if (d_m <= 1.4e+277) {
tmp = t_0;
} else {
tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
}
return tmp;
}
d_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_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_m
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((d_m * c0) ** 2.0d0) / (((d * w) * (d * w)) * h)
t_1 = (d_m * d_m) * c0
if (d_m <= 3.1d-136) then
tmp = t_0
else if (d_m <= 1.85d+104) then
tmp = (c0 * ((2.0d0 / ((h * w) * d)) * (t_1 / d))) / (w * 2.0d0)
else if (d_m <= 1.4d+277) then
tmp = t_0
else
tmp = (c0 / (2.0d0 * w)) * ((((m * d) * (m * d)) * ((h * w) / t_1)) * (-0.5d0))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = Math.pow((d_m * c0), 2.0) / (((D * w) * (D * w)) * h);
double t_1 = (d_m * d_m) * c0;
double tmp;
if (d_m <= 3.1e-136) {
tmp = t_0;
} else if (d_m <= 1.85e+104) {
tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
} else if (d_m <= 1.4e+277) {
tmp = t_0;
} else {
tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
}
return tmp;
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): t_0 = math.pow((d_m * c0), 2.0) / (((D * w) * (D * w)) * h) t_1 = (d_m * d_m) * c0 tmp = 0 if d_m <= 3.1e-136: tmp = t_0 elif d_m <= 1.85e+104: tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0) elif d_m <= 1.4e+277: tmp = t_0 else: tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5) return tmp
d_m = abs(d) function code(c0, w, h, D, d_m, M) t_0 = Float64((Float64(d_m * c0) ^ 2.0) / Float64(Float64(Float64(D * w) * Float64(D * w)) * h)) t_1 = Float64(Float64(d_m * d_m) * c0) tmp = 0.0 if (d_m <= 3.1e-136) tmp = t_0; elseif (d_m <= 1.85e+104) tmp = Float64(Float64(c0 * Float64(Float64(2.0 / Float64(Float64(h * w) * D)) * Float64(t_1 / D))) / Float64(w * 2.0)); elseif (d_m <= 1.4e+277) tmp = t_0; else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(Float64(h * w) / t_1)) * -0.5)); end return tmp end
d_m = abs(d); function tmp_2 = code(c0, w, h, D, d_m, M) t_0 = ((d_m * c0) ^ 2.0) / (((D * w) * (D * w)) * h); t_1 = (d_m * d_m) * c0; tmp = 0.0; if (d_m <= 3.1e-136) tmp = t_0; elseif (d_m <= 1.85e+104) tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0); elseif (d_m <= 1.4e+277) tmp = t_0; else tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(N[Power[N[(d$95$m * c0), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(N[(D * w), $MachinePrecision] * N[(D * w), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]}, If[LessEqual[d$95$m, 3.1e-136], t$95$0, If[LessEqual[d$95$m, 1.85e+104], N[(N[(c0 * N[(N[(2.0 / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d$95$m, 1.4e+277], t$95$0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(N[(h * w), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{{\left(d\_m \cdot c0\right)}^{2}}{\left(\left(D \cdot w\right) \cdot \left(D \cdot w\right)\right) \cdot h}\\
t_1 := \left(d\_m \cdot d\_m\right) \cdot c0\\
\mathbf{if}\;d\_m \leq 3.1 \cdot 10^{-136}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d\_m \leq 1.85 \cdot 10^{+104}:\\
\;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_1}{D}\right)}{w \cdot 2}\\
\mathbf{elif}\;d\_m \leq 1.4 \cdot 10^{+277}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{t\_1}\right) \cdot -0.5\right)\\
\end{array}
\end{array}
if d < 3.1e-136 or 1.8499999999999999e104 < d < 1.39999999999999993e277Initial program 20.5%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6434.6
Applied rewrites34.6%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-/r*N/A
Applied rewrites42.5%
count-2-rev42.5
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
associate-/l/N/A
Applied rewrites42.9%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6442.9
Applied rewrites42.9%
if 3.1e-136 < d < 1.8499999999999999e104Initial program 37.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-*.f6453.5
Applied rewrites53.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites57.9%
if 1.39999999999999993e277 < d Initial program 26.3%
Taylor expanded in w around 0
lower-/.f64N/A
Applied rewrites21.5%
Taylor expanded in c0 around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
unpow-prod-downN/A
lower-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6447.8
Applied rewrites47.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
*-commutativeN/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6447.9
Applied rewrites47.9%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6447.9
Applied rewrites47.9%
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w))))
(if (<= d_m 4.4e+271)
(* t_0 (/ (* 2.0 (* (* d_m c0) d_m)) (* (* h (* w D)) D)))
(* t_0 (* (* (* (* M D) (* M D)) (/ (* h w) (* (* d_m d_m) c0))) -0.5)))))d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = c0 / (2.0 * w);
double tmp;
if (d_m <= 4.4e+271) {
tmp = t_0 * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
} else {
tmp = t_0 * ((((M * D) * (M * D)) * ((h * w) / ((d_m * d_m) * c0))) * -0.5);
}
return tmp;
}
d_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_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_m
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: tmp
t_0 = c0 / (2.0d0 * w)
if (d_m <= 4.4d+271) then
tmp = t_0 * ((2.0d0 * ((d_m * c0) * d_m)) / ((h * (w * d)) * d))
else
tmp = t_0 * ((((m * d) * (m * d)) * ((h * w) / ((d_m * d_m) * c0))) * (-0.5d0))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
double t_0 = c0 / (2.0 * w);
double tmp;
if (d_m <= 4.4e+271) {
tmp = t_0 * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
} else {
tmp = t_0 * ((((M * D) * (M * D)) * ((h * w) / ((d_m * d_m) * c0))) * -0.5);
}
return tmp;
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): t_0 = c0 / (2.0 * w) tmp = 0 if d_m <= 4.4e+271: tmp = t_0 * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D)) else: tmp = t_0 * ((((M * D) * (M * D)) * ((h * w) / ((d_m * d_m) * c0))) * -0.5) return tmp
d_m = abs(d) function code(c0, w, h, D, d_m, M) t_0 = Float64(c0 / Float64(2.0 * w)) tmp = 0.0 if (d_m <= 4.4e+271) tmp = Float64(t_0 * Float64(Float64(2.0 * Float64(Float64(d_m * c0) * d_m)) / Float64(Float64(h * Float64(w * D)) * D))); else tmp = Float64(t_0 * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(Float64(h * w) / Float64(Float64(d_m * d_m) * c0))) * -0.5)); end return tmp end
d_m = abs(d); function tmp_2 = code(c0, w, h, D, d_m, M) t_0 = c0 / (2.0 * w); tmp = 0.0; if (d_m <= 4.4e+271) tmp = t_0 * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D)); else tmp = t_0 * ((((M * D) * (M * D)) * ((h * w) / ((d_m * d_m) * c0))) * -0.5); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d$95$m, 4.4e+271], N[(t$95$0 * N[(N[(2.0 * N[(N[(d$95$m * c0), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(h * N[(w * D), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(N[(h * w), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;d\_m \leq 4.4 \cdot 10^{+271}:\\
\;\;\;\;t\_0 \cdot \frac{2 \cdot \left(\left(d\_m \cdot c0\right) \cdot d\_m\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d\_m \cdot d\_m\right) \cdot c0}\right) \cdot -0.5\right)\\
\end{array}
\end{array}
if d < 4.40000000000000002e271Initial program 23.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-*.f6437.4
Applied rewrites37.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6437.4
Applied rewrites37.4%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
if 4.40000000000000002e271 < d Initial program 26.3%
Taylor expanded in w around 0
lower-/.f64N/A
Applied rewrites21.5%
Taylor expanded in c0 around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
unpow-prod-downN/A
lower-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6447.8
Applied rewrites47.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
*-commutativeN/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6447.9
Applied rewrites47.9%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6447.9
Applied rewrites47.9%
d_m = (fabs.f64 d) (FPCore (c0 w h D d_m M) :precision binary64 (if (or (<= d_m 1.4e-161) (not (<= d_m 1.35e+177))) (/ (* (* d_m c0) (* d_m c0)) (* (* D (* D h)) (* w w))) (* (/ c0 (+ w w)) (/ (* 2.0 (* (* d_m d_m) c0)) (* (* (* h w) D) D)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
double tmp;
if ((d_m <= 1.4e-161) || !(d_m <= 1.35e+177)) {
tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
} else {
tmp = (c0 / (w + w)) * ((2.0 * ((d_m * d_m) * c0)) / (((h * w) * D) * D));
}
return tmp;
}
d_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_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_m
real(8), intent (in) :: m
real(8) :: tmp
if ((d_m <= 1.4d-161) .or. (.not. (d_m <= 1.35d+177))) then
tmp = ((d_m * c0) * (d_m * c0)) / ((d * (d * h)) * (w * w))
else
tmp = (c0 / (w + w)) * ((2.0d0 * ((d_m * d_m) * c0)) / (((h * w) * d) * d))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
double tmp;
if ((d_m <= 1.4e-161) || !(d_m <= 1.35e+177)) {
tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
} else {
tmp = (c0 / (w + w)) * ((2.0 * ((d_m * d_m) * c0)) / (((h * w) * D) * D));
}
return tmp;
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): tmp = 0 if (d_m <= 1.4e-161) or not (d_m <= 1.35e+177): tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w)) else: tmp = (c0 / (w + w)) * ((2.0 * ((d_m * d_m) * c0)) / (((h * w) * D) * D)) return tmp
d_m = abs(d) function code(c0, w, h, D, d_m, M) tmp = 0.0 if ((d_m <= 1.4e-161) || !(d_m <= 1.35e+177)) tmp = Float64(Float64(Float64(d_m * c0) * Float64(d_m * c0)) / Float64(Float64(D * Float64(D * h)) * Float64(w * w))); else tmp = Float64(Float64(c0 / Float64(w + w)) * Float64(Float64(2.0 * Float64(Float64(d_m * d_m) * c0)) / Float64(Float64(Float64(h * w) * D) * D))); end return tmp end
d_m = abs(d); function tmp_2 = code(c0, w, h, D, d_m, M) tmp = 0.0; if ((d_m <= 1.4e-161) || ~((d_m <= 1.35e+177))) tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w)); else tmp = (c0 / (w + w)) * ((2.0 * ((d_m * d_m) * c0)) / (((h * w) * D) * D)); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[c0_, w_, h_, D_, d$95$m_, M_] := If[Or[LessEqual[d$95$m, 1.4e-161], N[Not[LessEqual[d$95$m, 1.35e+177]], $MachinePrecision]], N[(N[(N[(d$95$m * c0), $MachinePrecision] * N[(d$95$m * c0), $MachinePrecision]), $MachinePrecision] / N[(N[(D * N[(D * h), $MachinePrecision]), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;d\_m \leq 1.4 \cdot 10^{-161} \lor \neg \left(d\_m \leq 1.35 \cdot 10^{+177}\right):\\
\;\;\;\;\frac{\left(d\_m \cdot c0\right) \cdot \left(d\_m \cdot c0\right)}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{w + w} \cdot \frac{2 \cdot \left(\left(d\_m \cdot d\_m\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}\\
\end{array}
\end{array}
if d < 1.39999999999999996e-161 or 1.34999999999999995e177 < d Initial program 20.1%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6433.4
Applied rewrites33.4%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
pow2N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
Applied rewrites32.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6435.4
Applied rewrites35.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6435.4
Applied rewrites35.4%
if 1.39999999999999996e-161 < d < 1.34999999999999995e177Initial program 35.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-*.f6451.9
Applied rewrites51.9%
lift-*.f64N/A
count-2-revN/A
lower-+.f6451.9
Applied rewrites51.9%
Final simplification39.4%
d_m = (fabs.f64 d) (FPCore (c0 w h D d_m M) :precision binary64 (* (/ c0 (* 2.0 w)) (/ (* 2.0 (* (* d_m c0) d_m)) (* (* h (* w D)) D))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
return (c0 / (2.0 * w)) * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
}
d_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_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_m
real(8), intent (in) :: m
code = (c0 / (2.0d0 * w)) * ((2.0d0 * ((d_m * c0) * d_m)) / ((h * (w * d)) * d))
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
return (c0 / (2.0 * w)) * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): return (c0 / (2.0 * w)) * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D))
d_m = abs(d) function code(c0, w, h, D, d_m, M) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(2.0 * Float64(Float64(d_m * c0) * d_m)) / Float64(Float64(h * Float64(w * D)) * D))) end
d_m = abs(d); function tmp = code(c0, w, h, D, d_m, M) tmp = (c0 / (2.0 * w)) * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D)); end
d_m = N[Abs[d], $MachinePrecision] code[c0_, w_, h_, D_, d$95$m_, M_] := N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * N[(N[(d$95$m * c0), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(h * N[(w * D), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
\frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d\_m \cdot c0\right) \cdot d\_m\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D}
\end{array}
Initial program 23.7%
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.6
Applied rewrites36.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6436.6
Applied rewrites36.6%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6442.2
Applied rewrites42.2%
d_m = (fabs.f64 d) (FPCore (c0 w h D d_m M) :precision binary64 (if (or (<= d_m 1.7e-158) (not (<= d_m 3.4e+122))) (/ (* (* d_m c0) (* d_m c0)) (* (* D (* D h)) (* w w))) (* (* c0 c0) (/ (* d_m d_m) (* (* (* (* h w) D) D) w)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
double tmp;
if ((d_m <= 1.7e-158) || !(d_m <= 3.4e+122)) {
tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
} else {
tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
}
return tmp;
}
d_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_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_m
real(8), intent (in) :: m
real(8) :: tmp
if ((d_m <= 1.7d-158) .or. (.not. (d_m <= 3.4d+122))) then
tmp = ((d_m * c0) * (d_m * c0)) / ((d * (d * h)) * (w * w))
else
tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * d) * d) * w))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
double tmp;
if ((d_m <= 1.7e-158) || !(d_m <= 3.4e+122)) {
tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
} else {
tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
}
return tmp;
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): tmp = 0 if (d_m <= 1.7e-158) or not (d_m <= 3.4e+122): tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w)) else: tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w)) return tmp
d_m = abs(d) function code(c0, w, h, D, d_m, M) tmp = 0.0 if ((d_m <= 1.7e-158) || !(d_m <= 3.4e+122)) tmp = Float64(Float64(Float64(d_m * c0) * Float64(d_m * c0)) / Float64(Float64(D * Float64(D * h)) * Float64(w * w))); else tmp = Float64(Float64(c0 * c0) * Float64(Float64(d_m * d_m) / Float64(Float64(Float64(Float64(h * w) * D) * D) * w))); end return tmp end
d_m = abs(d); function tmp_2 = code(c0, w, h, D, d_m, M) tmp = 0.0; if ((d_m <= 1.7e-158) || ~((d_m <= 3.4e+122))) tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w)); else tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w)); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[c0_, w_, h_, D_, d$95$m_, M_] := If[Or[LessEqual[d$95$m, 1.7e-158], N[Not[LessEqual[d$95$m, 3.4e+122]], $MachinePrecision]], N[(N[(N[(d$95$m * c0), $MachinePrecision] * N[(d$95$m * c0), $MachinePrecision]), $MachinePrecision] / N[(N[(D * N[(D * h), $MachinePrecision]), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * c0), $MachinePrecision] * N[(N[(d$95$m * d$95$m), $MachinePrecision] / N[(N[(N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;d\_m \leq 1.7 \cdot 10^{-158} \lor \neg \left(d\_m \leq 3.4 \cdot 10^{+122}\right):\\
\;\;\;\;\frac{\left(d\_m \cdot c0\right) \cdot \left(d\_m \cdot c0\right)}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \frac{d\_m \cdot d\_m}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w}\\
\end{array}
\end{array}
if d < 1.7e-158 or 3.4e122 < d Initial program 21.2%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6434.3
Applied rewrites34.3%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
pow2N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-/.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
Applied rewrites34.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6436.6
Applied rewrites36.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6436.6
Applied rewrites36.6%
if 1.7e-158 < d < 3.4e122Initial program 34.1%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6441.6
Applied rewrites41.6%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
pow2N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
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
Applied rewrites34.2%
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
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6446.4
Applied rewrites46.4%
Final simplification38.5%
d_m = (fabs.f64 d) (FPCore (c0 w h D d_m M) :precision binary64 (if (or (<= d_m 5e-136) (not (<= d_m 4e+171))) (* (* c0 c0) (* d_m (/ d_m (* (* (* w w) h) (* D D))))) (* (* c0 c0) (/ (* d_m d_m) (* (* (* (* h w) D) D) w)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
double tmp;
if ((d_m <= 5e-136) || !(d_m <= 4e+171)) {
tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (D * D))));
} else {
tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
}
return tmp;
}
d_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_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_m
real(8), intent (in) :: m
real(8) :: tmp
if ((d_m <= 5d-136) .or. (.not. (d_m <= 4d+171))) then
tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (d * d))))
else
tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * d) * d) * w))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
double tmp;
if ((d_m <= 5e-136) || !(d_m <= 4e+171)) {
tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (D * D))));
} else {
tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
}
return tmp;
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): tmp = 0 if (d_m <= 5e-136) or not (d_m <= 4e+171): tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (D * D)))) else: tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w)) return tmp
d_m = abs(d) function code(c0, w, h, D, d_m, M) tmp = 0.0 if ((d_m <= 5e-136) || !(d_m <= 4e+171)) tmp = Float64(Float64(c0 * c0) * Float64(d_m * Float64(d_m / Float64(Float64(Float64(w * w) * h) * Float64(D * D))))); else tmp = Float64(Float64(c0 * c0) * Float64(Float64(d_m * d_m) / Float64(Float64(Float64(Float64(h * w) * D) * D) * w))); end return tmp end
d_m = abs(d); function tmp_2 = code(c0, w, h, D, d_m, M) tmp = 0.0; if ((d_m <= 5e-136) || ~((d_m <= 4e+171))) tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (D * D)))); else tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w)); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[c0_, w_, h_, D_, d$95$m_, M_] := If[Or[LessEqual[d$95$m, 5e-136], N[Not[LessEqual[d$95$m, 4e+171]], $MachinePrecision]], N[(N[(c0 * c0), $MachinePrecision] * N[(d$95$m * N[(d$95$m / N[(N[(N[(w * w), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * c0), $MachinePrecision] * N[(N[(d$95$m * d$95$m), $MachinePrecision] / N[(N[(N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;d\_m \leq 5 \cdot 10^{-136} \lor \neg \left(d\_m \leq 4 \cdot 10^{+171}\right):\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d\_m \cdot \frac{d\_m}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \frac{d\_m \cdot d\_m}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w}\\
\end{array}
\end{array}
if d < 5.0000000000000002e-136 or 3.99999999999999982e171 < d Initial program 20.1%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6433.8
Applied rewrites33.8%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
pow2N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
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
Applied rewrites22.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6433.7
Applied rewrites33.7%
if 5.0000000000000002e-136 < d < 3.99999999999999982e171Initial program 35.3%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6441.7
Applied rewrites41.7%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
pow2N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
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
Applied rewrites34.0%
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
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6443.9
Applied rewrites43.9%
Final simplification36.2%
d_m = (fabs.f64 d) (FPCore (c0 w h D d_m M) :precision binary64 (* c0 (/ (* (* d_m d_m) c0) (* (* (* w w) h) (* D D)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
return c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (D * D)));
}
d_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_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_m
real(8), intent (in) :: m
code = c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (d * d)))
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
return c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (D * D)));
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): return c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (D * D)))
d_m = abs(d) function code(c0, w, h, D, d_m, M) return Float64(c0 * Float64(Float64(Float64(d_m * d_m) * c0) / Float64(Float64(Float64(w * w) * h) * Float64(D * D)))) end
d_m = abs(d); function tmp = code(c0, w, h, D, d_m, M) tmp = c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (D * D))); end
d_m = N[Abs[d], $MachinePrecision] code[c0_, w_, h_, D_, d$95$m_, M_] := N[(c0 * N[(N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision] / N[(N[(N[(w * w), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
c0 \cdot \frac{\left(d\_m \cdot d\_m\right) \cdot c0}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}
\end{array}
Initial program 23.7%
Taylor expanded in c0 around inf
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6435.7
Applied rewrites35.7%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
pow2N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
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
Applied rewrites25.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
associate-/l*N/A
Applied rewrites30.3%
Final simplification30.3%
d_m = (fabs.f64 d) (FPCore (c0 w h D d_m M) :precision binary64 (* (/ c0 (+ w w)) (* (sqrt -1.0) M)))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
return (c0 / (w + w)) * (sqrt(-1.0) * M);
}
d_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_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_m
real(8), intent (in) :: m
code = (c0 / (w + w)) * (sqrt((-1.0d0)) * m)
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
return (c0 / (w + w)) * (Math.sqrt(-1.0) * M);
}
d_m = math.fabs(d) def code(c0, w, h, D, d_m, M): return (c0 / (w + w)) * (math.sqrt(-1.0) * M)
d_m = abs(d) function code(c0, w, h, D, d_m, M) return Float64(Float64(c0 / Float64(w + w)) * Float64(sqrt(-1.0) * M)) end
d_m = abs(d); function tmp = code(c0, w, h, D, d_m, M) tmp = (c0 / (w + w)) * (sqrt(-1.0) * M); end
d_m = N[Abs[d], $MachinePrecision] code[c0_, w_, h_, D_, d$95$m_, M_] := N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[-1.0], $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
\frac{c0}{w + w} \cdot \left(\sqrt{-1} \cdot M\right)
\end{array}
Initial program 23.7%
Taylor expanded in c0 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
lift-*.f64N/A
count-2-revN/A
lower-+.f640.0
Applied rewrites0.0%
herbie shell --seed 2025040
(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))))))