
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))))
(t_1 (fmin M (fabs D)))
(t_2 (fmax M (fabs D)))
(t_3 (* t_1 t_2))
(t_4 (- 1.0 (* (* (/ 1.0 2.0) (pow (/ t_3 (* 2.0 d)) 2.0)) (/ h l))))
(t_5 (* t_0 t_4))
(t_6 (* t_2 t_1))
(t_7 (* t_6 h))
(t_8 (* (+ d d) l)))
(if (<= t_5 -1e-22)
(*
t_0
(fma (/ (* (/ t_3 d) 0.25) l) (/ (* (* h t_2) t_1) (* -2.0 d)) 1.0))
(if (<= t_5 0.0)
(*
(fabs (/ d (sqrt (* l h))))
(- 1.0 (* (/ (* 0.5 t_6) (+ d d)) (/ t_7 t_8))))
(if (<= t_5 2e+256)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_4)
(/
(* (- 1.0 (/ (* (* 0.25 t_6) t_7) (* d t_8))) (fabs d))
(sqrt (* h l))))))))double code(double d, double h, double l, double M, double D) {
double t_0 = pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0));
double t_1 = fmin(M, fabs(D));
double t_2 = fmax(M, fabs(D));
double t_3 = t_1 * t_2;
double t_4 = 1.0 - (((1.0 / 2.0) * pow((t_3 / (2.0 * d)), 2.0)) * (h / l));
double t_5 = t_0 * t_4;
double t_6 = t_2 * t_1;
double t_7 = t_6 * h;
double t_8 = (d + d) * l;
double tmp;
if (t_5 <= -1e-22) {
tmp = t_0 * fma((((t_3 / d) * 0.25) / l), (((h * t_2) * t_1) / (-2.0 * d)), 1.0);
} else if (t_5 <= 0.0) {
tmp = fabs((d / sqrt((l * h)))) * (1.0 - (((0.5 * t_6) / (d + d)) * (t_7 / t_8)));
} else if (t_5 <= 2e+256) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_4;
} else {
tmp = ((1.0 - (((0.25 * t_6) * t_7) / (d * t_8))) * fabs(d)) / sqrt((h * l));
}
return tmp;
}
function code(d, h, l, M, D) t_0 = Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) t_1 = fmin(M, abs(D)) t_2 = fmax(M, abs(D)) t_3 = Float64(t_1 * t_2) t_4 = Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(t_3 / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) t_5 = Float64(t_0 * t_4) t_6 = Float64(t_2 * t_1) t_7 = Float64(t_6 * h) t_8 = Float64(Float64(d + d) * l) tmp = 0.0 if (t_5 <= -1e-22) tmp = Float64(t_0 * fma(Float64(Float64(Float64(t_3 / d) * 0.25) / l), Float64(Float64(Float64(h * t_2) * t_1) / Float64(-2.0 * d)), 1.0)); elseif (t_5 <= 0.0) tmp = Float64(abs(Float64(d / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64(Float64(0.5 * t_6) / Float64(d + d)) * Float64(t_7 / t_8)))); elseif (t_5 <= 2e+256) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_4); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(0.25 * t_6) * t_7) / Float64(d * t_8))) * abs(d)) / sqrt(Float64(h * l))); end return tmp end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Min[M, N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[M, N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(t$95$3 / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$0 * t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$2 * t$95$1), $MachinePrecision]}, Block[{t$95$7 = N[(t$95$6 * h), $MachinePrecision]}, Block[{t$95$8 = N[(N[(d + d), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[t$95$5, -1e-22], N[(t$95$0 * N[(N[(N[(N[(t$95$3 / d), $MachinePrecision] * 0.25), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(h * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision] / N[(-2.0 * d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 0.0], N[(N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(0.5 * t$95$6), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * N[(t$95$7 / t$95$8), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 2e+256], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(N[(0.25 * t$95$6), $MachinePrecision] * t$95$7), $MachinePrecision] / N[(d * t$95$8), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]
\begin{array}{l}
t_0 := {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\\
t_1 := \mathsf{min}\left(M, \left|D\right|\right)\\
t_2 := \mathsf{max}\left(M, \left|D\right|\right)\\
t_3 := t\_1 \cdot t\_2\\
t_4 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{t\_3}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
t_5 := t\_0 \cdot t\_4\\
t_6 := t\_2 \cdot t\_1\\
t_7 := t\_6 \cdot h\\
t_8 := \left(d + d\right) \cdot \ell\\
\mathbf{if}\;t\_5 \leq -1 \cdot 10^{-22}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(\frac{\frac{t\_3}{d} \cdot 0.25}{\ell}, \frac{\left(h \cdot t\_2\right) \cdot t\_1}{-2 \cdot d}, 1\right)\\
\mathbf{elif}\;t\_5 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right| \cdot \left(1 - \frac{0.5 \cdot t\_6}{d + d} \cdot \frac{t\_7}{t\_8}\right)\\
\mathbf{elif}\;t\_5 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_4\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{\left(0.25 \cdot t\_6\right) \cdot t\_7}{d \cdot t\_8}\right) \cdot \left|d\right|}{\sqrt{h \cdot \ell}}\\
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1e-22Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
Applied rewrites66.3%
if -1e-22 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e256Initial program 66.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6466.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6466.4
Applied rewrites66.4%
if 2.0000000000000001e256 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites72.4%
Applied rewrites69.0%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l))))
(t_1 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) t_0))
(t_2 (* (* D M) h))
(t_3 (* (+ d d) l)))
(if (<= t_1 0.0)
(*
(fabs (/ d (sqrt (* l h))))
(- 1.0 (* (/ (* 0.5 (* D M)) (+ d d)) (/ t_2 t_3))))
(if (<= t_1 2e+256)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_0)
(/
(* (- 1.0 (/ (* (* 0.25 (* D M)) t_2) (* d t_3))) (fabs d))
(sqrt (* h l)))))))double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l));
double t_1 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * t_0;
double t_2 = (D * M) * h;
double t_3 = (d + d) * l;
double tmp;
if (t_1 <= 0.0) {
tmp = fabs((d / sqrt((l * h)))) * (1.0 - (((0.5 * (D * M)) / (d + d)) * (t_2 / t_3)));
} else if (t_1 <= 2e+256) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
} else {
tmp = ((1.0 - (((0.25 * (D * M)) * t_2) / (d * t_3))) * fabs(d)) / sqrt((h * l));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
t_1 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * t_0
t_2 = (d_1 * m) * h
t_3 = (d + d) * l
if (t_1 <= 0.0d0) then
tmp = abs((d / sqrt((l * h)))) * (1.0d0 - (((0.5d0 * (d_1 * m)) / (d + d)) * (t_2 / t_3)))
else if (t_1 <= 2d+256) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0
else
tmp = ((1.0d0 - (((0.25d0 * (d_1 * m)) * t_2) / (d * t_3))) * abs(d)) / sqrt((h * l))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l));
double t_1 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * t_0;
double t_2 = (D * M) * h;
double t_3 = (d + d) * l;
double tmp;
if (t_1 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h)))) * (1.0 - (((0.5 * (D * M)) / (d + d)) * (t_2 / t_3)));
} else if (t_1 <= 2e+256) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * t_0;
} else {
tmp = ((1.0 - (((0.25 * (D * M)) * t_2) / (d * t_3))) * Math.abs(d)) / Math.sqrt((h * l));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = 1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)) t_1 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * t_0 t_2 = (D * M) * h t_3 = (d + d) * l tmp = 0 if t_1 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) * (1.0 - (((0.5 * (D * M)) / (d + d)) * (t_2 / t_3))) elif t_1 <= 2e+256: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * t_0 else: tmp = ((1.0 - (((0.25 * (D * M)) * t_2) / (d * t_3))) * math.fabs(d)) / math.sqrt((h * l)) return tmp
function code(d, h, l, M, D) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) t_1 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * t_0) t_2 = Float64(Float64(D * M) * h) t_3 = Float64(Float64(d + d) * l) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(abs(Float64(d / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64(Float64(0.5 * Float64(D * M)) / Float64(d + d)) * Float64(t_2 / t_3)))); elseif (t_1 <= 2e+256) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_0); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(0.25 * Float64(D * M)) * t_2) / Float64(d * t_3))) * abs(d)) / sqrt(Float64(h * l))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = 1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)); t_1 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * t_0; t_2 = (D * M) * h; t_3 = (d + d) * l; tmp = 0.0; if (t_1 <= 0.0) tmp = abs((d / sqrt((l * h)))) * (1.0 - (((0.5 * (D * M)) / (d + d)) * (t_2 / t_3))); elseif (t_1 <= 2e+256) tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0; else tmp = ((1.0 - (((0.25 * (D * M)) * t_2) / (d * t_3))) * abs(d)) / sqrt((h * l)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(D * M), $MachinePrecision] * h), $MachinePrecision]}, Block[{t$95$3 = N[(N[(d + d), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(0.5 * N[(D * M), $MachinePrecision]), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 / t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+256], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(N[(0.25 * N[(D * M), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] / N[(d * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot t\_0\\
t_2 := \left(D \cdot M\right) \cdot h\\
t_3 := \left(d + d\right) \cdot \ell\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right| \cdot \left(1 - \frac{0.5 \cdot \left(D \cdot M\right)}{d + d} \cdot \frac{t\_2}{t\_3}\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{\left(0.25 \cdot \left(D \cdot M\right)\right) \cdot t\_2}{d \cdot t\_3}\right) \cdot \left|d\right|}{\sqrt{h \cdot \ell}}\\
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e256Initial program 66.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6466.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6466.4
Applied rewrites66.4%
if 2.0000000000000001e256 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites72.4%
Applied rewrites69.0%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (* D M) h))
(t_2 (* (+ d d) l)))
(if (<= t_0 0.0)
(*
(fabs (/ d (sqrt (* l h))))
(- 1.0 (* (/ (* 0.5 (* D M)) (+ d d)) (/ t_1 t_2))))
(if (<= t_0 2e+256)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(/
(* (- 1.0 (/ (* (* 0.25 (* D M)) t_1) (* d t_2))) (fabs d))
(sqrt (* h l)))))))double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (D * M) * h;
double t_2 = (d + d) * l;
double tmp;
if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h)))) * (1.0 - (((0.5 * (D * M)) / (d + d)) * (t_1 / t_2)));
} else if (t_0 <= 2e+256) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = ((1.0 - (((0.25 * (D * M)) * t_1) / (d * t_2))) * fabs(d)) / sqrt((h * l));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = (d_1 * m) * h
t_2 = (d + d) * l
if (t_0 <= 0.0d0) then
tmp = abs((d / sqrt((l * h)))) * (1.0d0 - (((0.5d0 * (d_1 * m)) / (d + d)) * (t_1 / t_2)))
else if (t_0 <= 2d+256) then
tmp = sqrt((d / h)) * sqrt((d / l))
else
tmp = ((1.0d0 - (((0.25d0 * (d_1 * m)) * t_1) / (d * t_2))) * abs(d)) / sqrt((h * l))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (D * M) * h;
double t_2 = (d + d) * l;
double tmp;
if (t_0 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h)))) * (1.0 - (((0.5 * (D * M)) / (d + d)) * (t_1 / t_2)));
} else if (t_0 <= 2e+256) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else {
tmp = ((1.0 - (((0.25 * (D * M)) * t_1) / (d * t_2))) * Math.abs(d)) / Math.sqrt((h * l));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = (D * M) * h t_2 = (d + d) * l tmp = 0 if t_0 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) * (1.0 - (((0.5 * (D * M)) / (d + d)) * (t_1 / t_2))) elif t_0 <= 2e+256: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) else: tmp = ((1.0 - (((0.25 * (D * M)) * t_1) / (d * t_2))) * math.fabs(d)) / math.sqrt((h * l)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(D * M) * h) t_2 = Float64(Float64(d + d) * l) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(abs(Float64(d / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64(Float64(0.5 * Float64(D * M)) / Float64(d + d)) * Float64(t_1 / t_2)))); elseif (t_0 <= 2e+256) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(0.25 * Float64(D * M)) * t_1) / Float64(d * t_2))) * abs(d)) / sqrt(Float64(h * l))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); t_1 = (D * M) * h; t_2 = (d + d) * l; tmp = 0.0; if (t_0 <= 0.0) tmp = abs((d / sqrt((l * h)))) * (1.0 - (((0.5 * (D * M)) / (d + d)) * (t_1 / t_2))); elseif (t_0 <= 2e+256) tmp = sqrt((d / h)) * sqrt((d / l)); else tmp = ((1.0 - (((0.25 * (D * M)) * t_1) / (d * t_2))) * abs(d)) / sqrt((h * l)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(D * M), $MachinePrecision] * h), $MachinePrecision]}, Block[{t$95$2 = N[(N[(d + d), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(0.5 * N[(D * M), $MachinePrecision]), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+256], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(N[(0.25 * N[(D * M), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] / N[(d * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \left(D \cdot M\right) \cdot h\\
t_2 := \left(d + d\right) \cdot \ell\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right| \cdot \left(1 - \frac{0.5 \cdot \left(D \cdot M\right)}{d + d} \cdot \frac{t\_1}{t\_2}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{\left(0.25 \cdot \left(D \cdot M\right)\right) \cdot t\_1}{d \cdot t\_2}\right) \cdot \left|d\right|}{\sqrt{h \cdot \ell}}\\
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e256Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in h around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
if 2.0000000000000001e256 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites72.4%
Applied rewrites69.0%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (+ d d) l)))
(if (<= t_0 0.0)
(*
(fabs (/ d (sqrt (* l h))))
(- 1.0 (* (* (/ (* M D) d) 0.25) (* (/ h t_1) (* M D)))))
(if (<= t_0 2e+256)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(/
(* (- 1.0 (/ (* (* 0.25 (* D M)) (* (* D M) h)) (* d t_1))) (fabs d))
(sqrt (* h l)))))))double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (d + d) * l;
double tmp;
if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h)))) * (1.0 - ((((M * D) / d) * 0.25) * ((h / t_1) * (M * D))));
} else if (t_0 <= 2e+256) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = ((1.0 - (((0.25 * (D * M)) * ((D * M) * h)) / (d * t_1))) * fabs(d)) / sqrt((h * l));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = (d + d) * l
if (t_0 <= 0.0d0) then
tmp = abs((d / sqrt((l * h)))) * (1.0d0 - ((((m * d_1) / d) * 0.25d0) * ((h / t_1) * (m * d_1))))
else if (t_0 <= 2d+256) then
tmp = sqrt((d / h)) * sqrt((d / l))
else
tmp = ((1.0d0 - (((0.25d0 * (d_1 * m)) * ((d_1 * m) * h)) / (d * t_1))) * abs(d)) / sqrt((h * l))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (d + d) * l;
double tmp;
if (t_0 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h)))) * (1.0 - ((((M * D) / d) * 0.25) * ((h / t_1) * (M * D))));
} else if (t_0 <= 2e+256) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else {
tmp = ((1.0 - (((0.25 * (D * M)) * ((D * M) * h)) / (d * t_1))) * Math.abs(d)) / Math.sqrt((h * l));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = (d + d) * l tmp = 0 if t_0 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) * (1.0 - ((((M * D) / d) * 0.25) * ((h / t_1) * (M * D)))) elif t_0 <= 2e+256: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) else: tmp = ((1.0 - (((0.25 * (D * M)) * ((D * M) * h)) / (d * t_1))) * math.fabs(d)) / math.sqrt((h * l)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(d + d) * l) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(abs(Float64(d / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64(Float64(Float64(M * D) / d) * 0.25) * Float64(Float64(h / t_1) * Float64(M * D))))); elseif (t_0 <= 2e+256) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(0.25 * Float64(D * M)) * Float64(Float64(D * M) * h)) / Float64(d * t_1))) * abs(d)) / sqrt(Float64(h * l))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); t_1 = (d + d) * l; tmp = 0.0; if (t_0 <= 0.0) tmp = abs((d / sqrt((l * h)))) * (1.0 - ((((M * D) / d) * 0.25) * ((h / t_1) * (M * D)))); elseif (t_0 <= 2e+256) tmp = sqrt((d / h)) * sqrt((d / l)); else tmp = ((1.0 - (((0.25 * (D * M)) * ((D * M) * h)) / (d * t_1))) * abs(d)) / sqrt((h * l)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d + d), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision] * 0.25), $MachinePrecision] * N[(N[(h / t$95$1), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+256], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(N[(0.25 * N[(D * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D * M), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / N[(d * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \left(d + d\right) \cdot \ell\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right| \cdot \left(1 - \left(\frac{M \cdot D}{d} \cdot 0.25\right) \cdot \left(\frac{h}{t\_1} \cdot \left(M \cdot D\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{\left(0.25 \cdot \left(D \cdot M\right)\right) \cdot \left(\left(D \cdot M\right) \cdot h\right)}{d \cdot t\_1}\right) \cdot \left|d\right|}{\sqrt{h \cdot \ell}}\\
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-+.f64N/A
count-2-revN/A
*-commutativeN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6475.4
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6472.5
Applied rewrites72.5%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e256Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in h around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
if 2.0000000000000001e256 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites72.4%
Applied rewrites69.0%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* (fmin M D) (fmax M D)) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (* (fmax M D) (fmin M D)))
(t_2 (* (+ d d) l)))
(if (<= t_0 0.0)
(*
(fabs (/ d (sqrt (* l h))))
(-
1.0
(*
(/
(* (* (* (* (/ h t_2) (fmax M D)) (fmin M D)) (fmax M D)) (fmin M D))
d)
0.25)))
(if (<= t_0 2e+256)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(/
(* (- 1.0 (/ (* (* 0.25 t_1) (* t_1 h)) (* d t_2))) (fabs d))
(sqrt (* h l)))))))double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((fmin(M, D) * fmax(M, D)) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = fmax(M, D) * fmin(M, D);
double t_2 = (d + d) * l;
double tmp;
if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h)))) * (1.0 - (((((((h / t_2) * fmax(M, D)) * fmin(M, D)) * fmax(M, D)) * fmin(M, D)) / d) * 0.25));
} else if (t_0 <= 2e+256) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = ((1.0 - (((0.25 * t_1) * (t_1 * h)) / (d * t_2))) * fabs(d)) / sqrt((h * l));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((fmin(m, d_1) * fmax(m, d_1)) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = fmax(m, d_1) * fmin(m, d_1)
t_2 = (d + d) * l
if (t_0 <= 0.0d0) then
tmp = abs((d / sqrt((l * h)))) * (1.0d0 - (((((((h / t_2) * fmax(m, d_1)) * fmin(m, d_1)) * fmax(m, d_1)) * fmin(m, d_1)) / d) * 0.25d0))
else if (t_0 <= 2d+256) then
tmp = sqrt((d / h)) * sqrt((d / l))
else
tmp = ((1.0d0 - (((0.25d0 * t_1) * (t_1 * h)) / (d * t_2))) * abs(d)) / sqrt((h * l))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((fmin(M, D) * fmax(M, D)) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = fmax(M, D) * fmin(M, D);
double t_2 = (d + d) * l;
double tmp;
if (t_0 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h)))) * (1.0 - (((((((h / t_2) * fmax(M, D)) * fmin(M, D)) * fmax(M, D)) * fmin(M, D)) / d) * 0.25));
} else if (t_0 <= 2e+256) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else {
tmp = ((1.0 - (((0.25 * t_1) * (t_1 * h)) / (d * t_2))) * Math.abs(d)) / Math.sqrt((h * l));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((fmin(M, D) * fmax(M, D)) / (2.0 * d)), 2.0)) * (h / l))) t_1 = fmax(M, D) * fmin(M, D) t_2 = (d + d) * l tmp = 0 if t_0 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) * (1.0 - (((((((h / t_2) * fmax(M, D)) * fmin(M, D)) * fmax(M, D)) * fmin(M, D)) / d) * 0.25)) elif t_0 <= 2e+256: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) else: tmp = ((1.0 - (((0.25 * t_1) * (t_1 * h)) / (d * t_2))) * math.fabs(d)) / math.sqrt((h * l)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(fmin(M, D) * fmax(M, D)) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(fmax(M, D) * fmin(M, D)) t_2 = Float64(Float64(d + d) * l) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(abs(Float64(d / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(Float64(h / t_2) * fmax(M, D)) * fmin(M, D)) * fmax(M, D)) * fmin(M, D)) / d) * 0.25))); elseif (t_0 <= 2e+256) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(0.25 * t_1) * Float64(t_1 * h)) / Float64(d * t_2))) * abs(d)) / sqrt(Float64(h * l))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((min(M, D) * max(M, D)) / (2.0 * d)) ^ 2.0)) * (h / l))); t_1 = max(M, D) * min(M, D); t_2 = (d + d) * l; tmp = 0.0; if (t_0 <= 0.0) tmp = abs((d / sqrt((l * h)))) * (1.0 - (((((((h / t_2) * max(M, D)) * min(M, D)) * max(M, D)) * min(M, D)) / d) * 0.25)); elseif (t_0 <= 2e+256) tmp = sqrt((d / h)) * sqrt((d / l)); else tmp = ((1.0 - (((0.25 * t_1) * (t_1 * h)) / (d * t_2))) * abs(d)) / sqrt((h * l)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(N[Min[M, D], $MachinePrecision] * N[Max[M, D], $MachinePrecision]), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Max[M, D], $MachinePrecision] * N[Min[M, D], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(d + d), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(N[(N[(h / t$95$2), $MachinePrecision] * N[Max[M, D], $MachinePrecision]), $MachinePrecision] * N[Min[M, D], $MachinePrecision]), $MachinePrecision] * N[Max[M, D], $MachinePrecision]), $MachinePrecision] * N[Min[M, D], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+256], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(N[(0.25 * t$95$1), $MachinePrecision] * N[(t$95$1 * h), $MachinePrecision]), $MachinePrecision] / N[(d * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{\mathsf{min}\left(M, D\right) \cdot \mathsf{max}\left(M, D\right)}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \mathsf{max}\left(M, D\right) \cdot \mathsf{min}\left(M, D\right)\\
t_2 := \left(d + d\right) \cdot \ell\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right| \cdot \left(1 - \frac{\left(\left(\left(\frac{h}{t\_2} \cdot \mathsf{max}\left(M, D\right)\right) \cdot \mathsf{min}\left(M, D\right)\right) \cdot \mathsf{max}\left(M, D\right)\right) \cdot \mathsf{min}\left(M, D\right)}{d} \cdot 0.25\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{\left(0.25 \cdot t\_1\right) \cdot \left(t\_1 \cdot h\right)}{d \cdot t\_2}\right) \cdot \left|d\right|}{\sqrt{h \cdot \ell}}\\
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites72.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-+.f64N/A
count-2-revN/A
*-commutativeN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites71.4%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e256Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in h around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
if 2.0000000000000001e256 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites72.4%
Applied rewrites69.0%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1
(/
(*
(- 1.0 (/ (* (* 0.25 (* D M)) (* (* D M) h)) (* d (* (+ d d) l))))
(fabs d))
(sqrt (* h l)))))
(if (<= t_0 0.0)
t_1
(if (<= t_0 2e+256) (* (sqrt (/ d h)) (sqrt (/ d l))) t_1))))double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = ((1.0 - (((0.25 * (D * M)) * ((D * M) * h)) / (d * ((d + d) * l)))) * fabs(d)) / sqrt((h * l));
double tmp;
if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 2e+256) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = ((1.0d0 - (((0.25d0 * (d_1 * m)) * ((d_1 * m) * h)) / (d * ((d + d) * l)))) * abs(d)) / sqrt((h * l))
if (t_0 <= 0.0d0) then
tmp = t_1
else if (t_0 <= 2d+256) then
tmp = sqrt((d / h)) * sqrt((d / l))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = ((1.0 - (((0.25 * (D * M)) * ((D * M) * h)) / (d * ((d + d) * l)))) * Math.abs(d)) / Math.sqrt((h * l));
double tmp;
if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 2e+256) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else {
tmp = t_1;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = ((1.0 - (((0.25 * (D * M)) * ((D * M) * h)) / (d * ((d + d) * l)))) * math.fabs(d)) / math.sqrt((h * l)) tmp = 0 if t_0 <= 0.0: tmp = t_1 elif t_0 <= 2e+256: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) else: tmp = t_1 return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(0.25 * Float64(D * M)) * Float64(Float64(D * M) * h)) / Float64(d * Float64(Float64(d + d) * l)))) * abs(d)) / sqrt(Float64(h * l))) tmp = 0.0 if (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 2e+256) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = t_1; end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); t_1 = ((1.0 - (((0.25 * (D * M)) * ((D * M) * h)) / (d * ((d + d) * l)))) * abs(d)) / sqrt((h * l)); tmp = 0.0; if (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 2e+256) tmp = sqrt((d / h)) * sqrt((d / l)); else tmp = t_1; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 - N[(N[(N[(0.25 * N[(D * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D * M), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / N[(d * N[(N[(d + d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 2e+256], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left(1 - \frac{\left(0.25 \cdot \left(D \cdot M\right)\right) \cdot \left(\left(D \cdot M\right) \cdot h\right)}{d \cdot \left(\left(d + d\right) \cdot \ell\right)}\right) \cdot \left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0 or 2.0000000000000001e256 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites72.4%
Applied rewrites69.0%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e256Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in h around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
(FPCore (d h l M D)
:precision binary64
(if (<= l -1.08e-305)
(* -1.0 (/ (fabs d) (* l (* (sqrt (- h)) (sqrt (/ -1.0 l))))))
(if (<= l 1.2e+214)
(*
(fma
(/ (* -0.25 (* (* (/ (fmax M D) d) (fmin M D)) (fmin M D))) l)
(/ (* (* 0.5 h) (fmax M D)) d)
1.0)
(/ d (sqrt (* l h))))
(/ (* (sqrt d) (sqrt (/ d h))) (* l (sqrt (/ 1.0 l)))))))double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -1.08e-305) {
tmp = -1.0 * (fabs(d) / (l * (sqrt(-h) * sqrt((-1.0 / l)))));
} else if (l <= 1.2e+214) {
tmp = fma(((-0.25 * (((fmax(M, D) / d) * fmin(M, D)) * fmin(M, D))) / l), (((0.5 * h) * fmax(M, D)) / d), 1.0) * (d / sqrt((l * h)));
} else {
tmp = (sqrt(d) * sqrt((d / h))) / (l * sqrt((1.0 / l)));
}
return tmp;
}
function code(d, h, l, M, D) tmp = 0.0 if (l <= -1.08e-305) tmp = Float64(-1.0 * Float64(abs(d) / Float64(l * Float64(sqrt(Float64(-h)) * sqrt(Float64(-1.0 / l)))))); elseif (l <= 1.2e+214) tmp = Float64(fma(Float64(Float64(-0.25 * Float64(Float64(Float64(fmax(M, D) / d) * fmin(M, D)) * fmin(M, D))) / l), Float64(Float64(Float64(0.5 * h) * fmax(M, D)) / d), 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(Float64(sqrt(d) * sqrt(Float64(d / h))) / Float64(l * sqrt(Float64(1.0 / l)))); end return tmp end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1.08e-305], N[(-1.0 * N[(N[Abs[d], $MachinePrecision] / N[(l * N[(N[Sqrt[(-h)], $MachinePrecision] * N[Sqrt[N[(-1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.2e+214], N[(N[(N[(N[(-0.25 * N[(N[(N[(N[Max[M, D], $MachinePrecision] / d), $MachinePrecision] * N[Min[M, D], $MachinePrecision]), $MachinePrecision] * N[Min[M, D], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(0.5 * h), $MachinePrecision] * N[Max[M, D], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(l * N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.08 \cdot 10^{-305}:\\
\;\;\;\;-1 \cdot \frac{\left|d\right|}{\ell \cdot \left(\sqrt{-h} \cdot \sqrt{\frac{-1}{\ell}}\right)}\\
\mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+214}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-0.25 \cdot \left(\left(\frac{\mathsf{max}\left(M, D\right)}{d} \cdot \mathsf{min}\left(M, D\right)\right) \cdot \mathsf{min}\left(M, D\right)\right)}{\ell}, \frac{\left(0.5 \cdot h\right) \cdot \mathsf{max}\left(M, D\right)}{d}, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{h}}}{\ell \cdot \sqrt{\frac{1}{\ell}}}\\
\end{array}
if l < -1.08000000000000004e-305Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
Applied rewrites38.9%
Taylor expanded in l around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f6424.8
Applied rewrites24.8%
if -1.08000000000000004e-305 < l < 1.2e214Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites59.9%
Applied rewrites36.6%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6437.4
Applied rewrites37.4%
if 1.2e214 < l Initial program 66.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f6435.6
Applied rewrites35.6%
Taylor expanded in l around inf
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.1
Applied rewrites22.1%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (fmax M (fabs D))) (t_1 (fmin M (fabs D))))
(if (<= h -1.4e+236)
(/ (* (* d (sqrt (/ h d))) (* d (sqrt (/ 1.0 (* d l))))) h)
(if (<= h -3.8e-307)
(* -1.0 (/ (fabs d) (* l (* (sqrt (- h)) (sqrt (/ -1.0 l))))))
(/
(*
(- 1.0 (* (/ (* (* h t_0) t_1) l) (* (/ (/ (* t_1 t_0) d) d) 0.125)))
d)
(sqrt (* l h)))))))double code(double d, double h, double l, double M, double D) {
double t_0 = fmax(M, fabs(D));
double t_1 = fmin(M, fabs(D));
double tmp;
if (h <= -1.4e+236) {
tmp = ((d * sqrt((h / d))) * (d * sqrt((1.0 / (d * l))))) / h;
} else if (h <= -3.8e-307) {
tmp = -1.0 * (fabs(d) / (l * (sqrt(-h) * sqrt((-1.0 / l)))));
} else {
tmp = ((1.0 - ((((h * t_0) * t_1) / l) * ((((t_1 * t_0) / d) / d) * 0.125))) * d) / sqrt((l * h));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax(m, abs(d_1))
t_1 = fmin(m, abs(d_1))
if (h <= (-1.4d+236)) then
tmp = ((d * sqrt((h / d))) * (d * sqrt((1.0d0 / (d * l))))) / h
else if (h <= (-3.8d-307)) then
tmp = (-1.0d0) * (abs(d) / (l * (sqrt(-h) * sqrt(((-1.0d0) / l)))))
else
tmp = ((1.0d0 - ((((h * t_0) * t_1) / l) * ((((t_1 * t_0) / d) / d) * 0.125d0))) * d) / sqrt((l * h))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = fmax(M, Math.abs(D));
double t_1 = fmin(M, Math.abs(D));
double tmp;
if (h <= -1.4e+236) {
tmp = ((d * Math.sqrt((h / d))) * (d * Math.sqrt((1.0 / (d * l))))) / h;
} else if (h <= -3.8e-307) {
tmp = -1.0 * (Math.abs(d) / (l * (Math.sqrt(-h) * Math.sqrt((-1.0 / l)))));
} else {
tmp = ((1.0 - ((((h * t_0) * t_1) / l) * ((((t_1 * t_0) / d) / d) * 0.125))) * d) / Math.sqrt((l * h));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = fmax(M, math.fabs(D)) t_1 = fmin(M, math.fabs(D)) tmp = 0 if h <= -1.4e+236: tmp = ((d * math.sqrt((h / d))) * (d * math.sqrt((1.0 / (d * l))))) / h elif h <= -3.8e-307: tmp = -1.0 * (math.fabs(d) / (l * (math.sqrt(-h) * math.sqrt((-1.0 / l))))) else: tmp = ((1.0 - ((((h * t_0) * t_1) / l) * ((((t_1 * t_0) / d) / d) * 0.125))) * d) / math.sqrt((l * h)) return tmp
function code(d, h, l, M, D) t_0 = fmax(M, abs(D)) t_1 = fmin(M, abs(D)) tmp = 0.0 if (h <= -1.4e+236) tmp = Float64(Float64(Float64(d * sqrt(Float64(h / d))) * Float64(d * sqrt(Float64(1.0 / Float64(d * l))))) / h); elseif (h <= -3.8e-307) tmp = Float64(-1.0 * Float64(abs(d) / Float64(l * Float64(sqrt(Float64(-h)) * sqrt(Float64(-1.0 / l)))))); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(Float64(h * t_0) * t_1) / l) * Float64(Float64(Float64(Float64(t_1 * t_0) / d) / d) * 0.125))) * d) / sqrt(Float64(l * h))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = max(M, abs(D)); t_1 = min(M, abs(D)); tmp = 0.0; if (h <= -1.4e+236) tmp = ((d * sqrt((h / d))) * (d * sqrt((1.0 / (d * l))))) / h; elseif (h <= -3.8e-307) tmp = -1.0 * (abs(d) / (l * (sqrt(-h) * sqrt((-1.0 / l))))); else tmp = ((1.0 - ((((h * t_0) * t_1) / l) * ((((t_1 * t_0) / d) / d) * 0.125))) * d) / sqrt((l * h)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Max[M, N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[M, N[Abs[D], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -1.4e+236], N[(N[(N[(d * N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(d * N[Sqrt[N[(1.0 / N[(d * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[h, -3.8e-307], N[(-1.0 * N[(N[Abs[d], $MachinePrecision] / N[(l * N[(N[Sqrt[(-h)], $MachinePrecision] * N[Sqrt[N[(-1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(N[(N[(h * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(N[(t$95$1 * t$95$0), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(M, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(M, \left|D\right|\right)\\
\mathbf{if}\;h \leq -1.4 \cdot 10^{+236}:\\
\;\;\;\;\frac{\left(d \cdot \sqrt{\frac{h}{d}}\right) \cdot \left(d \cdot \sqrt{\frac{1}{d \cdot \ell}}\right)}{h}\\
\mathbf{elif}\;h \leq -3.8 \cdot 10^{-307}:\\
\;\;\;\;-1 \cdot \frac{\left|d\right|}{\ell \cdot \left(\sqrt{-h} \cdot \sqrt{\frac{-1}{\ell}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{\left(h \cdot t\_0\right) \cdot t\_1}{\ell} \cdot \left(\frac{\frac{t\_1 \cdot t\_0}{d}}{d} \cdot 0.125\right)\right) \cdot d}{\sqrt{\ell \cdot h}}\\
\end{array}
if h < -1.39999999999999996e236Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6421.0
Applied rewrites21.0%
if -1.39999999999999996e236 < h < -3.79999999999999985e-307Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
Applied rewrites38.9%
Taylor expanded in l around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f6424.8
Applied rewrites24.8%
if -3.79999999999999985e-307 < h Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites38.1%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (sqrt (/ d l))))
(if (<= t_0 -4e-59)
(/ (* (* -1.0 (* d (sqrt (sqrt (* (/ h d) (/ h d)))))) t_1) h)
(if (<= t_0 2e+256)
(* (sqrt (/ d h)) t_1)
(if (<= t_0 INFINITY)
(/ (/ (* (sqrt (* d h)) (sqrt (* d l))) l) h)
(/ (* t_1 (* (sqrt (/ h d)) (- d))) h))))))double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / l));
double tmp;
if (t_0 <= -4e-59) {
tmp = ((-1.0 * (d * sqrt(sqrt(((h / d) * (h / d)))))) * t_1) / h;
} else if (t_0 <= 2e+256) {
tmp = sqrt((d / h)) * t_1;
} else if (t_0 <= ((double) INFINITY)) {
tmp = ((sqrt((d * h)) * sqrt((d * l))) / l) / h;
} else {
tmp = (t_1 * (sqrt((h / d)) * -d)) / h;
}
return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((d / l));
double tmp;
if (t_0 <= -4e-59) {
tmp = ((-1.0 * (d * Math.sqrt(Math.sqrt(((h / d) * (h / d)))))) * t_1) / h;
} else if (t_0 <= 2e+256) {
tmp = Math.sqrt((d / h)) * t_1;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = ((Math.sqrt((d * h)) * Math.sqrt((d * l))) / l) / h;
} else {
tmp = (t_1 * (Math.sqrt((h / d)) * -d)) / h;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((d / l)) tmp = 0 if t_0 <= -4e-59: tmp = ((-1.0 * (d * math.sqrt(math.sqrt(((h / d) * (h / d)))))) * t_1) / h elif t_0 <= 2e+256: tmp = math.sqrt((d / h)) * t_1 elif t_0 <= math.inf: tmp = ((math.sqrt((d * h)) * math.sqrt((d * l))) / l) / h else: tmp = (t_1 * (math.sqrt((h / d)) * -d)) / h return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (t_0 <= -4e-59) tmp = Float64(Float64(Float64(-1.0 * Float64(d * sqrt(sqrt(Float64(Float64(h / d) * Float64(h / d)))))) * t_1) / h); elseif (t_0 <= 2e+256) tmp = Float64(sqrt(Float64(d / h)) * t_1); elseif (t_0 <= Inf) tmp = Float64(Float64(Float64(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) / l) / h); else tmp = Float64(Float64(t_1 * Float64(sqrt(Float64(h / d)) * Float64(-d))) / h); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); t_1 = sqrt((d / l)); tmp = 0.0; if (t_0 <= -4e-59) tmp = ((-1.0 * (d * sqrt(sqrt(((h / d) * (h / d)))))) * t_1) / h; elseif (t_0 <= 2e+256) tmp = sqrt((d / h)) * t_1; elseif (t_0 <= Inf) tmp = ((sqrt((d * h)) * sqrt((d * l))) / l) / h; else tmp = (t_1 * (sqrt((h / d)) * -d)) / h; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -4e-59], N[(N[(N[(-1.0 * N[(d * N[Sqrt[N[Sqrt[N[(N[(h / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$0, 2e+256], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] / h), $MachinePrecision], N[(N[(t$95$1 * N[(N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-59}:\\
\;\;\;\;\frac{\left(-1 \cdot \left(d \cdot \sqrt{\sqrt{\frac{h}{d} \cdot \frac{h}{d}}}\right)\right) \cdot t\_1}{h}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\frac{\sqrt{d \cdot h} \cdot \sqrt{d \cdot \ell}}{\ell}}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 \cdot \left(\sqrt{\frac{h}{d}} \cdot \left(-d\right)\right)}{h}\\
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.0000000000000001e-59Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6412.3
Applied rewrites12.3%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6415.5
Applied rewrites15.5%
if -4.0000000000000001e-59 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e256Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in h around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
if 2.0000000000000001e256 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f6431.5
Applied rewrites31.5%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6412.3
Applied rewrites12.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6412.3
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f6412.3
Applied rewrites12.3%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* d (sqrt (/ h d)))) (t_1 (* d (sqrt (/ 1.0 (* d l))))))
(if (<= d -2.6e-255)
(* -1.0 (/ (fabs d) (* l (* (sqrt (- h)) (sqrt (/ -1.0 l))))))
(if (<= d -8.5e-301)
(/ (* t_0 t_1) h)
(if (<= d 2.3e-123)
(/ (* t_0 (* -1.0 t_1)) h)
(/ (* (* (sqrt h) (sqrt d)) (sqrt (/ d l))) h))))))double code(double d, double h, double l, double M, double D) {
double t_0 = d * sqrt((h / d));
double t_1 = d * sqrt((1.0 / (d * l)));
double tmp;
if (d <= -2.6e-255) {
tmp = -1.0 * (fabs(d) / (l * (sqrt(-h) * sqrt((-1.0 / l)))));
} else if (d <= -8.5e-301) {
tmp = (t_0 * t_1) / h;
} else if (d <= 2.3e-123) {
tmp = (t_0 * (-1.0 * t_1)) / h;
} else {
tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d * sqrt((h / d))
t_1 = d * sqrt((1.0d0 / (d * l)))
if (d <= (-2.6d-255)) then
tmp = (-1.0d0) * (abs(d) / (l * (sqrt(-h) * sqrt(((-1.0d0) / l)))))
else if (d <= (-8.5d-301)) then
tmp = (t_0 * t_1) / h
else if (d <= 2.3d-123) then
tmp = (t_0 * ((-1.0d0) * t_1)) / h
else
tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = d * Math.sqrt((h / d));
double t_1 = d * Math.sqrt((1.0 / (d * l)));
double tmp;
if (d <= -2.6e-255) {
tmp = -1.0 * (Math.abs(d) / (l * (Math.sqrt(-h) * Math.sqrt((-1.0 / l)))));
} else if (d <= -8.5e-301) {
tmp = (t_0 * t_1) / h;
} else if (d <= 2.3e-123) {
tmp = (t_0 * (-1.0 * t_1)) / h;
} else {
tmp = ((Math.sqrt(h) * Math.sqrt(d)) * Math.sqrt((d / l))) / h;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = d * math.sqrt((h / d)) t_1 = d * math.sqrt((1.0 / (d * l))) tmp = 0 if d <= -2.6e-255: tmp = -1.0 * (math.fabs(d) / (l * (math.sqrt(-h) * math.sqrt((-1.0 / l))))) elif d <= -8.5e-301: tmp = (t_0 * t_1) / h elif d <= 2.3e-123: tmp = (t_0 * (-1.0 * t_1)) / h else: tmp = ((math.sqrt(h) * math.sqrt(d)) * math.sqrt((d / l))) / h return tmp
function code(d, h, l, M, D) t_0 = Float64(d * sqrt(Float64(h / d))) t_1 = Float64(d * sqrt(Float64(1.0 / Float64(d * l)))) tmp = 0.0 if (d <= -2.6e-255) tmp = Float64(-1.0 * Float64(abs(d) / Float64(l * Float64(sqrt(Float64(-h)) * sqrt(Float64(-1.0 / l)))))); elseif (d <= -8.5e-301) tmp = Float64(Float64(t_0 * t_1) / h); elseif (d <= 2.3e-123) tmp = Float64(Float64(t_0 * Float64(-1.0 * t_1)) / h); else tmp = Float64(Float64(Float64(sqrt(h) * sqrt(d)) * sqrt(Float64(d / l))) / h); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = d * sqrt((h / d)); t_1 = d * sqrt((1.0 / (d * l))); tmp = 0.0; if (d <= -2.6e-255) tmp = -1.0 * (abs(d) / (l * (sqrt(-h) * sqrt((-1.0 / l))))); elseif (d <= -8.5e-301) tmp = (t_0 * t_1) / h; elseif (d <= 2.3e-123) tmp = (t_0 * (-1.0 * t_1)) / h; else tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(d * N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * N[Sqrt[N[(1.0 / N[(d * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.6e-255], N[(-1.0 * N[(N[Abs[d], $MachinePrecision] / N[(l * N[(N[Sqrt[(-h)], $MachinePrecision] * N[Sqrt[N[(-1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8.5e-301], N[(N[(t$95$0 * t$95$1), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[d, 2.3e-123], N[(N[(t$95$0 * N[(-1.0 * t$95$1), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := d \cdot \sqrt{\frac{h}{d}}\\
t_1 := d \cdot \sqrt{\frac{1}{d \cdot \ell}}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{-255}:\\
\;\;\;\;-1 \cdot \frac{\left|d\right|}{\ell \cdot \left(\sqrt{-h} \cdot \sqrt{\frac{-1}{\ell}}\right)}\\
\mathbf{elif}\;d \leq -8.5 \cdot 10^{-301}:\\
\;\;\;\;\frac{t\_0 \cdot t\_1}{h}\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{-123}:\\
\;\;\;\;\frac{t\_0 \cdot \left(-1 \cdot t\_1\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\sqrt{h} \cdot \sqrt{d}\right) \cdot \sqrt{\frac{d}{\ell}}}{h}\\
\end{array}
if d < -2.60000000000000021e-255Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
Applied rewrites38.9%
Taylor expanded in l around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f6424.8
Applied rewrites24.8%
if -2.60000000000000021e-255 < d < -8.50000000000000046e-301Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6421.0
Applied rewrites21.0%
if -8.50000000000000046e-301 < d < 2.29999999999999987e-123Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6421.2
Applied rewrites21.2%
if 2.29999999999999987e-123 < d Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
lower-unsound-sqrt.f64N/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f6421.5
Applied rewrites21.5%
(FPCore (d h l M D)
:precision binary64
(if (<= d -2.6e-255)
(* -1.0 (/ (fabs d) (* l (* (sqrt (- h)) (sqrt (/ -1.0 l))))))
(if (<= d 1.35e-202)
(- (* -1.0 (/ d (sqrt (* l h)))))
(/ (* (* (sqrt h) (sqrt d)) (sqrt (/ d l))) h))))double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.6e-255) {
tmp = -1.0 * (fabs(d) / (l * (sqrt(-h) * sqrt((-1.0 / l)))));
} else if (d <= 1.35e-202) {
tmp = -(-1.0 * (d / sqrt((l * h))));
} else {
tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-2.6d-255)) then
tmp = (-1.0d0) * (abs(d) / (l * (sqrt(-h) * sqrt(((-1.0d0) / l)))))
else if (d <= 1.35d-202) then
tmp = -((-1.0d0) * (d / sqrt((l * h))))
else
tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.6e-255) {
tmp = -1.0 * (Math.abs(d) / (l * (Math.sqrt(-h) * Math.sqrt((-1.0 / l)))));
} else if (d <= 1.35e-202) {
tmp = -(-1.0 * (d / Math.sqrt((l * h))));
} else {
tmp = ((Math.sqrt(h) * Math.sqrt(d)) * Math.sqrt((d / l))) / h;
}
return tmp;
}
def code(d, h, l, M, D): tmp = 0 if d <= -2.6e-255: tmp = -1.0 * (math.fabs(d) / (l * (math.sqrt(-h) * math.sqrt((-1.0 / l))))) elif d <= 1.35e-202: tmp = -(-1.0 * (d / math.sqrt((l * h)))) else: tmp = ((math.sqrt(h) * math.sqrt(d)) * math.sqrt((d / l))) / h return tmp
function code(d, h, l, M, D) tmp = 0.0 if (d <= -2.6e-255) tmp = Float64(-1.0 * Float64(abs(d) / Float64(l * Float64(sqrt(Float64(-h)) * sqrt(Float64(-1.0 / l)))))); elseif (d <= 1.35e-202) tmp = Float64(-Float64(-1.0 * Float64(d / sqrt(Float64(l * h))))); else tmp = Float64(Float64(Float64(sqrt(h) * sqrt(d)) * sqrt(Float64(d / l))) / h); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (d <= -2.6e-255) tmp = -1.0 * (abs(d) / (l * (sqrt(-h) * sqrt((-1.0 / l))))); elseif (d <= 1.35e-202) tmp = -(-1.0 * (d / sqrt((l * h)))); else tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -2.6e-255], N[(-1.0 * N[(N[Abs[d], $MachinePrecision] / N[(l * N[(N[Sqrt[(-h)], $MachinePrecision] * N[Sqrt[N[(-1.0 / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e-202], (-N[(-1.0 * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;d \leq -2.6 \cdot 10^{-255}:\\
\;\;\;\;-1 \cdot \frac{\left|d\right|}{\ell \cdot \left(\sqrt{-h} \cdot \sqrt{\frac{-1}{\ell}}\right)}\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{-202}:\\
\;\;\;\;--1 \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\sqrt{h} \cdot \sqrt{d}\right) \cdot \sqrt{\frac{d}{\ell}}}{h}\\
\end{array}
if d < -2.60000000000000021e-255Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
Applied rewrites38.9%
Taylor expanded in l around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f6424.8
Applied rewrites24.8%
if -2.60000000000000021e-255 < d < 1.3499999999999999e-202Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites59.9%
Applied rewrites26.7%
Taylor expanded in d around inf
Applied rewrites26.1%
if 1.3499999999999999e-202 < d Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
lower-unsound-sqrt.f64N/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f6421.5
Applied rewrites21.5%
(FPCore (d h l M D)
:precision binary64
(if (<= d -2.6e-255)
(/ (fabs d) (* (sqrt (- h)) (sqrt (- l))))
(if (<= d 1.35e-202)
(- (* -1.0 (/ d (sqrt (* l h)))))
(/ (* (* (sqrt h) (sqrt d)) (sqrt (/ d l))) h))))double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.6e-255) {
tmp = fabs(d) / (sqrt(-h) * sqrt(-l));
} else if (d <= 1.35e-202) {
tmp = -(-1.0 * (d / sqrt((l * h))));
} else {
tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-2.6d-255)) then
tmp = abs(d) / (sqrt(-h) * sqrt(-l))
else if (d <= 1.35d-202) then
tmp = -((-1.0d0) * (d / sqrt((l * h))))
else
tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.6e-255) {
tmp = Math.abs(d) / (Math.sqrt(-h) * Math.sqrt(-l));
} else if (d <= 1.35e-202) {
tmp = -(-1.0 * (d / Math.sqrt((l * h))));
} else {
tmp = ((Math.sqrt(h) * Math.sqrt(d)) * Math.sqrt((d / l))) / h;
}
return tmp;
}
def code(d, h, l, M, D): tmp = 0 if d <= -2.6e-255: tmp = math.fabs(d) / (math.sqrt(-h) * math.sqrt(-l)) elif d <= 1.35e-202: tmp = -(-1.0 * (d / math.sqrt((l * h)))) else: tmp = ((math.sqrt(h) * math.sqrt(d)) * math.sqrt((d / l))) / h return tmp
function code(d, h, l, M, D) tmp = 0.0 if (d <= -2.6e-255) tmp = Float64(abs(d) / Float64(sqrt(Float64(-h)) * sqrt(Float64(-l)))); elseif (d <= 1.35e-202) tmp = Float64(-Float64(-1.0 * Float64(d / sqrt(Float64(l * h))))); else tmp = Float64(Float64(Float64(sqrt(h) * sqrt(d)) * sqrt(Float64(d / l))) / h); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (d <= -2.6e-255) tmp = abs(d) / (sqrt(-h) * sqrt(-l)); elseif (d <= 1.35e-202) tmp = -(-1.0 * (d / sqrt((l * h)))); else tmp = ((sqrt(h) * sqrt(d)) * sqrt((d / l))) / h; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -2.6e-255], N[(N[Abs[d], $MachinePrecision] / N[(N[Sqrt[(-h)], $MachinePrecision] * N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e-202], (-N[(-1.0 * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;d \leq -2.6 \cdot 10^{-255}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{-h} \cdot \sqrt{-\ell}}\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{-202}:\\
\;\;\;\;--1 \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\sqrt{h} \cdot \sqrt{d}\right) \cdot \sqrt{\frac{d}{\ell}}}{h}\\
\end{array}
if d < -2.60000000000000021e-255Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
Applied rewrites38.9%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6424.8
Applied rewrites24.8%
if -2.60000000000000021e-255 < d < 1.3499999999999999e-202Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites59.9%
Applied rewrites26.7%
Taylor expanded in d around inf
Applied rewrites26.1%
if 1.3499999999999999e-202 < d Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
lower-unsound-sqrt.f64N/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f6421.5
Applied rewrites21.5%
(FPCore (d h l M D)
:precision binary64
(if (<= l -5.5e-304)
(/ (fabs d) (* (sqrt (- h)) (sqrt (- l))))
(if (<= l 1.05e+251)
(- (* -1.0 (/ d (sqrt (* l h)))))
(* (sqrt (/ d h)) (sqrt (/ d l))))))double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5.5e-304) {
tmp = fabs(d) / (sqrt(-h) * sqrt(-l));
} else if (l <= 1.05e+251) {
tmp = -(-1.0 * (d / sqrt((l * h))));
} else {
tmp = sqrt((d / h)) * sqrt((d / l));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= (-5.5d-304)) then
tmp = abs(d) / (sqrt(-h) * sqrt(-l))
else if (l <= 1.05d+251) then
tmp = -((-1.0d0) * (d / sqrt((l * h))))
else
tmp = sqrt((d / h)) * sqrt((d / l))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5.5e-304) {
tmp = Math.abs(d) / (Math.sqrt(-h) * Math.sqrt(-l));
} else if (l <= 1.05e+251) {
tmp = -(-1.0 * (d / Math.sqrt((l * h))));
} else {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
}
return tmp;
}
def code(d, h, l, M, D): tmp = 0 if l <= -5.5e-304: tmp = math.fabs(d) / (math.sqrt(-h) * math.sqrt(-l)) elif l <= 1.05e+251: tmp = -(-1.0 * (d / math.sqrt((l * h)))) else: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) return tmp
function code(d, h, l, M, D) tmp = 0.0 if (l <= -5.5e-304) tmp = Float64(abs(d) / Float64(sqrt(Float64(-h)) * sqrt(Float64(-l)))); elseif (l <= 1.05e+251) tmp = Float64(-Float64(-1.0 * Float64(d / sqrt(Float64(l * h))))); else tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (l <= -5.5e-304) tmp = abs(d) / (sqrt(-h) * sqrt(-l)); elseif (l <= 1.05e+251) tmp = -(-1.0 * (d / sqrt((l * h)))); else tmp = sqrt((d / h)) * sqrt((d / l)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5.5e-304], N[(N[Abs[d], $MachinePrecision] / N[(N[Sqrt[(-h)], $MachinePrecision] * N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.05e+251], (-N[(-1.0 * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.5 \cdot 10^{-304}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{-h} \cdot \sqrt{-\ell}}\\
\mathbf{elif}\;\ell \leq 1.05 \cdot 10^{+251}:\\
\;\;\;\;--1 \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\end{array}
if l < -5.50000000000000035e-304Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
Applied rewrites38.9%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6424.8
Applied rewrites24.8%
if -5.50000000000000035e-304 < l < 1.05e251Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites59.9%
Applied rewrites26.7%
Taylor expanded in d around inf
Applied rewrites26.1%
if 1.05e251 < l Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6423.9
Applied rewrites23.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6431.0
Applied rewrites31.0%
Taylor expanded in h around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
(FPCore (d h l M D) :precision binary64 (if (<= l -5.5e-304) (/ (fabs d) (* (sqrt (- h)) (sqrt (- l)))) (- (* -1.0 (/ d (sqrt (* l h)))))))
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5.5e-304) {
tmp = fabs(d) / (sqrt(-h) * sqrt(-l));
} else {
tmp = -(-1.0 * (d / sqrt((l * h))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= (-5.5d-304)) then
tmp = abs(d) / (sqrt(-h) * sqrt(-l))
else
tmp = -((-1.0d0) * (d / sqrt((l * h))))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5.5e-304) {
tmp = Math.abs(d) / (Math.sqrt(-h) * Math.sqrt(-l));
} else {
tmp = -(-1.0 * (d / Math.sqrt((l * h))));
}
return tmp;
}
def code(d, h, l, M, D): tmp = 0 if l <= -5.5e-304: tmp = math.fabs(d) / (math.sqrt(-h) * math.sqrt(-l)) else: tmp = -(-1.0 * (d / math.sqrt((l * h)))) return tmp
function code(d, h, l, M, D) tmp = 0.0 if (l <= -5.5e-304) tmp = Float64(abs(d) / Float64(sqrt(Float64(-h)) * sqrt(Float64(-l)))); else tmp = Float64(-Float64(-1.0 * Float64(d / sqrt(Float64(l * h))))); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (l <= -5.5e-304) tmp = abs(d) / (sqrt(-h) * sqrt(-l)); else tmp = -(-1.0 * (d / sqrt((l * h)))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5.5e-304], N[(N[Abs[d], $MachinePrecision] / N[(N[Sqrt[(-h)], $MachinePrecision] * N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(-1.0 * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.5 \cdot 10^{-304}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{-h} \cdot \sqrt{-\ell}}\\
\mathbf{else}:\\
\;\;\;\;--1 \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
if l < -5.50000000000000035e-304Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
Applied rewrites66.3%
Applied rewrites75.4%
Applied rewrites38.9%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6424.8
Applied rewrites24.8%
if -5.50000000000000035e-304 < l Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites59.9%
Applied rewrites26.7%
Taylor expanded in d around inf
Applied rewrites26.1%
(FPCore (d h l M D) :precision binary64 (if (<= d 3.7e-262) (/ (- d) (sqrt (* h l))) (- (* -1.0 (/ d (sqrt (* l h)))))))
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= 3.7e-262) {
tmp = -d / sqrt((h * l));
} else {
tmp = -(-1.0 * (d / sqrt((l * h))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= 3.7d-262) then
tmp = -d / sqrt((h * l))
else
tmp = -((-1.0d0) * (d / sqrt((l * h))))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= 3.7e-262) {
tmp = -d / Math.sqrt((h * l));
} else {
tmp = -(-1.0 * (d / Math.sqrt((l * h))));
}
return tmp;
}
def code(d, h, l, M, D): tmp = 0 if d <= 3.7e-262: tmp = -d / math.sqrt((h * l)) else: tmp = -(-1.0 * (d / math.sqrt((l * h)))) return tmp
function code(d, h, l, M, D) tmp = 0.0 if (d <= 3.7e-262) tmp = Float64(Float64(-d) / sqrt(Float64(h * l))); else tmp = Float64(-Float64(-1.0 * Float64(d / sqrt(Float64(l * h))))); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (d <= 3.7e-262) tmp = -d / sqrt((h * l)); else tmp = -(-1.0 * (d / sqrt((l * h)))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, 3.7e-262], N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[(-1.0 * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}
\mathbf{if}\;d \leq 3.7 \cdot 10^{-262}:\\
\;\;\;\;\frac{-d}{\sqrt{h \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;--1 \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
if d < 3.7e-262Initial program 66.4%
lift-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-*.f64N/A
lower-unsound-sqrt.f64N/A
lower-*.f6448.9
Applied rewrites48.9%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f6425.9
Applied rewrites25.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6425.9
Applied rewrites25.9%
if 3.7e-262 < d Initial program 66.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites59.9%
Applied rewrites26.7%
Taylor expanded in d around inf
Applied rewrites26.1%
(FPCore (d h l M D) :precision binary64 (/ (- d) (sqrt (* h l))))
double code(double d, double h, double l, double M, double D) {
return -d / sqrt((h * l));
}
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = -d / sqrt((h * l))
end function
public static double code(double d, double h, double l, double M, double D) {
return -d / Math.sqrt((h * l));
}
def code(d, h, l, M, D): return -d / math.sqrt((h * l))
function code(d, h, l, M, D) return Float64(Float64(-d) / sqrt(Float64(h * l))) end
function tmp = code(d, h, l, M, D) tmp = -d / sqrt((h * l)); end
code[d_, h_, l_, M_, D_] := N[((-d) / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{-d}{\sqrt{h \cdot \ell}}
Initial program 66.4%
lift-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-*.f64N/A
lower-unsound-sqrt.f64N/A
lower-*.f6448.9
Applied rewrites48.9%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f6425.9
Applied rewrites25.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f6425.9
Applied rewrites25.9%
herbie shell --seed 2025178
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))