
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.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(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.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(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (fmax (fabs M) (fabs D)))
(t_1 (fmin (fabs M) (fabs D)))
(t_2 (* t_1 t_0))
(t_3 (/ t_2 (fabs d))))
(if (<= (* (pow (/ t_2 (* 2.0 (fabs d))) 2.0) (/ h l)) -2e+33)
(* (* (/ (* (fabs t_1) (sqrt (* -0.25 (/ h l)))) (fabs d)) t_0) w0)
(* w0 (sqrt (- 1.0 (* (* t_3 0.25) (/ (* t_3 h) l))))))))double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = fmax(fabs(M), fabs(D));
double t_1 = fmin(fabs(M), fabs(D));
double t_2 = t_1 * t_0;
double t_3 = t_2 / fabs(d);
double tmp;
if ((pow((t_2 / (2.0 * fabs(d))), 2.0) * (h / l)) <= -2e+33) {
tmp = (((fabs(t_1) * sqrt((-0.25 * (h / l)))) / fabs(d)) * t_0) * w0;
} else {
tmp = w0 * sqrt((1.0 - ((t_3 * 0.25) * ((t_3 * 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(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
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 = fmax(abs(m), abs(d))
t_1 = fmin(abs(m), abs(d))
t_2 = t_1 * t_0
t_3 = t_2 / abs(d_1)
if ((((t_2 / (2.0d0 * abs(d_1))) ** 2.0d0) * (h / l)) <= (-2d+33)) then
tmp = (((abs(t_1) * sqrt(((-0.25d0) * (h / l)))) / abs(d_1)) * t_0) * w0
else
tmp = w0 * sqrt((1.0d0 - ((t_3 * 0.25d0) * ((t_3 * h) / l))))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = fmax(Math.abs(M), Math.abs(D));
double t_1 = fmin(Math.abs(M), Math.abs(D));
double t_2 = t_1 * t_0;
double t_3 = t_2 / Math.abs(d);
double tmp;
if ((Math.pow((t_2 / (2.0 * Math.abs(d))), 2.0) * (h / l)) <= -2e+33) {
tmp = (((Math.abs(t_1) * Math.sqrt((-0.25 * (h / l)))) / Math.abs(d)) * t_0) * w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((t_3 * 0.25) * ((t_3 * h) / l))));
}
return tmp;
}
def code(w0, M, D, h, l, d): t_0 = fmax(math.fabs(M), math.fabs(D)) t_1 = fmin(math.fabs(M), math.fabs(D)) t_2 = t_1 * t_0 t_3 = t_2 / math.fabs(d) tmp = 0 if (math.pow((t_2 / (2.0 * math.fabs(d))), 2.0) * (h / l)) <= -2e+33: tmp = (((math.fabs(t_1) * math.sqrt((-0.25 * (h / l)))) / math.fabs(d)) * t_0) * w0 else: tmp = w0 * math.sqrt((1.0 - ((t_3 * 0.25) * ((t_3 * h) / l)))) return tmp
function code(w0, M, D, h, l, d) t_0 = fmax(abs(M), abs(D)) t_1 = fmin(abs(M), abs(D)) t_2 = Float64(t_1 * t_0) t_3 = Float64(t_2 / abs(d)) tmp = 0.0 if (Float64((Float64(t_2 / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)) <= -2e+33) tmp = Float64(Float64(Float64(Float64(abs(t_1) * sqrt(Float64(-0.25 * Float64(h / l)))) / abs(d)) * t_0) * w0); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_3 * 0.25) * Float64(Float64(t_3 * h) / l))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) t_0 = max(abs(M), abs(D)); t_1 = min(abs(M), abs(D)); t_2 = t_1 * t_0; t_3 = t_2 / abs(d); tmp = 0.0; if ((((t_2 / (2.0 * abs(d))) ^ 2.0) * (h / l)) <= -2e+33) tmp = (((abs(t_1) * sqrt((-0.25 * (h / l)))) / abs(d)) * t_0) * w0; else tmp = w0 * sqrt((1.0 - ((t_3 * 0.25) * ((t_3 * h) / l)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[Abs[d], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(t$95$2 / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+33], N[(N[(N[(N[(N[Abs[t$95$1], $MachinePrecision] * N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * w0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$3 * 0.25), $MachinePrecision] * N[(N[(t$95$3 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
t_2 := t\_1 \cdot t\_0\\
t_3 := \frac{t\_2}{\left|d\right|}\\
\mathbf{if}\;{\left(\frac{t\_2}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+33}:\\
\;\;\;\;\left(\frac{\left|t\_1\right| \cdot \sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_0\right) \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(t\_3 \cdot 0.25\right) \cdot \frac{t\_3 \cdot h}{\ell}}\\
\end{array}
if (*.f64 (pow.64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -1.9999999999999999e33Initial program 80.9%
Taylor expanded in D around inf
lower-*.f64N/A
lower-sqrt.64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.64N/A
lower-*.f64N/A
lower-pow.649.8%
Applied rewrites9.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f649.8%
Applied rewrites9.8%
lift-sqrt.64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
sqrt-prodN/A
lower-unsound-sqrt.32N/A
lower-sqrt.32N/A
lift-*.f64N/A
rem-sqrt-square-revN/A
lower-unsound-*.f64N/A
lower-fabs.64N/A
lower-unsound-sqrt.64N/A
lower-*.f6411.7%
Applied rewrites11.7%
Taylor expanded in d around 0
lower-/.f64N/A
lower-*.f64N/A
lower-fabs.64N/A
lower-sqrt.64N/A
lower-*.f64N/A
lower-/.f6413.9%
Applied rewrites13.9%
if -1.9999999999999999e33 < (*.f64 (pow.64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 80.9%
lift-pow.64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
metadata-evalN/A
cosh-0-revN/A
lower-/.f64N/A
Applied rewrites80.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6489.0%
Applied rewrites89.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lower-/.f6487.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6487.6%
Applied rewrites87.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lower-/.f6488.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.9%
Applied rewrites88.9%
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (* (/ (fabs D) (fabs d)) M)))
(if (<= (* (pow (/ (* M (fabs D)) (* 2.0 (fabs d))) 2.0) (/ h l)) -2e+33)
(* (* (/ (* (fabs M) (sqrt (* -0.25 (/ h l)))) (fabs d)) (fabs D)) w0)
(* w0 (sqrt (- 1.0 (* (* t_0 0.25) (/ (* t_0 h) l))))))))double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (fabs(D) / fabs(d)) * M;
double tmp;
if ((pow(((M * fabs(D)) / (2.0 * fabs(d))), 2.0) * (h / l)) <= -2e+33) {
tmp = (((fabs(M) * sqrt((-0.25 * (h / l)))) / fabs(d)) * fabs(D)) * w0;
} else {
tmp = w0 * sqrt((1.0 - ((t_0 * 0.25) * ((t_0 * 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(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (abs(d) / abs(d_1)) * m
if (((((m * abs(d)) / (2.0d0 * abs(d_1))) ** 2.0d0) * (h / l)) <= (-2d+33)) then
tmp = (((abs(m) * sqrt(((-0.25d0) * (h / l)))) / abs(d_1)) * abs(d)) * w0
else
tmp = w0 * sqrt((1.0d0 - ((t_0 * 0.25d0) * ((t_0 * h) / l))))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (Math.abs(D) / Math.abs(d)) * M;
double tmp;
if ((Math.pow(((M * Math.abs(D)) / (2.0 * Math.abs(d))), 2.0) * (h / l)) <= -2e+33) {
tmp = (((Math.abs(M) * Math.sqrt((-0.25 * (h / l)))) / Math.abs(d)) * Math.abs(D)) * w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((t_0 * 0.25) * ((t_0 * h) / l))));
}
return tmp;
}
def code(w0, M, D, h, l, d): t_0 = (math.fabs(D) / math.fabs(d)) * M tmp = 0 if (math.pow(((M * math.fabs(D)) / (2.0 * math.fabs(d))), 2.0) * (h / l)) <= -2e+33: tmp = (((math.fabs(M) * math.sqrt((-0.25 * (h / l)))) / math.fabs(d)) * math.fabs(D)) * w0 else: tmp = w0 * math.sqrt((1.0 - ((t_0 * 0.25) * ((t_0 * h) / l)))) return tmp
function code(w0, M, D, h, l, d) t_0 = Float64(Float64(abs(D) / abs(d)) * M) tmp = 0.0 if (Float64((Float64(Float64(M * abs(D)) / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)) <= -2e+33) tmp = Float64(Float64(Float64(Float64(abs(M) * sqrt(Float64(-0.25 * Float64(h / l)))) / abs(d)) * abs(D)) * w0); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 * 0.25) * Float64(Float64(t_0 * h) / l))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) t_0 = (abs(D) / abs(d)) * M; tmp = 0.0; if (((((M * abs(D)) / (2.0 * abs(d))) ^ 2.0) * (h / l)) <= -2e+33) tmp = (((abs(M) * sqrt((-0.25 * (h / l)))) / abs(d)) * abs(D)) * w0; else tmp = w0 * sqrt((1.0 - ((t_0 * 0.25) * ((t_0 * h) / l)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(N[Abs[D], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(M * N[Abs[D], $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+33], N[(N[(N[(N[(N[Abs[M], $MachinePrecision] * N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * N[Abs[D], $MachinePrecision]), $MachinePrecision] * w0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 * 0.25), $MachinePrecision] * N[(N[(t$95$0 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{\left|D\right|}{\left|d\right|} \cdot M\\
\mathbf{if}\;{\left(\frac{M \cdot \left|D\right|}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+33}:\\
\;\;\;\;\left(\frac{\left|M\right| \cdot \sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot \left|D\right|\right) \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(t\_0 \cdot 0.25\right) \cdot \frac{t\_0 \cdot h}{\ell}}\\
\end{array}
if (*.f64 (pow.64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -1.9999999999999999e33Initial program 80.9%
Taylor expanded in D around inf
lower-*.f64N/A
lower-sqrt.64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.64N/A
lower-*.f64N/A
lower-pow.649.8%
Applied rewrites9.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f649.8%
Applied rewrites9.8%
lift-sqrt.64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
sqrt-prodN/A
lower-unsound-sqrt.32N/A
lower-sqrt.32N/A
lift-*.f64N/A
rem-sqrt-square-revN/A
lower-unsound-*.f64N/A
lower-fabs.64N/A
lower-unsound-sqrt.64N/A
lower-*.f6411.7%
Applied rewrites11.7%
Taylor expanded in d around 0
lower-/.f64N/A
lower-*.f64N/A
lower-fabs.64N/A
lower-sqrt.64N/A
lower-*.f64N/A
lower-/.f6413.9%
Applied rewrites13.9%
if -1.9999999999999999e33 < (*.f64 (pow.64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 80.9%
lift-pow.64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
metadata-evalN/A
cosh-0-revN/A
lower-/.f64N/A
Applied rewrites80.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6489.0%
Applied rewrites89.0%
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (* M (/ (fabs D) (fabs d)))))
(if (<= (* (pow (/ (* M (fabs D)) (* 2.0 (fabs d))) 2.0) (/ h l)) -2e+32)
(* (* (/ (* (fabs M) (sqrt (* -0.25 (/ h l)))) (fabs d)) (fabs D)) w0)
(* w0 (sqrt (fma (/ (* -0.25 t_0) l) (* h t_0) 1.0))))))double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * (fabs(D) / fabs(d));
double tmp;
if ((pow(((M * fabs(D)) / (2.0 * fabs(d))), 2.0) * (h / l)) <= -2e+32) {
tmp = (((fabs(M) * sqrt((-0.25 * (h / l)))) / fabs(d)) * fabs(D)) * w0;
} else {
tmp = w0 * sqrt(fma(((-0.25 * t_0) / l), (h * t_0), 1.0));
}
return tmp;
}
function code(w0, M, D, h, l, d) t_0 = Float64(M * Float64(abs(D) / abs(d))) tmp = 0.0 if (Float64((Float64(Float64(M * abs(D)) / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)) <= -2e+32) tmp = Float64(Float64(Float64(Float64(abs(M) * sqrt(Float64(-0.25 * Float64(h / l)))) / abs(d)) * abs(D)) * w0); else tmp = Float64(w0 * sqrt(fma(Float64(Float64(-0.25 * t_0) / l), Float64(h * t_0), 1.0))); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(N[Abs[D], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(M * N[Abs[D], $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+32], N[(N[(N[(N[(N[Abs[M], $MachinePrecision] * N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * N[Abs[D], $MachinePrecision]), $MachinePrecision] * w0), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(-0.25 * t$95$0), $MachinePrecision] / l), $MachinePrecision] * N[(h * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := M \cdot \frac{\left|D\right|}{\left|d\right|}\\
\mathbf{if}\;{\left(\frac{M \cdot \left|D\right|}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+32}:\\
\;\;\;\;\left(\frac{\left|M\right| \cdot \sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot \left|D\right|\right) \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-0.25 \cdot t\_0}{\ell}, h \cdot t\_0, 1\right)}\\
\end{array}
if (*.f64 (pow.64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.00000000000000011e32Initial program 80.9%
Taylor expanded in D around inf
lower-*.f64N/A
lower-sqrt.64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.64N/A
lower-*.f64N/A
lower-pow.649.8%
Applied rewrites9.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f649.8%
Applied rewrites9.8%
lift-sqrt.64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
sqrt-prodN/A
lower-unsound-sqrt.32N/A
lower-sqrt.32N/A
lift-*.f64N/A
rem-sqrt-square-revN/A
lower-unsound-*.f64N/A
lower-fabs.64N/A
lower-unsound-sqrt.64N/A
lower-*.f6411.7%
Applied rewrites11.7%
Taylor expanded in d around 0
lower-/.f64N/A
lower-*.f64N/A
lower-fabs.64N/A
lower-sqrt.64N/A
lower-*.f64N/A
lower-/.f6413.9%
Applied rewrites13.9%
if -2.00000000000000011e32 < (*.f64 (pow.64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 80.9%
lift-pow.64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
metadata-evalN/A
cosh-0-revN/A
lower-/.f64N/A
Applied rewrites80.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6489.0%
Applied rewrites89.0%
Applied rewrites89.0%
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (fmax (fabs M) (fabs D))) (t_1 (fmin (fabs M) (fabs D))))
(if (<=
(* (pow (/ (* t_1 t_0) (* 2.0 (fabs d))) 2.0) (/ h l))
-20000000000.0)
(* (* (/ (* (fabs t_1) (sqrt (* -0.25 (/ h l)))) (fabs d)) t_0) w0)
(* w0 1.0))))double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = fmax(fabs(M), fabs(D));
double t_1 = fmin(fabs(M), fabs(D));
double tmp;
if ((pow(((t_1 * t_0) / (2.0 * fabs(d))), 2.0) * (h / l)) <= -20000000000.0) {
tmp = (((fabs(t_1) * sqrt((-0.25 * (h / l)))) / fabs(d)) * t_0) * w0;
} else {
tmp = w0 * 1.0;
}
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(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax(abs(m), abs(d))
t_1 = fmin(abs(m), abs(d))
if (((((t_1 * t_0) / (2.0d0 * abs(d_1))) ** 2.0d0) * (h / l)) <= (-20000000000.0d0)) then
tmp = (((abs(t_1) * sqrt(((-0.25d0) * (h / l)))) / abs(d_1)) * t_0) * w0
else
tmp = w0 * 1.0d0
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = fmax(Math.abs(M), Math.abs(D));
double t_1 = fmin(Math.abs(M), Math.abs(D));
double tmp;
if ((Math.pow(((t_1 * t_0) / (2.0 * Math.abs(d))), 2.0) * (h / l)) <= -20000000000.0) {
tmp = (((Math.abs(t_1) * Math.sqrt((-0.25 * (h / l)))) / Math.abs(d)) * t_0) * w0;
} else {
tmp = w0 * 1.0;
}
return tmp;
}
def code(w0, M, D, h, l, d): t_0 = fmax(math.fabs(M), math.fabs(D)) t_1 = fmin(math.fabs(M), math.fabs(D)) tmp = 0 if (math.pow(((t_1 * t_0) / (2.0 * math.fabs(d))), 2.0) * (h / l)) <= -20000000000.0: tmp = (((math.fabs(t_1) * math.sqrt((-0.25 * (h / l)))) / math.fabs(d)) * t_0) * w0 else: tmp = w0 * 1.0 return tmp
function code(w0, M, D, h, l, d) t_0 = fmax(abs(M), abs(D)) t_1 = fmin(abs(M), abs(D)) tmp = 0.0 if (Float64((Float64(Float64(t_1 * t_0) / Float64(2.0 * abs(d))) ^ 2.0) * Float64(h / l)) <= -20000000000.0) tmp = Float64(Float64(Float64(Float64(abs(t_1) * sqrt(Float64(-0.25 * Float64(h / l)))) / abs(d)) * t_0) * w0); else tmp = Float64(w0 * 1.0); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) t_0 = max(abs(M), abs(D)); t_1 = min(abs(M), abs(D)); tmp = 0.0; if (((((t_1 * t_0) / (2.0 * abs(d))) ^ 2.0) * (h / l)) <= -20000000000.0) tmp = (((abs(t_1) * sqrt((-0.25 * (h / l)))) / abs(d)) * t_0) * w0; else tmp = w0 * 1.0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[Max[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[M], $MachinePrecision], N[Abs[D], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(t$95$1 * t$95$0), $MachinePrecision] / N[(2.0 * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -20000000000.0], N[(N[(N[(N[(N[Abs[t$95$1], $MachinePrecision] * N[Sqrt[N[(-0.25 * N[(h / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * w0), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|M\right|, \left|D\right|\right)\\
t_1 := \mathsf{min}\left(\left|M\right|, \left|D\right|\right)\\
\mathbf{if}\;{\left(\frac{t\_1 \cdot t\_0}{2 \cdot \left|d\right|}\right)}^{2} \cdot \frac{h}{\ell} \leq -20000000000:\\
\;\;\;\;\left(\frac{\left|t\_1\right| \cdot \sqrt{-0.25 \cdot \frac{h}{\ell}}}{\left|d\right|} \cdot t\_0\right) \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
if (*.f64 (pow.64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2e10Initial program 80.9%
Taylor expanded in D around inf
lower-*.f64N/A
lower-sqrt.64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-pow.64N/A
lower-*.f64N/A
lower-pow.649.8%
Applied rewrites9.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f649.8%
Applied rewrites9.8%
lift-sqrt.64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
sqrt-prodN/A
lower-unsound-sqrt.32N/A
lower-sqrt.32N/A
lift-*.f64N/A
rem-sqrt-square-revN/A
lower-unsound-*.f64N/A
lower-fabs.64N/A
lower-unsound-sqrt.64N/A
lower-*.f6411.7%
Applied rewrites11.7%
Taylor expanded in d around 0
lower-/.f64N/A
lower-*.f64N/A
lower-fabs.64N/A
lower-sqrt.64N/A
lower-*.f64N/A
lower-/.f6413.9%
Applied rewrites13.9%
if -2e10 < (*.f64 (pow.64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 80.9%
Taylor expanded in M around 0
Applied rewrites68.4%
(FPCore (w0 M D h l d) :precision binary64 (* w0 1.0))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * 1.0;
}
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(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * 1.0d0
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * 1.0;
}
def code(w0, M, D, h, l, d): return w0 * 1.0
function code(w0, M, D, h, l, d) return Float64(w0 * 1.0) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * 1.0; end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
w0 \cdot 1
Initial program 80.9%
Taylor expanded in M around 0
Applied rewrites68.4%
herbie shell --seed 2025183
(FPCore (w0 M D h l d)
:name "Henrywood and Agarwal, Equation (9a)"
:precision binary64
(* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))