
(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))));
}
real(8) function code(w0, m, d, h, l, d_1)
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]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 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))));
}
real(8) function code(w0, m, d, h, l, d_1)
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]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (/ (* M D) (* 2.0 d))))
(if (<= (* (pow t_0 2.0) (/ h l)) 5e-10)
(* w0 (sqrt (fma t_0 (* (/ h l) (/ (* M D) (* d -2.0))) 1.0)))
(*
w0
(sqrt
(fma (* (* M h) (/ D (* -2.0 (* d l)))) (* 0.5 (* D (/ M d))) 1.0))))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (M * D) / (2.0 * d);
double tmp;
if ((pow(t_0, 2.0) * (h / l)) <= 5e-10) {
tmp = w0 * sqrt(fma(t_0, ((h / l) * ((M * D) / (d * -2.0))), 1.0));
} else {
tmp = w0 * sqrt(fma(((M * h) * (D / (-2.0 * (d * l)))), (0.5 * (D * (M / d))), 1.0));
}
return tmp;
}
function code(w0, M, D, h, l, d) t_0 = Float64(Float64(M * D) / Float64(2.0 * d)) tmp = 0.0 if (Float64((t_0 ^ 2.0) * Float64(h / l)) <= 5e-10) tmp = Float64(w0 * sqrt(fma(t_0, Float64(Float64(h / l) * Float64(Float64(M * D) / Float64(d * -2.0))), 1.0))); else tmp = Float64(w0 * sqrt(fma(Float64(Float64(M * h) * Float64(D / Float64(-2.0 * Float64(d * l)))), Float64(0.5 * Float64(D * Float64(M / d))), 1.0))); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 5e-10], N[(w0 * N[Sqrt[N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(M * h), $MachinePrecision] * N[(D / N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{2 \cdot d}\\
\mathbf{if}\;{t\_0}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{-10}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0, \frac{h}{\ell} \cdot \frac{M \cdot D}{d \cdot -2}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot h\right) \cdot \frac{D}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < 5.00000000000000031e-10Initial program 87.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-pow.f64N/A
unpow2N/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites88.0%
if 5.00000000000000031e-10 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 0.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-pow.f64N/A
unpow2N/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites11.7%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6411.7
Applied rewrites84.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6489.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6489.7
Applied rewrites89.7%
Final simplification88.1%
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (* M (/ D d))))
(if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) 5e-10)
(* w0 (sqrt (fma (* t_0 -0.5) (* (/ h l) (* 0.5 t_0)) 1.0)))
(*
w0
(sqrt
(fma (* (* M h) (/ D (* -2.0 (* d l)))) (* 0.5 (* D (/ M d))) 1.0))))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * (D / d);
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 5e-10) {
tmp = w0 * sqrt(fma((t_0 * -0.5), ((h / l) * (0.5 * t_0)), 1.0));
} else {
tmp = w0 * sqrt(fma(((M * h) * (D / (-2.0 * (d * l)))), (0.5 * (D * (M / d))), 1.0));
}
return tmp;
}
function code(w0, M, D, h, l, d) t_0 = Float64(M * Float64(D / d)) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= 5e-10) tmp = Float64(w0 * sqrt(fma(Float64(t_0 * -0.5), Float64(Float64(h / l) * Float64(0.5 * t_0)), 1.0))); else tmp = Float64(w0 * sqrt(fma(Float64(Float64(M * h) * Float64(D / Float64(-2.0 * Float64(d * l)))), Float64(0.5 * Float64(D * Float64(M / d))), 1.0))); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 5e-10], N[(w0 * N[Sqrt[N[(N[(t$95$0 * -0.5), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(M * h), $MachinePrecision] * N[(D / N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d}\\
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{-10}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(t\_0 \cdot -0.5, \frac{h}{\ell} \cdot \left(0.5 \cdot t\_0\right), 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot h\right) \cdot \frac{D}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < 5.00000000000000031e-10Initial program 87.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-pow.f64N/A
unpow2N/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites88.0%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites88.3%
if 5.00000000000000031e-10 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 0.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-pow.f64N/A
unpow2N/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites11.7%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6411.7
Applied rewrites84.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6489.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6489.7
Applied rewrites89.7%
Final simplification88.4%
(FPCore (w0 M D h l d)
:precision binary64
(if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -5e-8)
(*
w0
(sqrt
(+ 1.0 (/ (* (* M D) (* D (* M h))) (* (* -2.0 (* d l)) (* 2.0 d))))))
(* w0 1.0)))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e-8) {
tmp = w0 * sqrt((1.0 + (((M * D) * (D * (M * h))) / ((-2.0 * (d * l)) * (2.0 * d)))));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
real(8) function code(w0, m, d, h, l, d_1)
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) :: tmp
if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-5d-8)) then
tmp = w0 * sqrt((1.0d0 + (((m * d) * (d * (m * h))) / (((-2.0d0) * (d_1 * l)) * (2.0d0 * d_1)))))
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 tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e-8) {
tmp = w0 * Math.sqrt((1.0 + (((M * D) * (D * (M * h))) / ((-2.0 * (d * l)) * (2.0 * d)))));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e-8: tmp = w0 * math.sqrt((1.0 + (((M * D) * (D * (M * h))) / ((-2.0 * (d * l)) * (2.0 * d))))) else: tmp = w0 * 1.0 return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e-8) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(M * D) * Float64(D * Float64(M * h))) / Float64(Float64(-2.0 * Float64(d * l)) * Float64(2.0 * d)))))); else tmp = Float64(w0 * 1.0); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -5e-8) tmp = w0 * sqrt((1.0 + (((M * D) * (D * (M * h))) / ((-2.0 * (d * l)) * (2.0 * d))))); else tmp = w0 * 1.0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e-8], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(M * D), $MachinePrecision] * N[(D * N[(M * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision] * N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{-8}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\left(M \cdot D\right) \cdot \left(D \cdot \left(M \cdot h\right)\right)}{\left(-2 \cdot \left(d \cdot \ell\right)\right) \cdot \left(2 \cdot d\right)}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.9999999999999998e-8Initial program 67.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-pow.f64N/A
unpow2N/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites69.2%
Applied rewrites53.3%
if -4.9999999999999998e-8 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 89.0%
Taylor expanded in h around 0
Applied rewrites97.9%
Final simplification81.7%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -50000.0) (* w0 (sqrt (* D (* D (* (* M -0.25) (/ (* M h) (* d (* d l)))))))) (* w0 1.0)))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -50000.0) {
tmp = w0 * sqrt((D * (D * ((M * -0.25) * ((M * h) / (d * (d * l)))))));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
real(8) function code(w0, m, d, h, l, d_1)
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) :: tmp
if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-50000.0d0)) then
tmp = w0 * sqrt((d * (d * ((m * (-0.25d0)) * ((m * h) / (d_1 * (d_1 * l)))))))
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 tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -50000.0) {
tmp = w0 * Math.sqrt((D * (D * ((M * -0.25) * ((M * h) / (d * (d * l)))))));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -50000.0: tmp = w0 * math.sqrt((D * (D * ((M * -0.25) * ((M * h) / (d * (d * l))))))) else: tmp = w0 * 1.0 return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -50000.0) tmp = Float64(w0 * sqrt(Float64(D * Float64(D * Float64(Float64(M * -0.25) * Float64(Float64(M * h) / Float64(d * Float64(d * l)))))))); else tmp = Float64(w0 * 1.0); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -50000.0) tmp = w0 * sqrt((D * (D * ((M * -0.25) * ((M * h) / (d * (d * l))))))); else tmp = w0 * 1.0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -50000.0], N[(w0 * N[Sqrt[N[(D * N[(D * N[(N[(M * -0.25), $MachinePrecision] * N[(N[(M * h), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -50000:\\
\;\;\;\;w0 \cdot \sqrt{D \cdot \left(D \cdot \left(\left(M \cdot -0.25\right) \cdot \frac{M \cdot h}{d \cdot \left(d \cdot \ell\right)}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5e4Initial program 66.1%
Taylor expanded in h around inf
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6439.0
Applied rewrites39.0%
Applied rewrites43.6%
Applied rewrites46.5%
Applied rewrites51.1%
if -5e4 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 89.1%
Taylor expanded in h around 0
Applied rewrites96.9%
Final simplification80.8%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -4e+188) (fma (* D D) (* (* M -0.125) (* M (/ (* h w0) (* d (* d l))))) w0) (* w0 1.0)))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -4e+188) {
tmp = fma((D * D), ((M * -0.125) * (M * ((h * w0) / (d * (d * l))))), w0);
} else {
tmp = w0 * 1.0;
}
return tmp;
}
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -4e+188) tmp = fma(Float64(D * D), Float64(Float64(M * -0.125) * Float64(M * Float64(Float64(h * w0) / Float64(d * Float64(d * l))))), w0); else tmp = Float64(w0 * 1.0); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -4e+188], N[(N[(D * D), $MachinePrecision] * N[(N[(M * -0.125), $MachinePrecision] * N[(M * N[(N[(h * w0), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -4 \cdot 10^{+188}:\\
\;\;\;\;\mathsf{fma}\left(D \cdot D, \left(M \cdot -0.125\right) \cdot \left(M \cdot \frac{h \cdot w0}{d \cdot \left(d \cdot \ell\right)}\right), w0\right)\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.0000000000000001e188Initial program 61.0%
Taylor expanded in h around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.4%
Applied rewrites49.0%
if -4.0000000000000001e188 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 89.8%
Taylor expanded in h around 0
Applied rewrites91.0%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -4e+188) (* D (* (* D -0.125) (/ (* M (* M (* h w0))) (* d (* d l))))) (* w0 1.0)))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -4e+188) {
tmp = D * ((D * -0.125) * ((M * (M * (h * w0))) / (d * (d * l))));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
real(8) function code(w0, m, d, h, l, d_1)
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) :: tmp
if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-4d+188)) then
tmp = d * ((d * (-0.125d0)) * ((m * (m * (h * w0))) / (d_1 * (d_1 * l))))
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 tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -4e+188) {
tmp = D * ((D * -0.125) * ((M * (M * (h * w0))) / (d * (d * l))));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -4e+188: tmp = D * ((D * -0.125) * ((M * (M * (h * w0))) / (d * (d * l)))) else: tmp = w0 * 1.0 return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -4e+188) tmp = Float64(D * Float64(Float64(D * -0.125) * Float64(Float64(M * Float64(M * Float64(h * w0))) / Float64(d * Float64(d * l))))); else tmp = Float64(w0 * 1.0); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -4e+188) tmp = D * ((D * -0.125) * ((M * (M * (h * w0))) / (d * (d * l)))); else tmp = w0 * 1.0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -4e+188], N[(D * N[(N[(D * -0.125), $MachinePrecision] * N[(N[(M * N[(M * N[(h * w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -4 \cdot 10^{+188}:\\
\;\;\;\;D \cdot \left(\left(D \cdot -0.125\right) \cdot \frac{M \cdot \left(M \cdot \left(h \cdot w0\right)\right)}{d \cdot \left(d \cdot \ell\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.0000000000000001e188Initial program 61.0%
Taylor expanded in h around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.4%
Taylor expanded in h around inf
Applied rewrites42.5%
Applied rewrites50.6%
if -4.0000000000000001e188 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 89.8%
Taylor expanded in h around 0
Applied rewrites91.0%
(FPCore (w0 M D h l d)
:precision binary64
(if (<= M 5e-141)
(*
w0
(sqrt (fma (/ (* D (* M h)) (* -2.0 (* d l))) (* 0.5 (* D (/ M d))) 1.0)))
(*
w0
(sqrt (fma (* (/ h l) (* (* (* M M) 0.25) (/ D (- d)))) (/ D d) 1.0)))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 5e-141) {
tmp = w0 * sqrt(fma(((D * (M * h)) / (-2.0 * (d * l))), (0.5 * (D * (M / d))), 1.0));
} else {
tmp = w0 * sqrt(fma(((h / l) * (((M * M) * 0.25) * (D / -d))), (D / d), 1.0));
}
return tmp;
}
function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 5e-141) tmp = Float64(w0 * sqrt(fma(Float64(Float64(D * Float64(M * h)) / Float64(-2.0 * Float64(d * l))), Float64(0.5 * Float64(D * Float64(M / d))), 1.0))); else tmp = Float64(w0 * sqrt(fma(Float64(Float64(h / l) * Float64(Float64(Float64(M * M) * 0.25) * Float64(D / Float64(-d)))), Float64(D / d), 1.0))); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 5e-141], N[(w0 * N[Sqrt[N[(N[(N[(D * N[(M * h), $MachinePrecision]), $MachinePrecision] / N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(h / l), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * 0.25), $MachinePrecision] * N[(D / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 5 \cdot 10^{-141}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{D \cdot \left(M \cdot h\right)}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\left(\left(M \cdot M\right) \cdot 0.25\right) \cdot \frac{D}{-d}\right), \frac{D}{d}, 1\right)}\\
\end{array}
\end{array}
if M < 4.9999999999999999e-141Initial program 82.5%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-pow.f64N/A
unpow2N/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites84.3%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6484.3
Applied rewrites83.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6483.8
Applied rewrites83.8%
if 4.9999999999999999e-141 < M Initial program 78.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
Applied rewrites71.7%
Final simplification79.6%
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (fma (* (* M h) (/ D (* -2.0 (* d l)))) (* 0.5 (* D (/ M d))) 1.0))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt(fma(((M * h) * (D / (-2.0 * (d * l)))), (0.5 * (D * (M / d))), 1.0));
}
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(fma(Float64(Float64(M * h) * Float64(D / Float64(-2.0 * Float64(d * l)))), Float64(0.5 * Float64(D * Float64(M / d))), 1.0))) end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(N[(N[(M * h), $MachinePrecision] * N[(D / N[(-2.0 * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{\mathsf{fma}\left(\left(M \cdot h\right) \cdot \frac{D}{-2 \cdot \left(d \cdot \ell\right)}, 0.5 \cdot \left(D \cdot \frac{M}{d}\right), 1\right)}
\end{array}
Initial program 81.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-pow.f64N/A
unpow2N/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites82.6%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6482.6
Applied rewrites79.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6480.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.3
Applied rewrites80.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6480.7
Applied rewrites80.7%
Final simplification80.7%
(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;
}
real(8) function code(w0, m, d, h, l, d_1)
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]
\begin{array}{l}
\\
w0 \cdot 1
\end{array}
Initial program 81.0%
Taylor expanded in h around 0
Applied rewrites64.6%
herbie shell --seed 2024235
(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))))))