
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma A (* C -4.0) (pow B 2.0))))
(if (<= (pow B 2.0) 2e-30)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (+ A A))))) t_0)
(/ (sqrt (* (- A (hypot B A)) (* 2.0 F))) (- B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(A, (C * -4.0), pow(B, 2.0));
double tmp;
if (pow(B, 2.0) <= 2e-30) {
tmp = -sqrt((2.0 * ((t_0 * F) * (A + A)))) / t_0;
} else {
tmp = sqrt(((A - hypot(B, A)) * (2.0 * F))) / -B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(A, Float64(C * -4.0), (B ^ 2.0)) tmp = 0.0 if ((B ^ 2.0) <= 2e-30) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(A + A))))) / t_0); else tmp = Float64(sqrt(Float64(Float64(A - hypot(B, A)) * Float64(2.0 * F))) / Float64(-B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-30], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B)), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-30}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot \left(2 \cdot F\right)}}{-B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2e-30Initial program 19.9%
Simplified31.9%
Taylor expanded in C around inf 22.9%
cancel-sign-sub-inv22.9%
metadata-eval22.9%
*-lft-identity22.9%
Simplified22.9%
if 2e-30 < (pow.f64 B 2) Initial program 20.2%
Simplified22.7%
Taylor expanded in C around 0 11.3%
mul-1-neg11.3%
distribute-rgt-neg-in11.3%
+-commutative11.3%
unpow211.3%
unpow211.3%
hypot-def25.2%
Simplified25.2%
associate-*l/25.2%
frac-2neg25.2%
Applied egg-rr25.4%
associate-*r*25.4%
*-commutative25.4%
Simplified25.4%
Final simplification24.0%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (sqrt (* -8.0 (* (* F (* A C)) (* 2.0 A))))))
(if (<= (pow B 2.0) 5e-149)
(/ (- t_1) t_0)
(if (<= (pow B 2.0) 1e-59)
(- (/ (sqrt (* 2.0 (* t_0 (* F (- (+ A C) (hypot B (- A C))))))) t_0))
(if (<= (pow B 2.0) 2e-30)
(* t_1 (/ -1.0 t_0))
(/ (sqrt (* (- A (hypot B A)) (* 2.0 F))) (- B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double t_1 = sqrt((-8.0 * ((F * (A * C)) * (2.0 * A))));
double tmp;
if (pow(B, 2.0) <= 5e-149) {
tmp = -t_1 / t_0;
} else if (pow(B, 2.0) <= 1e-59) {
tmp = -(sqrt((2.0 * (t_0 * (F * ((A + C) - hypot(B, (A - C))))))) / t_0);
} else if (pow(B, 2.0) <= 2e-30) {
tmp = t_1 * (-1.0 / t_0);
} else {
tmp = sqrt(((A - hypot(B, A)) * (2.0 * F))) / -B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A * C)) * Float64(2.0 * A)))) tmp = 0.0 if ((B ^ 2.0) <= 5e-149) tmp = Float64(Float64(-t_1) / t_0); elseif ((B ^ 2.0) <= 1e-59) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(Float64(A + C) - hypot(B, Float64(A - C))))))) / t_0)); elseif ((B ^ 2.0) <= 2e-30) tmp = Float64(t_1 * Float64(-1.0 / t_0)); else tmp = Float64(sqrt(Float64(Float64(A - hypot(B, A)) * Float64(2.0 * F))) / Float64(-B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(-8.0 * N[(N[(F * N[(A * C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-149], N[((-t$95$1) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e-59], (-N[(N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(N[(A + C), $MachinePrecision] - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-30], N[(t$95$1 * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B)), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \sqrt{-8 \cdot \left(\left(F \cdot \left(A \cdot C\right)\right) \cdot \left(2 \cdot A\right)\right)}\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-149}:\\
\;\;\;\;\frac{-t_1}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 10^{-59}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{-30}:\\
\;\;\;\;t_1 \cdot \frac{-1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot \left(2 \cdot F\right)}}{-B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.99999999999999968e-149Initial program 16.7%
Simplified27.0%
Taylor expanded in C around inf 21.0%
associate-*r*22.6%
*-commutative22.6%
cancel-sign-sub-inv22.6%
metadata-eval22.6%
*-lft-identity22.6%
Simplified22.6%
distribute-frac-neg22.6%
associate-*r*22.6%
metadata-eval22.6%
associate-*r*23.8%
*-commutative23.8%
count-223.8%
Applied egg-rr23.8%
if 4.99999999999999968e-149 < (pow.f64 B 2) < 1e-59Initial program 36.2%
Simplified43.9%
if 1e-59 < (pow.f64 B 2) < 2e-30Initial program 3.0%
Simplified28.1%
Taylor expanded in C around inf 25.8%
associate-*r*25.8%
*-commutative25.8%
cancel-sign-sub-inv25.8%
metadata-eval25.8%
*-lft-identity25.8%
Simplified25.8%
div-inv25.8%
associate-*r*25.8%
metadata-eval25.8%
associate-*r*25.8%
*-commutative25.8%
count-225.8%
Applied egg-rr25.8%
if 2e-30 < (pow.f64 B 2) Initial program 20.2%
Simplified22.7%
Taylor expanded in C around 0 11.3%
mul-1-neg11.3%
distribute-rgt-neg-in11.3%
+-commutative11.3%
unpow211.3%
unpow211.3%
hypot-def25.2%
Simplified25.2%
associate-*l/25.2%
frac-2neg25.2%
Applied egg-rr25.4%
associate-*r*25.4%
*-commutative25.4%
Simplified25.4%
Final simplification26.6%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (sqrt (* (- A (hypot B A)) (* 2.0 F))))
(t_1 (fma B B (* A (* C -4.0))))
(t_2 (- (sqrt (* -8.0 (* (* F (* A C)) (* 2.0 A)))))))
(if (<= (pow B 2.0) 5e-149)
(/ t_2 t_1)
(if (<= (pow B 2.0) 4e-96)
(/ -1.0 (/ B t_0))
(if (<= (pow B 2.0) 2e-30) (pow (/ t_1 t_2) -1.0) (/ t_0 (- B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(((A - hypot(B, A)) * (2.0 * F)));
double t_1 = fma(B, B, (A * (C * -4.0)));
double t_2 = -sqrt((-8.0 * ((F * (A * C)) * (2.0 * A))));
double tmp;
if (pow(B, 2.0) <= 5e-149) {
tmp = t_2 / t_1;
} else if (pow(B, 2.0) <= 4e-96) {
tmp = -1.0 / (B / t_0);
} else if (pow(B, 2.0) <= 2e-30) {
tmp = pow((t_1 / t_2), -1.0);
} else {
tmp = t_0 / -B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = sqrt(Float64(Float64(A - hypot(B, A)) * Float64(2.0 * F))) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) t_2 = Float64(-sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A * C)) * Float64(2.0 * A))))) tmp = 0.0 if ((B ^ 2.0) <= 5e-149) tmp = Float64(t_2 / t_1); elseif ((B ^ 2.0) <= 4e-96) tmp = Float64(-1.0 / Float64(B / t_0)); elseif ((B ^ 2.0) <= 2e-30) tmp = Float64(t_1 / t_2) ^ -1.0; else tmp = Float64(t_0 / Float64(-B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[Sqrt[N[(-8.0 * N[(N[(F * N[(A * C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-149], N[(t$95$2 / t$95$1), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 4e-96], N[(-1.0 / N[(B / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-30], N[Power[N[(t$95$1 / t$95$2), $MachinePrecision], -1.0], $MachinePrecision], N[(t$95$0 / (-B)), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot \left(2 \cdot F\right)}\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := -\sqrt{-8 \cdot \left(\left(F \cdot \left(A \cdot C\right)\right) \cdot \left(2 \cdot A\right)\right)}\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-149}:\\
\;\;\;\;\frac{t_2}{t_1}\\
\mathbf{elif}\;{B}^{2} \leq 4 \cdot 10^{-96}:\\
\;\;\;\;\frac{-1}{\frac{B}{t_0}}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{-30}:\\
\;\;\;\;{\left(\frac{t_1}{t_2}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{-B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.99999999999999968e-149Initial program 16.7%
Simplified27.0%
Taylor expanded in C around inf 21.0%
associate-*r*22.6%
*-commutative22.6%
cancel-sign-sub-inv22.6%
metadata-eval22.6%
*-lft-identity22.6%
Simplified22.6%
distribute-frac-neg22.6%
associate-*r*22.6%
metadata-eval22.6%
associate-*r*23.8%
*-commutative23.8%
count-223.8%
Applied egg-rr23.8%
if 4.99999999999999968e-149 < (pow.f64 B 2) < 3.9999999999999996e-96Initial program 37.6%
Simplified38.9%
Taylor expanded in C around 0 23.4%
associate-*l*23.4%
+-commutative23.4%
unpow223.4%
unpow223.4%
hypot-def23.6%
Simplified23.6%
clear-num23.6%
inv-pow23.6%
sqrt-unprod23.5%
Applied egg-rr23.5%
unpow-123.5%
associate-/r*23.7%
*-commutative23.7%
associate-*r*23.7%
Simplified23.7%
Taylor expanded in A around 0 23.7%
if 3.9999999999999996e-96 < (pow.f64 B 2) < 2e-30Initial program 26.7%
Simplified39.2%
Taylor expanded in C around inf 21.2%
associate-*r*21.2%
*-commutative21.2%
cancel-sign-sub-inv21.2%
metadata-eval21.2%
*-lft-identity21.2%
Simplified21.2%
clear-num21.4%
inv-pow21.4%
associate-*r*21.4%
metadata-eval21.4%
associate-*r*21.4%
*-commutative21.4%
count-221.4%
Applied egg-rr21.4%
if 2e-30 < (pow.f64 B 2) Initial program 20.2%
Simplified22.7%
Taylor expanded in C around 0 11.3%
mul-1-neg11.3%
distribute-rgt-neg-in11.3%
+-commutative11.3%
unpow211.3%
unpow211.3%
hypot-def25.2%
Simplified25.2%
associate-*l/25.2%
frac-2neg25.2%
Applied egg-rr25.4%
associate-*r*25.4%
*-commutative25.4%
Simplified25.4%
Final simplification24.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (sqrt (* (- A (hypot B A)) (* 2.0 F))))
(t_1 (fma B B (* A (* C -4.0))))
(t_2 (- (sqrt (* -8.0 (* (* F (* A C)) (* 2.0 A)))))))
(if (<= (pow B 2.0) 5e-149)
(/ t_2 t_1)
(if (<= (pow B 2.0) 4e-96)
(/ -1.0 (/ (/ (fma A (* C -4.0) (pow B 2.0)) B) t_0))
(if (<= (pow B 2.0) 2e-30) (pow (/ t_1 t_2) -1.0) (/ t_0 (- B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(((A - hypot(B, A)) * (2.0 * F)));
double t_1 = fma(B, B, (A * (C * -4.0)));
double t_2 = -sqrt((-8.0 * ((F * (A * C)) * (2.0 * A))));
double tmp;
if (pow(B, 2.0) <= 5e-149) {
tmp = t_2 / t_1;
} else if (pow(B, 2.0) <= 4e-96) {
tmp = -1.0 / ((fma(A, (C * -4.0), pow(B, 2.0)) / B) / t_0);
} else if (pow(B, 2.0) <= 2e-30) {
tmp = pow((t_1 / t_2), -1.0);
} else {
tmp = t_0 / -B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = sqrt(Float64(Float64(A - hypot(B, A)) * Float64(2.0 * F))) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) t_2 = Float64(-sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A * C)) * Float64(2.0 * A))))) tmp = 0.0 if ((B ^ 2.0) <= 5e-149) tmp = Float64(t_2 / t_1); elseif ((B ^ 2.0) <= 4e-96) tmp = Float64(-1.0 / Float64(Float64(fma(A, Float64(C * -4.0), (B ^ 2.0)) / B) / t_0)); elseif ((B ^ 2.0) <= 2e-30) tmp = Float64(t_1 / t_2) ^ -1.0; else tmp = Float64(t_0 / Float64(-B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[Sqrt[N[(-8.0 * N[(N[(F * N[(A * C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-149], N[(t$95$2 / t$95$1), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 4e-96], N[(-1.0 / N[(N[(N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-30], N[Power[N[(t$95$1 / t$95$2), $MachinePrecision], -1.0], $MachinePrecision], N[(t$95$0 / (-B)), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot \left(2 \cdot F\right)}\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := -\sqrt{-8 \cdot \left(\left(F \cdot \left(A \cdot C\right)\right) \cdot \left(2 \cdot A\right)\right)}\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-149}:\\
\;\;\;\;\frac{t_2}{t_1}\\
\mathbf{elif}\;{B}^{2} \leq 4 \cdot 10^{-96}:\\
\;\;\;\;\frac{-1}{\frac{\frac{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}{B}}{t_0}}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{-30}:\\
\;\;\;\;{\left(\frac{t_1}{t_2}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{-B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.99999999999999968e-149Initial program 16.7%
Simplified27.0%
Taylor expanded in C around inf 21.0%
associate-*r*22.6%
*-commutative22.6%
cancel-sign-sub-inv22.6%
metadata-eval22.6%
*-lft-identity22.6%
Simplified22.6%
distribute-frac-neg22.6%
associate-*r*22.6%
metadata-eval22.6%
associate-*r*23.8%
*-commutative23.8%
count-223.8%
Applied egg-rr23.8%
if 4.99999999999999968e-149 < (pow.f64 B 2) < 3.9999999999999996e-96Initial program 37.6%
Simplified38.9%
Taylor expanded in C around 0 23.4%
associate-*l*23.4%
+-commutative23.4%
unpow223.4%
unpow223.4%
hypot-def23.6%
Simplified23.6%
clear-num23.6%
inv-pow23.6%
sqrt-unprod23.5%
Applied egg-rr23.5%
unpow-123.5%
associate-/r*23.7%
*-commutative23.7%
associate-*r*23.7%
Simplified23.7%
if 3.9999999999999996e-96 < (pow.f64 B 2) < 2e-30Initial program 26.7%
Simplified39.2%
Taylor expanded in C around inf 21.2%
associate-*r*21.2%
*-commutative21.2%
cancel-sign-sub-inv21.2%
metadata-eval21.2%
*-lft-identity21.2%
Simplified21.2%
clear-num21.4%
inv-pow21.4%
associate-*r*21.4%
metadata-eval21.4%
associate-*r*21.4%
*-commutative21.4%
count-221.4%
Applied egg-rr21.4%
if 2e-30 < (pow.f64 B 2) Initial program 20.2%
Simplified22.7%
Taylor expanded in C around 0 11.3%
mul-1-neg11.3%
distribute-rgt-neg-in11.3%
+-commutative11.3%
unpow211.3%
unpow211.3%
hypot-def25.2%
Simplified25.2%
associate-*l/25.2%
frac-2neg25.2%
Applied egg-rr25.4%
associate-*r*25.4%
*-commutative25.4%
Simplified25.4%
Final simplification24.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (sqrt (* (- A (hypot B A)) (* 2.0 F))))
(t_1 (fma B B (* A (* C -4.0))))
(t_2 (sqrt (* -8.0 (* (* F (* A C)) (* 2.0 A))))))
(if (<= (pow B 2.0) 5e-149)
(/ (- t_2) t_1)
(if (<= (pow B 2.0) 4e-96)
(/ -1.0 (/ B t_0))
(if (<= (pow B 2.0) 2e-30) (* t_2 (/ -1.0 t_1)) (/ t_0 (- B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(((A - hypot(B, A)) * (2.0 * F)));
double t_1 = fma(B, B, (A * (C * -4.0)));
double t_2 = sqrt((-8.0 * ((F * (A * C)) * (2.0 * A))));
double tmp;
if (pow(B, 2.0) <= 5e-149) {
tmp = -t_2 / t_1;
} else if (pow(B, 2.0) <= 4e-96) {
tmp = -1.0 / (B / t_0);
} else if (pow(B, 2.0) <= 2e-30) {
tmp = t_2 * (-1.0 / t_1);
} else {
tmp = t_0 / -B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = sqrt(Float64(Float64(A - hypot(B, A)) * Float64(2.0 * F))) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) t_2 = sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A * C)) * Float64(2.0 * A)))) tmp = 0.0 if ((B ^ 2.0) <= 5e-149) tmp = Float64(Float64(-t_2) / t_1); elseif ((B ^ 2.0) <= 4e-96) tmp = Float64(-1.0 / Float64(B / t_0)); elseif ((B ^ 2.0) <= 2e-30) tmp = Float64(t_2 * Float64(-1.0 / t_1)); else tmp = Float64(t_0 / Float64(-B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(-8.0 * N[(N[(F * N[(A * C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-149], N[((-t$95$2) / t$95$1), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 4e-96], N[(-1.0 / N[(B / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-30], N[(t$95$2 * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / (-B)), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot \left(2 \cdot F\right)}\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := \sqrt{-8 \cdot \left(\left(F \cdot \left(A \cdot C\right)\right) \cdot \left(2 \cdot A\right)\right)}\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-149}:\\
\;\;\;\;\frac{-t_2}{t_1}\\
\mathbf{elif}\;{B}^{2} \leq 4 \cdot 10^{-96}:\\
\;\;\;\;\frac{-1}{\frac{B}{t_0}}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{-30}:\\
\;\;\;\;t_2 \cdot \frac{-1}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{-B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.99999999999999968e-149Initial program 16.7%
Simplified27.0%
Taylor expanded in C around inf 21.0%
associate-*r*22.6%
*-commutative22.6%
cancel-sign-sub-inv22.6%
metadata-eval22.6%
*-lft-identity22.6%
Simplified22.6%
distribute-frac-neg22.6%
associate-*r*22.6%
metadata-eval22.6%
associate-*r*23.8%
*-commutative23.8%
count-223.8%
Applied egg-rr23.8%
if 4.99999999999999968e-149 < (pow.f64 B 2) < 3.9999999999999996e-96Initial program 37.6%
Simplified38.9%
Taylor expanded in C around 0 23.4%
associate-*l*23.4%
+-commutative23.4%
unpow223.4%
unpow223.4%
hypot-def23.6%
Simplified23.6%
clear-num23.6%
inv-pow23.6%
sqrt-unprod23.5%
Applied egg-rr23.5%
unpow-123.5%
associate-/r*23.7%
*-commutative23.7%
associate-*r*23.7%
Simplified23.7%
Taylor expanded in A around 0 23.7%
if 3.9999999999999996e-96 < (pow.f64 B 2) < 2e-30Initial program 26.7%
Simplified39.2%
Taylor expanded in C around inf 21.2%
associate-*r*21.2%
*-commutative21.2%
cancel-sign-sub-inv21.2%
metadata-eval21.2%
*-lft-identity21.2%
Simplified21.2%
div-inv21.2%
associate-*r*21.2%
metadata-eval21.2%
associate-*r*21.2%
*-commutative21.2%
count-221.2%
Applied egg-rr21.2%
if 2e-30 < (pow.f64 B 2) Initial program 20.2%
Simplified22.7%
Taylor expanded in C around 0 11.3%
mul-1-neg11.3%
distribute-rgt-neg-in11.3%
+-commutative11.3%
unpow211.3%
unpow211.3%
hypot-def25.2%
Simplified25.2%
associate-*l/25.2%
frac-2neg25.2%
Applied egg-rr25.4%
associate-*r*25.4%
*-commutative25.4%
Simplified25.4%
Final simplification24.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (sqrt (* (- A (hypot B A)) (* 2.0 F))))
(t_1
(/
(- (sqrt (* -8.0 (* (* F (* A C)) (* 2.0 A)))))
(fma B B (* A (* C -4.0))))))
(if (<= (pow B 2.0) 5e-149)
t_1
(if (<= (pow B 2.0) 4e-96)
(/ -1.0 (/ B t_0))
(if (<= (pow B 2.0) 2e-30) t_1 (/ t_0 (- B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(((A - hypot(B, A)) * (2.0 * F)));
double t_1 = -sqrt((-8.0 * ((F * (A * C)) * (2.0 * A)))) / fma(B, B, (A * (C * -4.0)));
double tmp;
if (pow(B, 2.0) <= 5e-149) {
tmp = t_1;
} else if (pow(B, 2.0) <= 4e-96) {
tmp = -1.0 / (B / t_0);
} else if (pow(B, 2.0) <= 2e-30) {
tmp = t_1;
} else {
tmp = t_0 / -B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = sqrt(Float64(Float64(A - hypot(B, A)) * Float64(2.0 * F))) t_1 = Float64(Float64(-sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A * C)) * Float64(2.0 * A))))) / fma(B, B, Float64(A * Float64(C * -4.0)))) tmp = 0.0 if ((B ^ 2.0) <= 5e-149) tmp = t_1; elseif ((B ^ 2.0) <= 4e-96) tmp = Float64(-1.0 / Float64(B / t_0)); elseif ((B ^ 2.0) <= 2e-30) tmp = t_1; else tmp = Float64(t_0 / Float64(-B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-N[Sqrt[N[(-8.0 * N[(N[(F * N[(A * C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-149], t$95$1, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 4e-96], N[(-1.0 / N[(B / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-30], t$95$1, N[(t$95$0 / (-B)), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot \left(2 \cdot F\right)}\\
t_1 := \frac{-\sqrt{-8 \cdot \left(\left(F \cdot \left(A \cdot C\right)\right) \cdot \left(2 \cdot A\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-149}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;{B}^{2} \leq 4 \cdot 10^{-96}:\\
\;\;\;\;\frac{-1}{\frac{B}{t_0}}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{-30}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{-B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.99999999999999968e-149 or 3.9999999999999996e-96 < (pow.f64 B 2) < 2e-30Initial program 18.0%
Simplified28.5%
Taylor expanded in C around inf 21.0%
associate-*r*22.4%
*-commutative22.4%
cancel-sign-sub-inv22.4%
metadata-eval22.4%
*-lft-identity22.4%
Simplified22.4%
distribute-frac-neg22.4%
associate-*r*22.4%
metadata-eval22.4%
associate-*r*23.5%
*-commutative23.5%
count-223.5%
Applied egg-rr23.5%
if 4.99999999999999968e-149 < (pow.f64 B 2) < 3.9999999999999996e-96Initial program 37.6%
Simplified38.9%
Taylor expanded in C around 0 23.4%
associate-*l*23.4%
+-commutative23.4%
unpow223.4%
unpow223.4%
hypot-def23.6%
Simplified23.6%
clear-num23.6%
inv-pow23.6%
sqrt-unprod23.5%
Applied egg-rr23.5%
unpow-123.5%
associate-/r*23.7%
*-commutative23.7%
associate-*r*23.7%
Simplified23.7%
Taylor expanded in A around 0 23.7%
if 2e-30 < (pow.f64 B 2) Initial program 20.2%
Simplified22.7%
Taylor expanded in C around 0 11.3%
mul-1-neg11.3%
distribute-rgt-neg-in11.3%
+-commutative11.3%
unpow211.3%
unpow211.3%
hypot-def25.2%
Simplified25.2%
associate-*l/25.2%
frac-2neg25.2%
Applied egg-rr25.4%
associate-*r*25.4%
*-commutative25.4%
Simplified25.4%
Final simplification24.4%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= A -4.6e+60) (* (/ (pow (* A F) 0.5) B) (- 2.0)) (* (sqrt (* F (- B))) (/ (- (sqrt 2.0)) B))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (A <= -4.6e+60) {
tmp = (pow((A * F), 0.5) / B) * -2.0;
} else {
tmp = sqrt((F * -B)) * (-sqrt(2.0) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (a <= (-4.6d+60)) then
tmp = (((a * f) ** 0.5d0) / b) * -2.0d0
else
tmp = sqrt((f * -b)) * (-sqrt(2.0d0) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (A <= -4.6e+60) {
tmp = (Math.pow((A * F), 0.5) / B) * -2.0;
} else {
tmp = Math.sqrt((F * -B)) * (-Math.sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if A <= -4.6e+60: tmp = (math.pow((A * F), 0.5) / B) * -2.0 else: tmp = math.sqrt((F * -B)) * (-math.sqrt(2.0) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (A <= -4.6e+60) tmp = Float64(Float64((Float64(A * F) ^ 0.5) / B) * Float64(-2.0)); else tmp = Float64(sqrt(Float64(F * Float64(-B))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (A <= -4.6e+60)
tmp = (((A * F) ^ 0.5) / B) * -2.0;
else
tmp = sqrt((F * -B)) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[A, -4.6e+60], N[(N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision] * (-2.0)), $MachinePrecision], N[(N[Sqrt[N[(F * (-B)), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -4.6 \cdot 10^{+60}:\\
\;\;\;\;\frac{{\left(A \cdot F\right)}^{0.5}}{B} \cdot \left(-2\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(-B\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if A < -4.60000000000000034e60Initial program 18.9%
Simplified38.7%
Taylor expanded in C around inf 34.6%
cancel-sign-sub-inv34.6%
metadata-eval34.6%
*-lft-identity34.6%
Simplified34.6%
pow1/234.6%
pow-to-exp32.4%
associate-*l*35.0%
count-235.0%
Applied egg-rr35.0%
Taylor expanded in C around 0 15.7%
associate-*r/15.8%
*-rgt-identity15.8%
Simplified15.8%
add-sqr-sqrt15.6%
*-un-lft-identity15.6%
times-frac15.7%
pow1/215.7%
sqrt-pow115.7%
*-commutative15.7%
metadata-eval15.7%
pow1/216.0%
sqrt-pow116.0%
*-commutative16.0%
metadata-eval16.0%
Applied egg-rr16.0%
/-rgt-identity16.0%
associate-*r/15.9%
pow-sqr16.0%
metadata-eval16.0%
Simplified16.0%
if -4.60000000000000034e60 < A Initial program 20.3%
Simplified23.6%
Taylor expanded in C around 0 7.8%
mul-1-neg7.8%
distribute-rgt-neg-in7.8%
+-commutative7.8%
unpow27.8%
unpow27.8%
hypot-def15.1%
Simplified15.1%
Taylor expanded in A around 0 13.9%
associate-*r*13.9%
mul-1-neg13.9%
Simplified13.9%
Final simplification14.3%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (sqrt (* (- A (hypot B A)) (* 2.0 F))) (- B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return sqrt(((A - hypot(B, A)) * (2.0 * F))) / -B;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return Math.sqrt(((A - Math.hypot(B, A)) * (2.0 * F))) / -B;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return math.sqrt(((A - math.hypot(B, A)) * (2.0 * F))) / -B
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(sqrt(Float64(Float64(A - hypot(B, A)) * Float64(2.0 * F))) / Float64(-B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = sqrt(((A - hypot(B, A)) * (2.0 * F))) / -B;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[Sqrt[N[(N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B)), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{\sqrt{\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot \left(2 \cdot F\right)}}{-B}
\end{array}
Initial program 20.1%
Simplified26.8%
Taylor expanded in C around 0 8.3%
mul-1-neg8.3%
distribute-rgt-neg-in8.3%
+-commutative8.3%
unpow28.3%
unpow28.3%
hypot-def15.2%
Simplified15.2%
associate-*l/15.2%
frac-2neg15.2%
Applied egg-rr15.3%
associate-*r*15.3%
*-commutative15.3%
Simplified15.3%
Final simplification15.3%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (/ (pow (* A F) 0.5) B) (- 2.0)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return (pow((A * F), 0.5) / B) * -2.0;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (((a * f) ** 0.5d0) / b) * -2.0d0
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return (Math.pow((A * F), 0.5) / B) * -2.0;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return (math.pow((A * F), 0.5) / B) * -2.0
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64((Float64(A * F) ^ 0.5) / B) * Float64(-2.0)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (((A * F) ^ 0.5) / B) * -2.0;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision] * (-2.0)), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{{\left(A \cdot F\right)}^{0.5}}{B} \cdot \left(-2\right)
\end{array}
Initial program 20.1%
Simplified27.6%
Taylor expanded in C around inf 14.5%
cancel-sign-sub-inv14.5%
metadata-eval14.5%
*-lft-identity14.5%
Simplified14.5%
pow1/214.7%
pow-to-exp13.6%
associate-*l*13.9%
count-213.9%
Applied egg-rr13.9%
Taylor expanded in C around 0 4.4%
associate-*r/4.4%
*-rgt-identity4.4%
Simplified4.4%
add-sqr-sqrt4.4%
*-un-lft-identity4.4%
times-frac4.4%
pow1/24.4%
sqrt-pow14.4%
*-commutative4.4%
metadata-eval4.4%
pow1/24.6%
sqrt-pow14.6%
*-commutative4.6%
metadata-eval4.6%
Applied egg-rr4.6%
/-rgt-identity4.6%
associate-*r/4.5%
pow-sqr4.6%
metadata-eval4.6%
Simplified4.6%
Final simplification4.6%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (/ (sqrt (* A F)) B) (- 2.0)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return (sqrt((A * F)) / B) * -2.0;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (sqrt((a * f)) / b) * -2.0d0
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return (Math.sqrt((A * F)) / B) * -2.0;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return (math.sqrt((A * F)) / B) * -2.0
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(sqrt(Float64(A * F)) / B) * Float64(-2.0)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (sqrt((A * F)) / B) * -2.0;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision] * (-2.0)), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{\sqrt{A \cdot F}}{B} \cdot \left(-2\right)
\end{array}
Initial program 20.1%
Simplified27.6%
Taylor expanded in C around inf 14.5%
cancel-sign-sub-inv14.5%
metadata-eval14.5%
*-lft-identity14.5%
Simplified14.5%
pow1/214.7%
pow-to-exp13.6%
associate-*l*13.9%
count-213.9%
Applied egg-rr13.9%
Taylor expanded in C around 0 4.4%
associate-*r/4.4%
*-rgt-identity4.4%
Simplified4.4%
Final simplification4.4%
herbie shell --seed 2023310
(FPCore (A B C F)
:name "ABCF->ab-angle b"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))