
(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 11 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, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (sqrt (- F)))
(t_1 (fma (* -4.0 C) A (* B B)))
(t_2 (fma -4.0 (* C A) (* B B)))
(t_3 (- (* C (* A 4.0)) (pow B 2.0)))
(t_4
(/
(sqrt
(*
(* (* t_3 F) 2.0)
(- (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))) (+ C A))))
t_3)))
(if (<= t_4 (- INFINITY))
(* (- (pow C -0.5)) t_0)
(if (<= t_4 -5e-187)
(/ (sqrt (* (* t_2 (* F 2.0)) (- (+ C A) (hypot (- A C) B)))) (- t_2))
(if (<= t_4 INFINITY)
(*
(/ -1.0 t_1)
(sqrt (* (* (+ (fma (/ (* B B) C) -0.5 A) A) (* F 2.0)) t_1)))
(/ -1.0 (/ (sqrt C) t_0)))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(-F);
double t_1 = fma((-4.0 * C), A, (B * B));
double t_2 = fma(-4.0, (C * A), (B * B));
double t_3 = (C * (A * 4.0)) - pow(B, 2.0);
double t_4 = sqrt((((t_3 * F) * 2.0) * (sqrt((pow((A - C), 2.0) + pow(B, 2.0))) - (C + A)))) / t_3;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = -pow(C, -0.5) * t_0;
} else if (t_4 <= -5e-187) {
tmp = sqrt(((t_2 * (F * 2.0)) * ((C + A) - hypot((A - C), B)))) / -t_2;
} else if (t_4 <= ((double) INFINITY)) {
tmp = (-1.0 / t_1) * sqrt((((fma(((B * B) / C), -0.5, A) + A) * (F * 2.0)) * t_1));
} else {
tmp = -1.0 / (sqrt(C) / t_0);
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = sqrt(Float64(-F)) t_1 = fma(Float64(-4.0 * C), A, Float64(B * B)) t_2 = fma(-4.0, Float64(C * A), Float64(B * B)) t_3 = Float64(Float64(C * Float64(A * 4.0)) - (B ^ 2.0)) t_4 = Float64(sqrt(Float64(Float64(Float64(t_3 * F) * 2.0) * Float64(sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))) - Float64(C + A)))) / t_3) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(Float64(-(C ^ -0.5)) * t_0); elseif (t_4 <= -5e-187) tmp = Float64(sqrt(Float64(Float64(t_2 * Float64(F * 2.0)) * Float64(Float64(C + A) - hypot(Float64(A - C), B)))) / Float64(-t_2)); elseif (t_4 <= Inf) tmp = Float64(Float64(-1.0 / t_1) * sqrt(Float64(Float64(Float64(fma(Float64(Float64(B * B) / C), -0.5, A) + A) * Float64(F * 2.0)) * t_1))); else tmp = Float64(-1.0 / Float64(sqrt(C) / t_0)); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[(-F)], $MachinePrecision]}, Block[{t$95$1 = N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision] - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(N[(t$95$3 * F), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(C + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[((-N[Power[C, -0.5], $MachinePrecision]) * t$95$0), $MachinePrecision], If[LessEqual[t$95$4, -5e-187], N[(N[Sqrt[N[(N[(t$95$2 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$2)), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[(-1.0 / t$95$1), $MachinePrecision] * N[Sqrt[N[(N[(N[(N[(N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision] * -0.5 + A), $MachinePrecision] + A), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(N[Sqrt[C], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{-F}\\
t_1 := \mathsf{fma}\left(-4 \cdot C, A, B \cdot B\right)\\
t_2 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
t_3 := C \cdot \left(A \cdot 4\right) - {B}^{2}\\
t_4 := \frac{\sqrt{\left(\left(t\_3 \cdot F\right) \cdot 2\right) \cdot \left(\sqrt{{\left(A - C\right)}^{2} + {B}^{2}} - \left(C + A\right)\right)}}{t\_3}\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;\left(-{C}^{-0.5}\right) \cdot t\_0\\
\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-187}:\\
\;\;\;\;\frac{\sqrt{\left(t\_2 \cdot \left(F \cdot 2\right)\right) \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(A - C, B\right)\right)}}{-t\_2}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{-1}{t\_1} \cdot \sqrt{\left(\left(\mathsf{fma}\left(\frac{B \cdot B}{C}, -0.5, A\right) + A\right) \cdot \left(F \cdot 2\right)\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\sqrt{C}}{t\_0}}\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0Initial program 3.1%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites32.6%
Applied rewrites32.7%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -4.9999999999999996e-187Initial program 99.5%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
lower-/.f64N/A
Applied rewrites99.5%
if -4.9999999999999996e-187 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0Initial program 19.4%
Taylor expanded in C around inf
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6433.5
Applied rewrites33.5%
Applied rewrites33.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites36.1%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 0.0%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites14.1%
Applied rewrites14.1%
Final simplification34.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma (* -4.0 C) A (* B B))))
(if (<= (pow B 2.0) 5e-290)
(* (sqrt (* (* t_0 (* F 2.0)) (+ A A))) (/ -1.0 t_0))
(if (<= (pow B 2.0) 2e+82)
(* (- (pow C -0.5)) (sqrt (- F)))
(* (/ (- (sqrt 2.0)) B) (sqrt (* (- A (hypot A B)) F)))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma((-4.0 * C), A, (B * B));
double tmp;
if (pow(B, 2.0) <= 5e-290) {
tmp = sqrt(((t_0 * (F * 2.0)) * (A + A))) * (-1.0 / t_0);
} else if (pow(B, 2.0) <= 2e+82) {
tmp = -pow(C, -0.5) * sqrt(-F);
} else {
tmp = (-sqrt(2.0) / B) * sqrt(((A - hypot(A, B)) * F));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(Float64(-4.0 * C), A, Float64(B * B)) tmp = 0.0 if ((B ^ 2.0) <= 5e-290) tmp = Float64(sqrt(Float64(Float64(t_0 * Float64(F * 2.0)) * Float64(A + A))) * Float64(-1.0 / t_0)); elseif ((B ^ 2.0) <= 2e+82) tmp = Float64(Float64(-(C ^ -0.5)) * sqrt(Float64(-F))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B) * sqrt(Float64(Float64(A - hypot(A, B)) * F))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-290], N[(N[Sqrt[N[(N[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e+82], N[((-N[Power[C, -0.5], $MachinePrecision]) * N[Sqrt[(-F)], $MachinePrecision]), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision] * N[Sqrt[N[(N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot C, A, B \cdot B\right)\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-290}:\\
\;\;\;\;\sqrt{\left(t\_0 \cdot \left(F \cdot 2\right)\right) \cdot \left(A + A\right)} \cdot \frac{-1}{t\_0}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+82}:\\
\;\;\;\;\left(-{C}^{-0.5}\right) \cdot \sqrt{-F}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B} \cdot \sqrt{\left(A - \mathsf{hypot}\left(A, B\right)\right) \cdot F}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000001e-290Initial program 18.8%
Taylor expanded in C around inf
lower--.f64N/A
mul-1-negN/A
lower-neg.f6426.7
Applied rewrites26.7%
Applied rewrites26.7%
if 5.0000000000000001e-290 < (pow.f64 B #s(literal 2 binary64)) < 1.9999999999999999e82Initial program 26.8%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites27.4%
Applied rewrites27.4%
if 1.9999999999999999e82 < (pow.f64 B #s(literal 2 binary64)) Initial program 12.9%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6423.8
Applied rewrites23.8%
Final simplification25.7%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= (pow B 2.0) 1e+108) (* (- (sqrt (/ 1.0 C))) (sqrt (- F))) (- (sqrt (* (/ (- (/ (+ C A) B) 1.0) B) (* F 2.0))))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 1e+108) {
tmp = -sqrt((1.0 / C)) * sqrt(-F);
} else {
tmp = -sqrt((((((C + A) / B) - 1.0) / B) * (F * 2.0)));
}
return tmp;
}
NOTE: A, B, C, and F 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 ((b ** 2.0d0) <= 1d+108) then
tmp = -sqrt((1.0d0 / c)) * sqrt(-f)
else
tmp = -sqrt((((((c + a) / b) - 1.0d0) / b) * (f * 2.0d0)))
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double tmp;
if (Math.pow(B, 2.0) <= 1e+108) {
tmp = -Math.sqrt((1.0 / C)) * Math.sqrt(-F);
} else {
tmp = -Math.sqrt((((((C + A) / B) - 1.0) / B) * (F * 2.0)));
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): tmp = 0 if math.pow(B, 2.0) <= 1e+108: tmp = -math.sqrt((1.0 / C)) * math.sqrt(-F) else: tmp = -math.sqrt((((((C + A) / B) - 1.0) / B) * (F * 2.0))) return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 1e+108) tmp = Float64(Float64(-sqrt(Float64(1.0 / C))) * sqrt(Float64(-F))); else tmp = Float64(-sqrt(Float64(Float64(Float64(Float64(Float64(C + A) / B) - 1.0) / B) * Float64(F * 2.0)))); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if ((B ^ 2.0) <= 1e+108)
tmp = -sqrt((1.0 / C)) * sqrt(-F);
else
tmp = -sqrt((((((C + A) / B) - 1.0) / B) * (F * 2.0)));
end
tmp_2 = tmp;
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e+108], N[((-N[Sqrt[N[(1.0 / C), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[(-F)], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[(N[(N[(N[(N[(C + A), $MachinePrecision] / B), $MachinePrecision] - 1.0), $MachinePrecision] / B), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 10^{+108}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{C}}\right) \cdot \sqrt{-F}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{\frac{C + A}{B} - 1}{B} \cdot \left(F \cdot 2\right)}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1e108Initial program 23.4%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites23.7%
Applied rewrites23.7%
Taylor expanded in C around 0
Applied rewrites23.7%
if 1e108 < (pow.f64 B #s(literal 2 binary64)) Initial program 11.8%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites27.8%
Taylor expanded in B around inf
Applied rewrites26.1%
Applied rewrites26.2%
Final simplification24.6%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= C 5.2e-247)
(/
(sqrt (* (* (fma (* -4.0 C) A (* B B)) (* F 2.0)) (+ A A)))
(fma (- B) B (* C (* A 4.0))))
(* (- (pow C -0.5)) (sqrt (- F)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (C <= 5.2e-247) {
tmp = sqrt(((fma((-4.0 * C), A, (B * B)) * (F * 2.0)) * (A + A))) / fma(-B, B, (C * (A * 4.0)));
} else {
tmp = -pow(C, -0.5) * sqrt(-F);
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (C <= 5.2e-247) tmp = Float64(sqrt(Float64(Float64(fma(Float64(-4.0 * C), A, Float64(B * B)) * Float64(F * 2.0)) * Float64(A + A))) / fma(Float64(-B), B, Float64(C * Float64(A * 4.0)))); else tmp = Float64(Float64(-(C ^ -0.5)) * sqrt(Float64(-F))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[C, 5.2e-247], N[(N[Sqrt[N[(N[(N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[((-B) * B + N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Power[C, -0.5], $MachinePrecision]) * N[Sqrt[(-F)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq 5.2 \cdot 10^{-247}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(-4 \cdot C, A, B \cdot B\right) \cdot \left(F \cdot 2\right)\right) \cdot \left(A + A\right)}}{\mathsf{fma}\left(-B, B, C \cdot \left(A \cdot 4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-{C}^{-0.5}\right) \cdot \sqrt{-F}\\
\end{array}
\end{array}
if C < 5.2e-247Initial program 24.3%
Taylor expanded in C around inf
lower--.f64N/A
mul-1-negN/A
lower-neg.f649.5
Applied rewrites9.5%
Applied rewrites9.5%
if 5.2e-247 < C Initial program 11.5%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites43.4%
Applied rewrites43.4%
Final simplification23.7%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= C 5.2e-247)
(/
(sqrt (* (* (fma (* -4.0 C) A (* B B)) (* F 2.0)) (+ A A)))
(fma (- B) B (* C (* A 4.0))))
(* (- (sqrt (/ 1.0 C))) (sqrt (- F)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (C <= 5.2e-247) {
tmp = sqrt(((fma((-4.0 * C), A, (B * B)) * (F * 2.0)) * (A + A))) / fma(-B, B, (C * (A * 4.0)));
} else {
tmp = -sqrt((1.0 / C)) * sqrt(-F);
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (C <= 5.2e-247) tmp = Float64(sqrt(Float64(Float64(fma(Float64(-4.0 * C), A, Float64(B * B)) * Float64(F * 2.0)) * Float64(A + A))) / fma(Float64(-B), B, Float64(C * Float64(A * 4.0)))); else tmp = Float64(Float64(-sqrt(Float64(1.0 / C))) * sqrt(Float64(-F))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[C, 5.2e-247], N[(N[Sqrt[N[(N[(N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[((-B) * B + N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(1.0 / C), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[(-F)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq 5.2 \cdot 10^{-247}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(-4 \cdot C, A, B \cdot B\right) \cdot \left(F \cdot 2\right)\right) \cdot \left(A + A\right)}}{\mathsf{fma}\left(-B, B, C \cdot \left(A \cdot 4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{C}}\right) \cdot \sqrt{-F}\\
\end{array}
\end{array}
if C < 5.2e-247Initial program 24.3%
Taylor expanded in C around inf
lower--.f64N/A
mul-1-negN/A
lower-neg.f649.5
Applied rewrites9.5%
Applied rewrites9.5%
if 5.2e-247 < C Initial program 11.5%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites43.4%
Applied rewrites43.4%
Taylor expanded in C around 0
Applied rewrites43.4%
Final simplification23.7%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= C -1.9e-130)
(*
(sqrt (* (* (* (* (+ A A) F) C) A) -8.0))
(/ -1.0 (fma (* -4.0 C) A (* B B))))
(if (<= C 3.4e-200)
(- (sqrt (* (/ (- (/ (+ C A) B) 1.0) B) (* F 2.0))))
(* (- (sqrt (/ 1.0 C))) (sqrt (- F))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (C <= -1.9e-130) {
tmp = sqrt((((((A + A) * F) * C) * A) * -8.0)) * (-1.0 / fma((-4.0 * C), A, (B * B)));
} else if (C <= 3.4e-200) {
tmp = -sqrt((((((C + A) / B) - 1.0) / B) * (F * 2.0)));
} else {
tmp = -sqrt((1.0 / C)) * sqrt(-F);
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (C <= -1.9e-130) tmp = Float64(sqrt(Float64(Float64(Float64(Float64(Float64(A + A) * F) * C) * A) * -8.0)) * Float64(-1.0 / fma(Float64(-4.0 * C), A, Float64(B * B)))); elseif (C <= 3.4e-200) tmp = Float64(-sqrt(Float64(Float64(Float64(Float64(Float64(C + A) / B) - 1.0) / B) * Float64(F * 2.0)))); else tmp = Float64(Float64(-sqrt(Float64(1.0 / C))) * sqrt(Float64(-F))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[C, -1.9e-130], N[(N[Sqrt[N[(N[(N[(N[(N[(A + A), $MachinePrecision] * F), $MachinePrecision] * C), $MachinePrecision] * A), $MachinePrecision] * -8.0), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[C, 3.4e-200], (-N[Sqrt[N[(N[(N[(N[(N[(C + A), $MachinePrecision] / B), $MachinePrecision] - 1.0), $MachinePrecision] / B), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), N[((-N[Sqrt[N[(1.0 / C), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[(-F)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq -1.9 \cdot 10^{-130}:\\
\;\;\;\;\sqrt{\left(\left(\left(\left(A + A\right) \cdot F\right) \cdot C\right) \cdot A\right) \cdot -8} \cdot \frac{-1}{\mathsf{fma}\left(-4 \cdot C, A, B \cdot B\right)}\\
\mathbf{elif}\;C \leq 3.4 \cdot 10^{-200}:\\
\;\;\;\;-\sqrt{\frac{\frac{C + A}{B} - 1}{B} \cdot \left(F \cdot 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{C}}\right) \cdot \sqrt{-F}\\
\end{array}
\end{array}
if C < -1.8999999999999999e-130Initial program 23.2%
Taylor expanded in C around inf
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f647.9
Applied rewrites7.9%
Applied rewrites7.9%
Taylor expanded in C around inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f648.1
Applied rewrites8.1%
if -1.8999999999999999e-130 < C < 3.4000000000000003e-200Initial program 26.4%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites33.3%
Taylor expanded in B around inf
Applied rewrites19.8%
Applied rewrites19.9%
if 3.4000000000000003e-200 < C Initial program 10.9%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites44.9%
Applied rewrites44.9%
Taylor expanded in C around 0
Applied rewrites44.9%
Final simplification25.4%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= B 2e+55) (* (- (sqrt (/ 1.0 C))) (sqrt (- F))) (* (- (sqrt 2.0)) (sqrt (* (/ -1.0 B) F)))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2e+55) {
tmp = -sqrt((1.0 / C)) * sqrt(-F);
} else {
tmp = -sqrt(2.0) * sqrt(((-1.0 / B) * F));
}
return tmp;
}
NOTE: A, B, C, and F 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 (b <= 2d+55) then
tmp = -sqrt((1.0d0 / c)) * sqrt(-f)
else
tmp = -sqrt(2.0d0) * sqrt((((-1.0d0) / b) * f))
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2e+55) {
tmp = -Math.sqrt((1.0 / C)) * Math.sqrt(-F);
} else {
tmp = -Math.sqrt(2.0) * Math.sqrt(((-1.0 / B) * F));
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): tmp = 0 if B <= 2e+55: tmp = -math.sqrt((1.0 / C)) * math.sqrt(-F) else: tmp = -math.sqrt(2.0) * math.sqrt(((-1.0 / B) * F)) return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 2e+55) tmp = Float64(Float64(-sqrt(Float64(1.0 / C))) * sqrt(Float64(-F))); else tmp = Float64(Float64(-sqrt(2.0)) * sqrt(Float64(Float64(-1.0 / B) * F))); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 2e+55)
tmp = -sqrt((1.0 / C)) * sqrt(-F);
else
tmp = -sqrt(2.0) * sqrt(((-1.0 / B) * F));
end
tmp_2 = tmp;
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 2e+55], N[((-N[Sqrt[N[(1.0 / C), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[(-F)], $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[2.0], $MachinePrecision]) * N[Sqrt[N[(N[(-1.0 / B), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 2 \cdot 10^{+55}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{C}}\right) \cdot \sqrt{-F}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{2}\right) \cdot \sqrt{\frac{-1}{B} \cdot F}\\
\end{array}
\end{array}
if B < 2.00000000000000002e55Initial program 21.4%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites21.8%
Applied rewrites21.8%
Taylor expanded in C around 0
Applied rewrites21.8%
if 2.00000000000000002e55 < B Initial program 7.1%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites25.4%
Taylor expanded in B around inf
Applied rewrites50.3%
Final simplification26.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (- (sqrt (/ 1.0 C))) (sqrt (- F))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return -sqrt((1.0 / C)) * sqrt(-F);
}
NOTE: A, B, C, and F 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((1.0d0 / c)) * sqrt(-f)
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((1.0 / C)) * Math.sqrt(-F);
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return -math.sqrt((1.0 / C)) * math.sqrt(-F)
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(1.0 / C))) * sqrt(Float64(-F))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((1.0 / C)) * sqrt(-F);
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(1.0 / C), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[(-F)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\left(-\sqrt{\frac{1}{C}}\right) \cdot \sqrt{-F}
\end{array}
Initial program 18.9%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites18.7%
Applied rewrites18.7%
Taylor expanded in C around 0
Applied rewrites18.7%
Final simplification18.7%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (sqrt (- F)) (- (sqrt C))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return sqrt(-F) / -sqrt(C);
}
NOTE: A, B, C, and F 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(-f) / -sqrt(c)
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return Math.sqrt(-F) / -Math.sqrt(C);
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return math.sqrt(-F) / -math.sqrt(C)
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(sqrt(Float64(-F)) / Float64(-sqrt(C))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = sqrt(-F) / -sqrt(C);
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[Sqrt[(-F)], $MachinePrecision] / (-N[Sqrt[C], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\frac{\sqrt{-F}}{-\sqrt{C}}
\end{array}
Initial program 18.9%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites18.7%
Applied rewrites18.7%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (- (sqrt (* (* (/ F C) -0.5) 2.0))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return -sqrt((((F / C) * -0.5) * 2.0));
}
NOTE: A, B, C, and F 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((((f / c) * (-0.5d0)) * 2.0d0))
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((((F / C) * -0.5) * 2.0));
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return -math.sqrt((((F / C) * -0.5) * 2.0))
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(-sqrt(Float64(Float64(Float64(F / C) * -0.5) * 2.0))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((((F / C) * -0.5) * 2.0));
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := (-N[Sqrt[N[(N[(N[(F / C), $MachinePrecision] * -0.5), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
-\sqrt{\left(\frac{F}{C} \cdot -0.5\right) \cdot 2}
\end{array}
Initial program 18.9%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites14.2%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (- (sqrt (/ (- F) C))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return -sqrt((-F / C));
}
NOTE: A, B, C, and F 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((-f / c))
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((-F / C));
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return -math.sqrt((-F / C))
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(-sqrt(Float64(Float64(-F) / C))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((-F / C));
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := (-N[Sqrt[N[((-F) / C), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
-\sqrt{\frac{-F}{C}}
\end{array}
Initial program 18.9%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Applied rewrites18.7%
Applied rewrites14.2%
herbie shell --seed 2024298
(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))))