
(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 12 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: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- A (hypot A B)))
(t_1 (fma B B (* A (* C -4.0))))
(t_2 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 0.0)
(/ (* (sqrt (* (* 2.0 F) t_0)) (- (sqrt (fma B B (* C (* A -4.0)))))) t_1)
(if (<= t_3 INFINITY)
(/ (* (sqrt (* (* C F) (+ A A))) (- (sqrt (* A -8.0)))) t_1)
(* (sqrt (* F t_0)) (/ (- (sqrt 2.0)) B))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = A - hypot(A, B);
double t_1 = fma(B, B, (A * (C * -4.0)));
double t_2 = pow(B, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= 0.0) {
tmp = (sqrt(((2.0 * F) * t_0)) * -sqrt(fma(B, B, (C * (A * -4.0))))) / t_1;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt(((C * F) * (A + A))) * -sqrt((A * -8.0))) / t_1;
} else {
tmp = sqrt((F * t_0)) * (-sqrt(2.0) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(A - hypot(A, B)) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) t_2 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= 0.0) tmp = Float64(Float64(sqrt(Float64(Float64(2.0 * F) * t_0)) * Float64(-sqrt(fma(B, B, Float64(C * Float64(A * -4.0)))))) / t_1); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(Float64(C * F) * Float64(A + A))) * Float64(-sqrt(Float64(A * -8.0)))) / t_1); else tmp = Float64(sqrt(Float64(F * t_0)) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
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[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, 0.0], N[(N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(N[(C * F), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(A * -8.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[Sqrt[N[(F * t$95$0), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := A - \mathsf{hypot}\left(A, B\right)\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq 0:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot t_0} \cdot \left(-\sqrt{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\right)}{t_1}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(C \cdot F\right) \cdot \left(A + A\right)} \cdot \left(-\sqrt{A \cdot -8}\right)}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot t_0} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -0.0Initial program 40.3%
Simplified49.8%
sqrt-prod63.8%
*-commutative63.8%
*-commutative63.8%
associate-*r*63.8%
associate--r-64.4%
Applied egg-rr64.4%
Taylor expanded in C around 0 48.9%
mul-1-neg48.9%
+-commutative48.9%
unpow248.9%
unpow248.9%
hypot-def53.3%
Simplified53.3%
if -0.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 57.4%
Simplified69.1%
Taylor expanded in C around inf 34.0%
associate-*r*34.0%
*-commutative34.0%
*-commutative34.0%
mul-1-neg34.0%
Simplified34.0%
sqrt-prod46.1%
associate-*l*45.7%
Applied egg-rr45.7%
associate-*r*46.1%
*-commutative46.1%
Simplified46.1%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified0.0%
Taylor expanded in C around 0 1.8%
mul-1-neg1.8%
*-commutative1.8%
+-commutative1.8%
unpow21.8%
unpow21.8%
hypot-def21.7%
Simplified21.7%
Final simplification37.2%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))) (t_1 (* 4.0 (* A C))))
(if (<= B -5.8e+147)
(* 2.0 (* (sqrt (* A F)) (/ 1.0 B)))
(if (<= B -1.2e-37)
(-
(/
(sqrt (* 2.0 (* (- (hypot A B) A) (* F (- t_1 (* B B))))))
(- (* B B) t_1)))
(if (<= B -2.1e-69)
(/
(* B (sqrt (* (* 2.0 F) (+ A (- C (hypot B (- A C)))))))
(fma B B (* A (* C -4.0))))
(if (<= B 5.3e-61)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* (sqrt (* F (- A (hypot A B)))) (/ (- (sqrt 2.0)) B))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double t_1 = 4.0 * (A * C);
double tmp;
if (B <= -5.8e+147) {
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
} else if (B <= -1.2e-37) {
tmp = -(sqrt((2.0 * ((hypot(A, B) - A) * (F * (t_1 - (B * B)))))) / ((B * B) - t_1));
} else if (B <= -2.1e-69) {
tmp = (B * sqrt(((2.0 * F) * (A + (C - hypot(B, (A - C))))))) / fma(B, B, (A * (C * -4.0)));
} else if (B <= 5.3e-61) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) t_1 = Float64(4.0 * Float64(A * C)) tmp = 0.0 if (B <= -5.8e+147) tmp = Float64(2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); elseif (B <= -1.2e-37) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(hypot(A, B) - A) * Float64(F * Float64(t_1 - Float64(B * B)))))) / Float64(Float64(B * B) - t_1))); elseif (B <= -2.1e-69) tmp = Float64(Float64(B * sqrt(Float64(Float64(2.0 * F) * Float64(A + Float64(C - hypot(B, Float64(A - C))))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); elseif (B <= 5.3e-61) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -5.8e+147], N[(2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, -1.2e-37], (-N[(N[Sqrt[N[(2.0 * N[(N[(N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision] - A), $MachinePrecision] * N[(F * N[(t$95$1 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(B * B), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), If[LessEqual[B, -2.1e-69], N[(N[(B * N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 5.3e-61], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
t_1 := 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -5.8 \cdot 10^{+147}:\\
\;\;\;\;2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{elif}\;B \leq -1.2 \cdot 10^{-37}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(\mathsf{hypot}\left(A, B\right) - A\right) \cdot \left(F \cdot \left(t_1 - B \cdot B\right)\right)\right)}}{B \cdot B - t_1}\\
\mathbf{elif}\;B \leq -2.1 \cdot 10^{-69}:\\
\;\;\;\;\frac{B \cdot \sqrt{\left(2 \cdot F\right) \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;B \leq 5.3 \cdot 10^{-61}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < -5.7999999999999997e147Initial program 0.1%
Simplified0.1%
Taylor expanded in A around -inf 0.1%
*-commutative0.1%
Simplified0.1%
Taylor expanded in B around -inf 10.4%
*-commutative10.4%
Simplified10.4%
if -5.7999999999999997e147 < B < -1.19999999999999995e-37Initial program 44.5%
Simplified44.5%
Taylor expanded in C around 0 43.6%
+-commutative43.6%
unpow243.6%
unpow243.6%
hypot-def43.8%
Simplified43.8%
if -1.19999999999999995e-37 < B < -2.1e-69Initial program 35.2%
Simplified35.6%
sqrt-prod82.4%
*-commutative82.4%
*-commutative82.4%
associate-*r*82.4%
associate--r-82.4%
Applied egg-rr82.4%
Taylor expanded in B around -inf 67.1%
mul-1-neg67.1%
Simplified67.1%
if -2.1e-69 < B < 5.3e-61Initial program 17.3%
Simplified17.3%
Taylor expanded in A around -inf 23.2%
*-commutative23.2%
Simplified23.2%
distribute-frac-neg23.2%
associate-*l*24.3%
cancel-sign-sub-inv24.3%
metadata-eval24.3%
cancel-sign-sub-inv24.3%
metadata-eval24.3%
Applied egg-rr24.3%
if 5.3e-61 < B Initial program 22.9%
Simplified22.9%
Taylor expanded in C around 0 27.8%
mul-1-neg27.8%
*-commutative27.8%
+-commutative27.8%
unpow227.8%
unpow227.8%
hypot-def54.9%
Simplified54.9%
Final simplification37.0%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))) (t_1 (* 4.0 (* A C))))
(if (<= B -1.08e+148)
(* 2.0 (* (sqrt (* A F)) (/ 1.0 B)))
(if (<= B -2.6e-10)
(-
(/
(sqrt (* 2.0 (* (- (hypot A B) A) (* F (- t_1 (* B B))))))
(- (* B B) t_1)))
(if (<= B 3.7e-63)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* (sqrt (* F (- A (hypot A B)))) (/ (- (sqrt 2.0)) B)))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double t_1 = 4.0 * (A * C);
double tmp;
if (B <= -1.08e+148) {
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
} else if (B <= -2.6e-10) {
tmp = -(sqrt((2.0 * ((hypot(A, B) - A) * (F * (t_1 - (B * B)))))) / ((B * B) - t_1));
} else if (B <= 3.7e-63) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
}
return tmp;
}
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double t_1 = 4.0 * (A * C);
double tmp;
if (B <= -1.08e+148) {
tmp = 2.0 * (Math.sqrt((A * F)) * (1.0 / B));
} else if (B <= -2.6e-10) {
tmp = -(Math.sqrt((2.0 * ((Math.hypot(A, B) - A) * (F * (t_1 - (B * B)))))) / ((B * B) - t_1));
} else if (B <= 3.7e-63) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = Math.sqrt((F * (A - Math.hypot(A, B)))) * (-Math.sqrt(2.0) / B);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) t_1 = 4.0 * (A * C) tmp = 0 if B <= -1.08e+148: tmp = 2.0 * (math.sqrt((A * F)) * (1.0 / B)) elif B <= -2.6e-10: tmp = -(math.sqrt((2.0 * ((math.hypot(A, B) - A) * (F * (t_1 - (B * B)))))) / ((B * B) - t_1)) elif B <= 3.7e-63: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = math.sqrt((F * (A - math.hypot(A, B)))) * (-math.sqrt(2.0) / B) return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) t_1 = Float64(4.0 * Float64(A * C)) tmp = 0.0 if (B <= -1.08e+148) tmp = Float64(2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); elseif (B <= -2.6e-10) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(hypot(A, B) - A) * Float64(F * Float64(t_1 - Float64(B * B)))))) / Float64(Float64(B * B) - t_1))); elseif (B <= 3.7e-63) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
t_1 = 4.0 * (A * C);
tmp = 0.0;
if (B <= -1.08e+148)
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
elseif (B <= -2.6e-10)
tmp = -(sqrt((2.0 * ((hypot(A, B) - A) * (F * (t_1 - (B * B)))))) / ((B * B) - t_1));
elseif (B <= 3.7e-63)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.08e+148], N[(2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, -2.6e-10], (-N[(N[Sqrt[N[(2.0 * N[(N[(N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision] - A), $MachinePrecision] * N[(F * N[(t$95$1 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(B * B), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), If[LessEqual[B, 3.7e-63], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
t_1 := 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -1.08 \cdot 10^{+148}:\\
\;\;\;\;2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{elif}\;B \leq -2.6 \cdot 10^{-10}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(\mathsf{hypot}\left(A, B\right) - A\right) \cdot \left(F \cdot \left(t_1 - B \cdot B\right)\right)\right)}}{B \cdot B - t_1}\\
\mathbf{elif}\;B \leq 3.7 \cdot 10^{-63}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < -1.07999999999999999e148Initial program 0.1%
Simplified0.1%
Taylor expanded in A around -inf 0.1%
*-commutative0.1%
Simplified0.1%
Taylor expanded in B around -inf 10.4%
*-commutative10.4%
Simplified10.4%
if -1.07999999999999999e148 < B < -2.59999999999999981e-10Initial program 44.6%
Simplified44.6%
Taylor expanded in C around 0 46.2%
+-commutative46.2%
unpow246.2%
unpow246.2%
hypot-def46.3%
Simplified46.3%
if -2.59999999999999981e-10 < B < 3.70000000000000012e-63Initial program 20.4%
Simplified20.4%
Taylor expanded in A around -inf 23.6%
*-commutative23.6%
Simplified23.6%
distribute-frac-neg23.6%
associate-*l*24.6%
cancel-sign-sub-inv24.6%
metadata-eval24.6%
cancel-sign-sub-inv24.6%
metadata-eval24.6%
Applied egg-rr24.6%
if 3.70000000000000012e-63 < B Initial program 22.9%
Simplified22.9%
Taylor expanded in C around 0 27.8%
mul-1-neg27.8%
*-commutative27.8%
+-commutative27.8%
unpow227.8%
unpow227.8%
hypot-def54.9%
Simplified54.9%
Final simplification35.9%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (* 4.0 (* A C))) (t_1 (- (* B B) t_0)))
(if (<= C 1.55e+47)
(- (/ (sqrt (* 2.0 (* (- (hypot A B) A) (* F (- t_0 (* B B)))))) t_1))
(/
(-
(sqrt
(*
2.0
(*
(* F t_1)
(+ A (+ A (* -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C))))))))
t_1))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = 4.0 * (A * C);
double t_1 = (B * B) - t_0;
double tmp;
if (C <= 1.55e+47) {
tmp = -(sqrt((2.0 * ((hypot(A, B) - A) * (F * (t_0 - (B * B)))))) / t_1);
} else {
tmp = -sqrt((2.0 * ((F * t_1) * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_1;
}
return tmp;
}
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = 4.0 * (A * C);
double t_1 = (B * B) - t_0;
double tmp;
if (C <= 1.55e+47) {
tmp = -(Math.sqrt((2.0 * ((Math.hypot(A, B) - A) * (F * (t_0 - (B * B)))))) / t_1);
} else {
tmp = -Math.sqrt((2.0 * ((F * t_1) * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_1;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = 4.0 * (A * C) t_1 = (B * B) - t_0 tmp = 0 if C <= 1.55e+47: tmp = -(math.sqrt((2.0 * ((math.hypot(A, B) - A) * (F * (t_0 - (B * B)))))) / t_1) else: tmp = -math.sqrt((2.0 * ((F * t_1) * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_1 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(4.0 * Float64(A * C)) t_1 = Float64(Float64(B * B) - t_0) tmp = 0.0 if (C <= 1.55e+47) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(hypot(A, B) - A) * Float64(F * Float64(t_0 - Float64(B * B)))))) / t_1)); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C)))))))) / t_1); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = 4.0 * (A * C);
t_1 = (B * B) - t_0;
tmp = 0.0;
if (C <= 1.55e+47)
tmp = -(sqrt((2.0 * ((hypot(A, B) - A) * (F * (t_0 - (B * B)))))) / t_1);
else
tmp = -sqrt((2.0 * ((F * t_1) * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_1;
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[C, 1.55e+47], (-N[(N[Sqrt[N[(2.0 * N[(N[(N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision] - A), $MachinePrecision] * N[(F * N[(t$95$0 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision]), N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(A + N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := 4 \cdot \left(A \cdot C\right)\\
t_1 := B \cdot B - t_0\\
\mathbf{if}\;C \leq 1.55 \cdot 10^{+47}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(\mathsf{hypot}\left(A, B\right) - A\right) \cdot \left(F \cdot \left(t_0 - B \cdot B\right)\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)}}{t_1}\\
\end{array}
\end{array}
if C < 1.55e47Initial program 26.4%
Simplified26.4%
Taylor expanded in C around 0 23.2%
+-commutative23.2%
unpow223.2%
unpow223.2%
hypot-def25.6%
Simplified25.6%
if 1.55e47 < C Initial program 3.5%
Simplified3.5%
Taylor expanded in C around inf 23.7%
associate--l+23.7%
unpow223.7%
unpow223.7%
unpow223.7%
mul-1-neg23.7%
mul-1-neg23.7%
sqr-neg23.7%
mul-1-neg23.7%
Simplified23.7%
Final simplification25.2%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (* 4.0 (* A C)))
(t_1 (- (* B B) t_0))
(t_2 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B -2.3e+148)
(* 2.0 (* (sqrt (* A F)) (/ 1.0 B)))
(if (<= B -4.3e-8)
(/ (- (sqrt (* 2.0 (* (* F t_1) (+ A (+ B C)))))) t_1)
(if (<= B 1e-60)
(/ (- (sqrt (* 2.0 (* t_2 (* F (* 2.0 A)))))) t_2)
(/
(- (sqrt (* 2.0 (* (* F (- t_0 (* B B))) (- B (+ A C))))))
t_1))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = 4.0 * (A * C);
double t_1 = (B * B) - t_0;
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= -2.3e+148) {
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
} else if (B <= -4.3e-8) {
tmp = -sqrt((2.0 * ((F * t_1) * (A + (B + C))))) / t_1;
} else if (B <= 1e-60) {
tmp = -sqrt((2.0 * (t_2 * (F * (2.0 * A))))) / t_2;
} else {
tmp = -sqrt((2.0 * ((F * (t_0 - (B * B))) * (B - (A + C))))) / t_1;
}
return tmp;
}
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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 4.0d0 * (a * c)
t_1 = (b * b) - t_0
t_2 = (b * b) + ((-4.0d0) * (a * c))
if (b <= (-2.3d+148)) then
tmp = 2.0d0 * (sqrt((a * f)) * (1.0d0 / b))
else if (b <= (-4.3d-8)) then
tmp = -sqrt((2.0d0 * ((f * t_1) * (a + (b + c))))) / t_1
else if (b <= 1d-60) then
tmp = -sqrt((2.0d0 * (t_2 * (f * (2.0d0 * a))))) / t_2
else
tmp = -sqrt((2.0d0 * ((f * (t_0 - (b * b))) * (b - (a + c))))) / t_1
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = 4.0 * (A * C);
double t_1 = (B * B) - t_0;
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= -2.3e+148) {
tmp = 2.0 * (Math.sqrt((A * F)) * (1.0 / B));
} else if (B <= -4.3e-8) {
tmp = -Math.sqrt((2.0 * ((F * t_1) * (A + (B + C))))) / t_1;
} else if (B <= 1e-60) {
tmp = -Math.sqrt((2.0 * (t_2 * (F * (2.0 * A))))) / t_2;
} else {
tmp = -Math.sqrt((2.0 * ((F * (t_0 - (B * B))) * (B - (A + C))))) / t_1;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = 4.0 * (A * C) t_1 = (B * B) - t_0 t_2 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= -2.3e+148: tmp = 2.0 * (math.sqrt((A * F)) * (1.0 / B)) elif B <= -4.3e-8: tmp = -math.sqrt((2.0 * ((F * t_1) * (A + (B + C))))) / t_1 elif B <= 1e-60: tmp = -math.sqrt((2.0 * (t_2 * (F * (2.0 * A))))) / t_2 else: tmp = -math.sqrt((2.0 * ((F * (t_0 - (B * B))) * (B - (A + C))))) / t_1 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(4.0 * Float64(A * C)) t_1 = Float64(Float64(B * B) - t_0) t_2 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= -2.3e+148) tmp = Float64(2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); elseif (B <= -4.3e-8) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(A + Float64(B + C)))))) / t_1); elseif (B <= 1e-60) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(2.0 * A)))))) / t_2); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * Float64(t_0 - Float64(B * B))) * Float64(B - Float64(A + C)))))) / t_1); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = 4.0 * (A * C);
t_1 = (B * B) - t_0;
t_2 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= -2.3e+148)
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
elseif (B <= -4.3e-8)
tmp = -sqrt((2.0 * ((F * t_1) * (A + (B + C))))) / t_1;
elseif (B <= 1e-60)
tmp = -sqrt((2.0 * (t_2 * (F * (2.0 * A))))) / t_2;
else
tmp = -sqrt((2.0 * ((F * (t_0 - (B * B))) * (B - (A + C))))) / t_1;
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -2.3e+148], N[(2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, -4.3e-8], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(A + N[(B + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 1e-60], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(F * N[(t$95$0 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(B - N[(A + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := 4 \cdot \left(A \cdot C\right)\\
t_1 := B \cdot B - t_0\\
t_2 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -2.3 \cdot 10^{+148}:\\
\;\;\;\;2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{elif}\;B \leq -4.3 \cdot 10^{-8}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(A + \left(B + C\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 10^{-60}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot \left(t_0 - B \cdot B\right)\right) \cdot \left(B - \left(A + C\right)\right)\right)}}{t_1}\\
\end{array}
\end{array}
if B < -2.3000000000000001e148Initial program 0.1%
Simplified0.1%
Taylor expanded in A around -inf 0.1%
*-commutative0.1%
Simplified0.1%
Taylor expanded in B around -inf 10.4%
*-commutative10.4%
Simplified10.4%
if -2.3000000000000001e148 < B < -4.3000000000000001e-8Initial program 46.0%
Simplified46.0%
Taylor expanded in B around -inf 40.2%
if -4.3000000000000001e-8 < B < 9.9999999999999997e-61Initial program 20.2%
Simplified20.2%
Taylor expanded in A around -inf 24.4%
*-commutative24.4%
Simplified24.4%
distribute-frac-neg24.4%
associate-*l*24.4%
cancel-sign-sub-inv24.4%
metadata-eval24.4%
cancel-sign-sub-inv24.4%
metadata-eval24.4%
Applied egg-rr24.4%
if 9.9999999999999997e-61 < B Initial program 22.9%
Simplified22.9%
Taylor expanded in B around inf 20.5%
Final simplification22.9%
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 F)) (/ 1.0 B)))
(t_1 (- (* B B) (* 4.0 (* A C))))
(t_2 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B -1.04e+147)
(* 2.0 t_0)
(if (<= B -4.3e-8)
(/ (- (sqrt (* 2.0 (* (* F t_1) (+ A (+ B C)))))) t_1)
(if (<= B 3.4e+89)
(/ (- (sqrt (* 2.0 (* t_2 (* F (* 2.0 A)))))) t_2)
(* t_0 -2.0))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((A * F)) * (1.0 / B);
double t_1 = (B * B) - (4.0 * (A * C));
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= -1.04e+147) {
tmp = 2.0 * t_0;
} else if (B <= -4.3e-8) {
tmp = -sqrt((2.0 * ((F * t_1) * (A + (B + C))))) / t_1;
} else if (B <= 3.4e+89) {
tmp = -sqrt((2.0 * (t_2 * (F * (2.0 * A))))) / t_2;
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt((a * f)) * (1.0d0 / b)
t_1 = (b * b) - (4.0d0 * (a * c))
t_2 = (b * b) + ((-4.0d0) * (a * c))
if (b <= (-1.04d+147)) then
tmp = 2.0d0 * t_0
else if (b <= (-4.3d-8)) then
tmp = -sqrt((2.0d0 * ((f * t_1) * (a + (b + c))))) / t_1
else if (b <= 3.4d+89) then
tmp = -sqrt((2.0d0 * (t_2 * (f * (2.0d0 * a))))) / t_2
else
tmp = t_0 * (-2.0d0)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((A * F)) * (1.0 / B);
double t_1 = (B * B) - (4.0 * (A * C));
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= -1.04e+147) {
tmp = 2.0 * t_0;
} else if (B <= -4.3e-8) {
tmp = -Math.sqrt((2.0 * ((F * t_1) * (A + (B + C))))) / t_1;
} else if (B <= 3.4e+89) {
tmp = -Math.sqrt((2.0 * (t_2 * (F * (2.0 * A))))) / t_2;
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((A * F)) * (1.0 / B) t_1 = (B * B) - (4.0 * (A * C)) t_2 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= -1.04e+147: tmp = 2.0 * t_0 elif B <= -4.3e-8: tmp = -math.sqrt((2.0 * ((F * t_1) * (A + (B + C))))) / t_1 elif B <= 3.4e+89: tmp = -math.sqrt((2.0 * (t_2 * (F * (2.0 * A))))) / t_2 else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_2 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= -1.04e+147) tmp = Float64(2.0 * t_0); elseif (B <= -4.3e-8) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(A + Float64(B + C)))))) / t_1); elseif (B <= 3.4e+89) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(2.0 * A)))))) / t_2); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((A * F)) * (1.0 / B);
t_1 = (B * B) - (4.0 * (A * C));
t_2 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= -1.04e+147)
tmp = 2.0 * t_0;
elseif (B <= -4.3e-8)
tmp = -sqrt((2.0 * ((F * t_1) * (A + (B + C))))) / t_1;
elseif (B <= 3.4e+89)
tmp = -sqrt((2.0 * (t_2 * (F * (2.0 * A))))) / t_2;
else
tmp = t_0 * -2.0;
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.04e+147], N[(2.0 * t$95$0), $MachinePrecision], If[LessEqual[B, -4.3e-8], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(A + N[(B + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 3.4e+89], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], N[(t$95$0 * -2.0), $MachinePrecision]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{A \cdot F} \cdot \frac{1}{B}\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_2 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -1.04 \cdot 10^{+147}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{elif}\;B \leq -4.3 \cdot 10^{-8}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(A + \left(B + C\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 3.4 \cdot 10^{+89}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -1.04000000000000006e147Initial program 0.1%
Simplified0.1%
Taylor expanded in A around -inf 0.1%
*-commutative0.1%
Simplified0.1%
Taylor expanded in B around -inf 10.4%
*-commutative10.4%
Simplified10.4%
if -1.04000000000000006e147 < B < -4.3000000000000001e-8Initial program 46.0%
Simplified46.0%
Taylor expanded in B around -inf 40.2%
if -4.3000000000000001e-8 < B < 3.4000000000000002e89Initial program 25.8%
Simplified25.8%
Taylor expanded in A around -inf 21.2%
*-commutative21.2%
Simplified21.2%
distribute-frac-neg21.2%
associate-*l*21.2%
cancel-sign-sub-inv21.2%
metadata-eval21.2%
cancel-sign-sub-inv21.2%
metadata-eval21.2%
Applied egg-rr21.2%
if 3.4000000000000002e89 < B Initial program 13.2%
Simplified13.2%
Taylor expanded in A around -inf 0.7%
*-commutative0.7%
Simplified0.7%
Taylor expanded in B around inf 5.9%
*-commutative5.9%
Simplified5.9%
Final simplification18.2%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))) (t_1 (* (sqrt (* A F)) (/ 1.0 B))))
(if (<= B -1.8e+146)
(* 2.0 t_1)
(if (<= B 2.35e+89)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* t_1 -2.0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double t_1 = sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1.8e+146) {
tmp = 2.0 * t_1;
} else if (B <= 2.35e+89) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = t_1 * -2.0;
}
return tmp;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
t_1 = sqrt((a * f)) * (1.0d0 / b)
if (b <= (-1.8d+146)) then
tmp = 2.0d0 * t_1
else if (b <= 2.35d+89) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = t_1 * (-2.0d0)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double t_1 = Math.sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1.8e+146) {
tmp = 2.0 * t_1;
} else if (B <= 2.35e+89) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = t_1 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) t_1 = math.sqrt((A * F)) * (1.0 / B) tmp = 0 if B <= -1.8e+146: tmp = 2.0 * t_1 elif B <= 2.35e+89: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = t_1 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) t_1 = Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= -1.8e+146) tmp = Float64(2.0 * t_1); elseif (B <= 2.35e+89) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(t_1 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
t_1 = sqrt((A * F)) * (1.0 / B);
tmp = 0.0;
if (B <= -1.8e+146)
tmp = 2.0 * t_1;
elseif (B <= 2.35e+89)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = t_1 * -2.0;
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.8e+146], N[(2.0 * t$95$1), $MachinePrecision], If[LessEqual[B, 2.35e+89], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(t$95$1 * -2.0), $MachinePrecision]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
t_1 := \sqrt{A \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq -1.8 \cdot 10^{+146}:\\
\;\;\;\;2 \cdot t_1\\
\mathbf{elif}\;B \leq 2.35 \cdot 10^{+89}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot -2\\
\end{array}
\end{array}
if B < -1.7999999999999999e146Initial program 0.1%
Simplified0.1%
Taylor expanded in A around -inf 0.1%
*-commutative0.1%
Simplified0.1%
Taylor expanded in B around -inf 10.4%
*-commutative10.4%
Simplified10.4%
if -1.7999999999999999e146 < B < 2.35000000000000011e89Initial program 29.9%
Simplified29.9%
Taylor expanded in A around -inf 19.1%
*-commutative19.1%
Simplified19.1%
distribute-frac-neg19.1%
associate-*l*19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
Applied egg-rr19.2%
if 2.35000000000000011e89 < B Initial program 13.2%
Simplified13.2%
Taylor expanded in A around -inf 0.7%
*-commutative0.7%
Simplified0.7%
Taylor expanded in B around inf 5.9%
*-commutative5.9%
Simplified5.9%
Final simplification14.6%
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 F)) (/ 1.0 B))))
(if (<= B -1.7e+25)
(* 2.0 t_0)
(if (<= B 2.45e+82)
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* 4.0 (* A C))))
(* t_0 -2.0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1.7e+25) {
tmp = 2.0 * t_0;
} else if (B <= 2.45e+82) {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt((a * f)) * (1.0d0 / b)
if (b <= (-1.7d+25)) then
tmp = 2.0d0 * t_0
else if (b <= 2.45d+82) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - (4.0d0 * (a * c)))
else
tmp = t_0 * (-2.0d0)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1.7e+25) {
tmp = 2.0 * t_0;
} else if (B <= 2.45e+82) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((A * F)) * (1.0 / B) tmp = 0 if B <= -1.7e+25: tmp = 2.0 * t_0 elif B <= 2.45e+82: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C))) else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= -1.7e+25) tmp = Float64(2.0 * t_0); elseif (B <= 2.45e+82) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((A * F)) * (1.0 / B);
tmp = 0.0;
if (B <= -1.7e+25)
tmp = 2.0 * t_0;
elseif (B <= 2.45e+82)
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
else
tmp = t_0 * -2.0;
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.7e+25], N[(2.0 * t$95$0), $MachinePrecision], If[LessEqual[B, 2.45e+82], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * -2.0), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{A \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq -1.7 \cdot 10^{+25}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{elif}\;B \leq 2.45 \cdot 10^{+82}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -1.69999999999999992e25Initial program 13.9%
Simplified13.9%
Taylor expanded in A around -inf 0.8%
*-commutative0.8%
Simplified0.8%
Taylor expanded in B around -inf 7.4%
*-commutative7.4%
Simplified7.4%
if -1.69999999999999992e25 < B < 2.45e82Initial program 28.2%
Simplified28.2%
Taylor expanded in A around -inf 22.7%
*-commutative22.7%
Simplified22.7%
Taylor expanded in B around 0 16.1%
*-commutative16.1%
Simplified16.1%
if 2.45e82 < B Initial program 15.3%
Simplified15.3%
Taylor expanded in A around -inf 1.0%
*-commutative1.0%
Simplified1.0%
Taylor expanded in B around inf 5.8%
*-commutative5.8%
Simplified5.8%
Final simplification11.3%
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 F)) (/ 1.0 B))))
(if (<= B -1.3e+25)
(* 2.0 t_0)
(if (<= B 4.2e+82)
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* F (* A C)))))))
(- (* B B) (* 4.0 (* A C))))
(* t_0 -2.0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1.3e+25) {
tmp = 2.0 * t_0;
} else if (B <= 4.2e+82) {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (A * C)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt((a * f)) * (1.0d0 / b)
if (b <= (-1.3d+25)) then
tmp = 2.0d0 * t_0
else if (b <= 4.2d+82) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (f * (a * c)))))) / ((b * b) - (4.0d0 * (a * c)))
else
tmp = t_0 * (-2.0d0)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1.3e+25) {
tmp = 2.0 * t_0;
} else if (B <= 4.2e+82) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (A * C)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((A * F)) * (1.0 / B) tmp = 0 if B <= -1.3e+25: tmp = 2.0 * t_0 elif B <= 4.2e+82: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (A * C)))))) / ((B * B) - (4.0 * (A * C))) else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= -1.3e+25) tmp = Float64(2.0 * t_0); elseif (B <= 4.2e+82) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(-4.0 * Float64(F * Float64(A * C))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((A * F)) * (1.0 / B);
tmp = 0.0;
if (B <= -1.3e+25)
tmp = 2.0 * t_0;
elseif (B <= 4.2e+82)
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (A * C)))))) / ((B * B) - (4.0 * (A * C)));
else
tmp = t_0 * -2.0;
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.3e+25], N[(2.0 * t$95$0), $MachinePrecision], If[LessEqual[B, 4.2e+82], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(-4.0 * N[(F * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * -2.0), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{A \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq -1.3 \cdot 10^{+25}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{elif}\;B \leq 4.2 \cdot 10^{+82}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(-4 \cdot \left(F \cdot \left(A \cdot C\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -1.2999999999999999e25Initial program 13.9%
Simplified13.9%
Taylor expanded in A around -inf 0.8%
*-commutative0.8%
Simplified0.8%
Taylor expanded in B around -inf 7.4%
*-commutative7.4%
Simplified7.4%
if -1.2999999999999999e25 < B < 4.2e82Initial program 28.2%
Simplified28.2%
Taylor expanded in A around -inf 22.7%
*-commutative22.7%
Simplified22.7%
Taylor expanded in B around 0 16.1%
associate-*r*20.5%
Simplified20.5%
if 4.2e82 < B Initial program 15.3%
Simplified15.3%
Taylor expanded in A around -inf 1.0%
*-commutative1.0%
Simplified1.0%
Taylor expanded in B around inf 5.8%
*-commutative5.8%
Simplified5.8%
Final simplification13.5%
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 F)) (/ 1.0 B))))
(if (<= B -1.15e+25)
(* 2.0 t_0)
(if (<= B 1.5e+51)
(-
(/
(sqrt (* 2.0 (* -8.0 (* (* C F) (* A A)))))
(- (* B B) (* 4.0 (* A C)))))
(* t_0 -2.0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1.15e+25) {
tmp = 2.0 * t_0;
} else if (B <= 1.5e+51) {
tmp = -(sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - (4.0 * (A * C))));
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt((a * f)) * (1.0d0 / b)
if (b <= (-1.15d+25)) then
tmp = 2.0d0 * t_0
else if (b <= 1.5d+51) then
tmp = -(sqrt((2.0d0 * ((-8.0d0) * ((c * f) * (a * a))))) / ((b * b) - (4.0d0 * (a * c))))
else
tmp = t_0 * (-2.0d0)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1.15e+25) {
tmp = 2.0 * t_0;
} else if (B <= 1.5e+51) {
tmp = -(Math.sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - (4.0 * (A * C))));
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((A * F)) * (1.0 / B) tmp = 0 if B <= -1.15e+25: tmp = 2.0 * t_0 elif B <= 1.5e+51: tmp = -(math.sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - (4.0 * (A * C)))) else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= -1.15e+25) tmp = Float64(2.0 * t_0); elseif (B <= 1.5e+51) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(-8.0 * Float64(Float64(C * F) * Float64(A * A))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))))); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((A * F)) * (1.0 / B);
tmp = 0.0;
if (B <= -1.15e+25)
tmp = 2.0 * t_0;
elseif (B <= 1.5e+51)
tmp = -(sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - (4.0 * (A * C))));
else
tmp = t_0 * -2.0;
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.15e+25], N[(2.0 * t$95$0), $MachinePrecision], If[LessEqual[B, 1.5e+51], (-N[(N[Sqrt[N[(2.0 * N[(-8.0 * N[(N[(C * F), $MachinePrecision] * N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(t$95$0 * -2.0), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{A \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq -1.15 \cdot 10^{+25}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{elif}\;B \leq 1.5 \cdot 10^{+51}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(-8 \cdot \left(\left(C \cdot F\right) \cdot \left(A \cdot A\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -1.1499999999999999e25Initial program 13.9%
Simplified13.9%
Taylor expanded in A around -inf 0.8%
*-commutative0.8%
Simplified0.8%
Taylor expanded in B around -inf 7.4%
*-commutative7.4%
Simplified7.4%
if -1.1499999999999999e25 < B < 1.5e51Initial program 28.7%
Simplified28.7%
Taylor expanded in A around -inf 23.7%
*-commutative23.7%
Simplified23.7%
Taylor expanded in B around 0 14.1%
unpow214.1%
*-commutative14.1%
Simplified14.1%
if 1.5e51 < B Initial program 15.5%
Simplified15.5%
Taylor expanded in A around -inf 1.0%
*-commutative1.0%
Simplified1.0%
Taylor expanded in B around inf 5.5%
*-commutative5.5%
Simplified5.5%
Final simplification10.0%
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 F)) (/ 1.0 B)))) (if (<= B -1e-310) (* 2.0 t_0) (* t_0 -2.0))))
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1e-310) {
tmp = 2.0 * t_0;
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt((a * f)) * (1.0d0 / b)
if (b <= (-1d-310)) then
tmp = 2.0d0 * t_0
else
tmp = t_0 * (-2.0d0)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= -1e-310) {
tmp = 2.0 * t_0;
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((A * F)) * (1.0 / B) tmp = 0 if B <= -1e-310: tmp = 2.0 * t_0 else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= -1e-310) tmp = Float64(2.0 * t_0); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((A * F)) * (1.0 / B);
tmp = 0.0;
if (B <= -1e-310)
tmp = 2.0 * t_0;
else
tmp = t_0 * -2.0;
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1e-310], N[(2.0 * t$95$0), $MachinePrecision], N[(t$95$0 * -2.0), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{A \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq -1 \cdot 10^{-310}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -9.999999999999969e-311Initial program 21.7%
Simplified21.7%
Taylor expanded in A around -inf 13.4%
*-commutative13.4%
Simplified13.4%
Taylor expanded in B around -inf 6.7%
*-commutative6.7%
Simplified6.7%
if -9.999999999999969e-311 < B Initial program 21.1%
Simplified21.1%
Taylor expanded in A around -inf 10.1%
*-commutative10.1%
Simplified10.1%
Taylor expanded in B around inf 4.9%
*-commutative4.9%
Simplified4.9%
Final simplification5.8%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (* (sqrt (* A F)) (/ 1.0 B)) -2.0))
assert(A < C);
double code(double A, double B, double C, double F) {
return (sqrt((A * F)) * (1.0 / B)) * -2.0;
}
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)) * (1.0d0 / b)) * (-2.0d0)
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return (Math.sqrt((A * F)) * (1.0 / B)) * -2.0;
}
[A, C] = sort([A, C]) def code(A, B, C, F): return (math.sqrt((A * F)) * (1.0 / B)) * -2.0
A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) * -2.0) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (sqrt((A * F)) * (1.0 / B)) * -2.0;
end
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] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right) \cdot -2
\end{array}
Initial program 21.4%
Simplified21.4%
Taylor expanded in A around -inf 11.8%
*-commutative11.8%
Simplified11.8%
Taylor expanded in B around inf 3.0%
*-commutative3.0%
Simplified3.0%
Final simplification3.0%
herbie shell --seed 2023193
(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))))