
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (* b b) b)))
(fma
(fma
(fma
(/ c (* t_0 (* b b)))
(* -0.5625 (* c c))
(*
(* (/ 6.328125 (* (* t_0 b) t_0)) (* (* (* c c) c) c))
(* -0.16666666666666666 a)))
a
(/ (* -0.375 (* c c)) t_0))
a
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double t_0 = (b * b) * b;
return fma(fma(fma((c / (t_0 * (b * b))), (-0.5625 * (c * c)), (((6.328125 / ((t_0 * b) * t_0)) * (((c * c) * c) * c)) * (-0.16666666666666666 * a))), a, ((-0.375 * (c * c)) / t_0)), a, (-0.5 * (c / b)));
}
function code(a, b, c) t_0 = Float64(Float64(b * b) * b) return fma(fma(fma(Float64(c / Float64(t_0 * Float64(b * b))), Float64(-0.5625 * Float64(c * c)), Float64(Float64(Float64(6.328125 / Float64(Float64(t_0 * b) * t_0)) * Float64(Float64(Float64(c * c) * c) * c)) * Float64(-0.16666666666666666 * a))), a, Float64(Float64(-0.375 * Float64(c * c)) / t_0)), a, Float64(-0.5 * Float64(c / b))) end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]}, N[(N[(N[(N[(c / N[(t$95$0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.5625 * N[(c * c), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(6.328125 / N[(N[(t$95$0 * b), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c * c), $MachinePrecision] * c), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] * N[(-0.16666666666666666 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + N[(N[(-0.375 * N[(c * c), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] * a + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot b\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{c}{t\_0 \cdot \left(b \cdot b\right)}, -0.5625 \cdot \left(c \cdot c\right), \left(\frac{6.328125}{\left(t\_0 \cdot b\right) \cdot t\_0} \cdot \left(\left(\left(c \cdot c\right) \cdot c\right) \cdot c\right)\right) \cdot \left(-0.16666666666666666 \cdot a\right)\right), a, \frac{-0.375 \cdot \left(c \cdot c\right)}{t\_0}\right), a, -0.5 \cdot \frac{c}{b}\right)
\end{array}
\end{array}
Initial program 18.5%
Taylor expanded in a around 0
Applied rewrites97.4%
Applied rewrites97.4%
Final simplification97.4%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0)) -0.2) (/ (- (sqrt (fma b b (* (* -3.0 a) c))) b) (* a 3.0)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0)) <= -0.2) {
tmp = (sqrt(fma(b, b, ((-3.0 * a) * c))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)) <= -0.2) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(-3.0 * a) * c))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -0.2], N[(N[(N[Sqrt[N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3} \leq -0.2:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -0.20000000000000001Initial program 71.4%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval71.6
Applied rewrites71.6%
if -0.20000000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 12.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6494.6
Applied rewrites94.6%
Final simplification92.3%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0)) -0.2) (/ (- (sqrt (fma b b (* (* -3.0 c) a))) b) (* a 3.0)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0)) <= -0.2) {
tmp = (sqrt(fma(b, b, ((-3.0 * c) * a))) - b) / (a * 3.0);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)) <= -0.2) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(-3.0 * c) * a))) - b) / Float64(a * 3.0)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -0.2], N[(N[(N[Sqrt[N[(b * b + N[(N[(-3.0 * c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3} \leq -0.2:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -0.20000000000000001Initial program 71.4%
Applied rewrites71.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f6471.6
Applied rewrites71.6%
if -0.20000000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 12.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6494.6
Applied rewrites94.6%
Final simplification92.3%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0)) -0.2) (/ (* (- (sqrt (fma (* -3.0 c) a (* b b))) b) 0.3333333333333333) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0)) <= -0.2) {
tmp = ((sqrt(fma((-3.0 * c), a, (b * b))) - b) * 0.3333333333333333) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)) <= -0.2) tmp = Float64(Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) * 0.3333333333333333) / a); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -0.2], N[(N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3} \leq -0.2:\\
\;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b\right) \cdot 0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -0.20000000000000001Initial program 71.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites71.3%
if -0.20000000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 12.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6494.6
Applied rewrites94.6%
Final simplification92.3%
(FPCore (a b c) :precision binary64 (if (<= (/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0)) -0.2) (* (/ (- (sqrt (fma (* -3.0 c) a (* b b))) b) a) 0.3333333333333333) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (((sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0)) <= -0.2) {
tmp = ((sqrt(fma((-3.0 * c), a, (b * b))) - b) / a) * 0.3333333333333333;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0)) <= -0.2) tmp = Float64(Float64(Float64(sqrt(fma(Float64(-3.0 * c), a, Float64(b * b))) - b) / a) * 0.3333333333333333); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], -0.2], N[(N[(N[(N[Sqrt[N[(N[(-3.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3} \leq -0.2:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)} - b}{a} \cdot 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -0.20000000000000001Initial program 71.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
div-invN/A
lower-*.f64N/A
Applied rewrites71.3%
if -0.20000000000000001 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) Initial program 12.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6494.6
Applied rewrites94.6%
Final simplification92.3%
(FPCore (a b c) :precision binary64 (fma (/ (* (fma (* (/ c (* b b)) a) -0.5625 -0.375) (* c c)) (* (* b b) b)) a (* -0.5 (/ c b))))
double code(double a, double b, double c) {
return fma(((fma(((c / (b * b)) * a), -0.5625, -0.375) * (c * c)) / ((b * b) * b)), a, (-0.5 * (c / b)));
}
function code(a, b, c) return fma(Float64(Float64(fma(Float64(Float64(c / Float64(b * b)) * a), -0.5625, -0.375) * Float64(c * c)) / Float64(Float64(b * b) * b)), a, Float64(-0.5 * Float64(c / b))) end
code[a_, b_, c_] := N[(N[(N[(N[(N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * -0.5625 + -0.375), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision] / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * a + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{c}{b \cdot b} \cdot a, -0.5625, -0.375\right) \cdot \left(c \cdot c\right)}{\left(b \cdot b\right) \cdot b}, a, -0.5 \cdot \frac{c}{b}\right)
\end{array}
Initial program 18.5%
Taylor expanded in a around 0
Applied rewrites97.4%
Taylor expanded in b around inf
Applied rewrites96.7%
Taylor expanded in c around 0
Applied rewrites96.7%
Final simplification96.7%
(FPCore (a b c) :precision binary64 (/ (fma (* -0.375 a) (* (/ c (* b b)) c) (* -0.5 c)) b))
double code(double a, double b, double c) {
return fma((-0.375 * a), ((c / (b * b)) * c), (-0.5 * c)) / b;
}
function code(a, b, c) return Float64(fma(Float64(-0.375 * a), Float64(Float64(c / Float64(b * b)) * c), Float64(-0.5 * c)) / b) end
code[a_, b_, c_] := N[(N[(N[(-0.375 * a), $MachinePrecision] * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] + N[(-0.5 * c), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(-0.375 \cdot a, \frac{c}{b \cdot b} \cdot c, -0.5 \cdot c\right)}{b}
\end{array}
Initial program 18.5%
Taylor expanded in b around inf
lower-/.f64N/A
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6495.1
Applied rewrites95.1%
Final simplification95.1%
(FPCore (a b c) :precision binary64 (* (fma (* -0.375 c) (/ a (* (* b b) b)) (/ -0.5 b)) c))
double code(double a, double b, double c) {
return fma((-0.375 * c), (a / ((b * b) * b)), (-0.5 / b)) * c;
}
function code(a, b, c) return Float64(fma(Float64(-0.375 * c), Float64(a / Float64(Float64(b * b) * b)), Float64(-0.5 / b)) * c) end
code[a_, b_, c_] := N[(N[(N[(-0.375 * c), $MachinePrecision] * N[(a / N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / b), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.375 \cdot c, \frac{a}{\left(b \cdot b\right) \cdot b}, \frac{-0.5}{b}\right) \cdot c
\end{array}
Initial program 18.5%
Taylor expanded in c around 0
*-commutativeN/A
sub-negN/A
associate-*r/N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
lower-*.f64N/A
Applied rewrites94.8%
Final simplification94.8%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 18.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.2
Applied rewrites90.2%
Final simplification90.2%
(FPCore (a b c) :precision binary64 (* (/ -0.5 b) c))
double code(double a, double b, double c) {
return (-0.5 / b) * c;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((-0.5d0) / b) * c
end function
public static double code(double a, double b, double c) {
return (-0.5 / b) * c;
}
def code(a, b, c): return (-0.5 / b) * c
function code(a, b, c) return Float64(Float64(-0.5 / b) * c) end
function tmp = code(a, b, c) tmp = (-0.5 / b) * c; end
code[a_, b_, c_] := N[(N[(-0.5 / b), $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{b} \cdot c
\end{array}
Initial program 18.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.2
Applied rewrites90.2%
Applied rewrites89.9%
Final simplification89.9%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 18.5%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lift-*.f64N/A
associate-/l/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites18.5%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
+-commutativeN/A
distribute-lft-inN/A
lower-fma.f64N/A
lower-*.f6420.0
Applied rewrites20.0%
Taylor expanded in c around 0
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-eval3.3
Applied rewrites3.3%
herbie shell --seed 2024240
(FPCore (a b c)
:name "Cubic critical, wide range"
:precision binary64
:pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))