
(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 16 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 (/ -1.0 (* (/ (* a 3.0) a) (/ (+ b (sqrt (fma -3.0 (* a c) (pow b 2.0)))) (* 3.0 c)))))
double code(double a, double b, double c) {
return -1.0 / (((a * 3.0) / a) * ((b + sqrt(fma(-3.0, (a * c), pow(b, 2.0)))) / (3.0 * c)));
}
function code(a, b, c) return Float64(-1.0 / Float64(Float64(Float64(a * 3.0) / a) * Float64(Float64(b + sqrt(fma(-3.0, Float64(a * c), (b ^ 2.0)))) / Float64(3.0 * c)))) end
code[a_, b_, c_] := N[(-1.0 / N[(N[(N[(a * 3.0), $MachinePrecision] / a), $MachinePrecision] * N[(N[(b + N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{\frac{a \cdot 3}{a} \cdot \frac{b + \sqrt{\mathsf{fma}\left(-3, a \cdot c, {b}^{2}\right)}}{3 \cdot c}}
\end{array}
Initial program 52.6%
neg-sub052.6%
sqr-neg52.6%
associate-+l-52.6%
sub0-neg52.6%
sub-neg52.6%
distribute-neg-in52.6%
remove-double-neg52.6%
sqr-neg52.6%
associate-*l*52.6%
Simplified52.6%
expm1-log1p-u52.6%
expm1-undefine49.3%
Applied egg-rr49.3%
expm1-define52.6%
*-commutative52.6%
Simplified52.6%
flip-+52.4%
pow252.4%
add-sqr-sqrt54.2%
pow254.2%
expm1-log1p-u54.3%
associate-*l*54.3%
pow254.3%
expm1-log1p-u54.3%
associate-*l*54.3%
Applied egg-rr54.3%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
*-un-lft-identity99.1%
associate-/l/99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-lft-identity99.1%
associate-*r/99.1%
fma-define99.1%
+-rgt-identity99.1%
*-commutative99.1%
times-frac99.1%
*-commutative99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (a b c)
:precision binary64
(if (<= b 0.38)
(/ 1.0 (* a (/ 3.0 (fma -1.0 b (sqrt (- (pow b 2.0) (* a (* 3.0 c))))))))
(/
(/
1.0
(/
(+
(* -0.6666666666666666 (/ b c))
(* a (+ (* 0.375 (/ (* a c) (pow b 3.0))) (* 0.5 (/ 1.0 b)))))
a))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.38) {
tmp = 1.0 / (a * (3.0 / fma(-1.0, b, sqrt((pow(b, 2.0) - (a * (3.0 * c)))))));
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (a * ((0.375 * ((a * c) / pow(b, 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 3.0);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 0.38) tmp = Float64(1.0 / Float64(a * Float64(3.0 / fma(-1.0, b, sqrt(Float64((b ^ 2.0) - Float64(a * Float64(3.0 * c)))))))); else tmp = Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / c)) + Float64(a * Float64(Float64(0.375 * Float64(Float64(a * c) / (b ^ 3.0))) + Float64(0.5 * Float64(1.0 / b))))) / a)) / Float64(a * 3.0)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 0.38], N[(1.0 / N[(a * N[(3.0 / N[(-1.0 * b + N[Sqrt[N[(N[Power[b, 2.0], $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(0.375 * N[(N[(a * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.38:\\
\;\;\;\;\frac{1}{a \cdot \frac{3}{\mathsf{fma}\left(-1, b, \sqrt{{b}^{2} - a \cdot \left(3 \cdot c\right)}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{c} + a \cdot \left(0.375 \cdot \frac{a \cdot c}{{b}^{3}} + 0.5 \cdot \frac{1}{b}\right)}{a}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 0.38Initial program 84.1%
neg-sub084.1%
sqr-neg84.1%
associate-+l-84.1%
sub0-neg84.1%
sub-neg84.1%
distribute-neg-in84.1%
remove-double-neg84.1%
sqr-neg84.1%
associate-*l*84.1%
Simplified84.1%
expm1-log1p-u84.1%
expm1-undefine62.0%
Applied egg-rr62.0%
expm1-define84.1%
*-commutative84.1%
Simplified84.1%
clear-num84.1%
inv-pow84.1%
*-commutative84.1%
neg-mul-184.1%
fma-define84.1%
pow284.1%
expm1-log1p-u84.1%
associate-*l*84.2%
Applied egg-rr84.2%
unpow-184.2%
associate-/l*84.3%
Simplified84.3%
if 0.38 < b Initial program 47.3%
neg-sub047.3%
sqr-neg47.3%
associate-+l-47.3%
sub0-neg47.3%
sub-neg47.3%
distribute-neg-in47.3%
remove-double-neg47.3%
sqr-neg47.3%
associate-*l*47.3%
Simplified47.3%
expm1-log1p-u47.3%
expm1-undefine47.2%
Applied egg-rr47.2%
expm1-define47.3%
*-commutative47.3%
Simplified47.3%
flip-+47.1%
pow247.1%
add-sqr-sqrt48.9%
pow248.9%
expm1-log1p-u49.0%
associate-*l*49.0%
pow249.0%
expm1-log1p-u49.0%
associate-*l*49.0%
Applied egg-rr49.0%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in a around 0 93.5%
Final simplification92.2%
(FPCore (a b c) :precision binary64 (* (/ (/ (* a (* 3.0 c)) (- (- b) (sqrt (fma -3.0 (* a c) (pow b 2.0))))) a) 0.3333333333333333))
double code(double a, double b, double c) {
return (((a * (3.0 * c)) / (-b - sqrt(fma(-3.0, (a * c), pow(b, 2.0))))) / a) * 0.3333333333333333;
}
function code(a, b, c) return Float64(Float64(Float64(Float64(a * Float64(3.0 * c)) / Float64(Float64(-b) - sqrt(fma(-3.0, Float64(a * c), (b ^ 2.0))))) / a) * 0.3333333333333333) end
code[a_, b_, c_] := N[(N[(N[(N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision] / N[((-b) - N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{a \cdot \left(3 \cdot c\right)}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-3, a \cdot c, {b}^{2}\right)}}}{a} \cdot 0.3333333333333333
\end{array}
Initial program 52.6%
neg-sub052.6%
sqr-neg52.6%
associate-+l-52.6%
sub0-neg52.6%
sub-neg52.6%
distribute-neg-in52.6%
remove-double-neg52.6%
sqr-neg52.6%
associate-*l*52.6%
Simplified52.6%
expm1-log1p-u52.6%
expm1-undefine49.3%
Applied egg-rr49.3%
expm1-define52.6%
*-commutative52.6%
Simplified52.6%
flip-+52.4%
pow252.4%
add-sqr-sqrt54.2%
pow254.2%
expm1-log1p-u54.3%
associate-*l*54.3%
pow254.3%
expm1-log1p-u54.3%
associate-*l*54.3%
Applied egg-rr54.3%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
div-inv99.0%
associate-/r/99.0%
*-commutative99.0%
Applied egg-rr99.0%
associate-*r/99.0%
times-frac98.9%
associate-*l/98.9%
*-lft-identity98.9%
fma-define98.9%
+-rgt-identity98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (a b c)
:precision binary64
(if (<= b 0.38)
(/ (- (sqrt (fma b b (* a (* -3.0 c)))) b) (* a 3.0))
(/
(/
1.0
(/
(+
(* -0.6666666666666666 (/ b c))
(* a (+ (* 0.375 (/ (* a c) (pow b 3.0))) (* 0.5 (/ 1.0 b)))))
a))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.38) {
tmp = (sqrt(fma(b, b, (a * (-3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (a * ((0.375 * ((a * c) / pow(b, 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 3.0);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 0.38) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(-3.0 * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / c)) + Float64(a * Float64(Float64(0.375 * Float64(Float64(a * c) / (b ^ 3.0))) + Float64(0.5 * Float64(1.0 / b))))) / a)) / Float64(a * 3.0)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 0.38], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(-3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(0.375 * N[(N[(a * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.38:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{c} + a \cdot \left(0.375 \cdot \frac{a \cdot c}{{b}^{3}} + 0.5 \cdot \frac{1}{b}\right)}{a}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 0.38Initial program 84.1%
/-rgt-identity84.1%
metadata-eval84.1%
Simplified84.3%
if 0.38 < b Initial program 47.3%
neg-sub047.3%
sqr-neg47.3%
associate-+l-47.3%
sub0-neg47.3%
sub-neg47.3%
distribute-neg-in47.3%
remove-double-neg47.3%
sqr-neg47.3%
associate-*l*47.3%
Simplified47.3%
expm1-log1p-u47.3%
expm1-undefine47.2%
Applied egg-rr47.2%
expm1-define47.3%
*-commutative47.3%
Simplified47.3%
flip-+47.1%
pow247.1%
add-sqr-sqrt48.9%
pow248.9%
expm1-log1p-u49.0%
associate-*l*49.0%
pow249.0%
expm1-log1p-u49.0%
associate-*l*49.0%
Applied egg-rr49.0%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in a around 0 93.5%
Final simplification92.2%
(FPCore (a b c)
:precision binary64
(if (<= b 0.36)
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (* a 3.0))
(/
(/
1.0
(/
(+
(* -0.6666666666666666 (/ b c))
(* a (+ (* 0.375 (/ (* a c) (pow b 3.0))) (* 0.5 (/ 1.0 b)))))
a))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.36) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (a * ((0.375 * ((a * c) / pow(b, 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 3.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 0.36d0) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a * 3.0d0)
else
tmp = (1.0d0 / ((((-0.6666666666666666d0) * (b / c)) + (a * ((0.375d0 * ((a * c) / (b ** 3.0d0))) + (0.5d0 * (1.0d0 / b))))) / a)) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 0.36) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (a * ((0.375 * ((a * c) / Math.pow(b, 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 0.36: tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0) else: tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (a * ((0.375 * ((a * c) / math.pow(b, 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 0.36) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / c)) + Float64(a * Float64(Float64(0.375 * Float64(Float64(a * c) / (b ^ 3.0))) + Float64(0.5 * Float64(1.0 / b))))) / a)) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 0.36) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0); else tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (a * ((0.375 * ((a * c) / (b ^ 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 0.36], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(0.375 * N[(N[(a * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.36:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{c} + a \cdot \left(0.375 \cdot \frac{a \cdot c}{{b}^{3}} + 0.5 \cdot \frac{1}{b}\right)}{a}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 0.35999999999999999Initial program 84.1%
neg-sub084.1%
sqr-neg84.1%
associate-+l-84.1%
sub0-neg84.1%
sub-neg84.1%
distribute-neg-in84.1%
remove-double-neg84.1%
sqr-neg84.1%
associate-*l*84.1%
Simplified84.1%
expm1-log1p-u84.1%
expm1-undefine62.0%
Applied egg-rr62.0%
expm1-define84.1%
*-commutative84.1%
Simplified84.1%
Taylor expanded in a around 0 84.1%
*-commutative84.1%
associate-*r*84.2%
Simplified84.2%
if 0.35999999999999999 < b Initial program 47.3%
neg-sub047.3%
sqr-neg47.3%
associate-+l-47.3%
sub0-neg47.3%
sub-neg47.3%
distribute-neg-in47.3%
remove-double-neg47.3%
sqr-neg47.3%
associate-*l*47.3%
Simplified47.3%
expm1-log1p-u47.3%
expm1-undefine47.2%
Applied egg-rr47.2%
expm1-define47.3%
*-commutative47.3%
Simplified47.3%
flip-+47.1%
pow247.1%
add-sqr-sqrt48.9%
pow248.9%
expm1-log1p-u49.0%
associate-*l*49.0%
pow249.0%
expm1-log1p-u49.0%
associate-*l*49.0%
Applied egg-rr49.0%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in a around 0 93.5%
Final simplification92.1%
(FPCore (a b c)
:precision binary64
(if (<= b 0.37)
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (* a 3.0))
(/
(/
1.0
(/
(+
(* -0.6666666666666666 (/ b a))
(* c (+ (* 0.375 (/ (* a c) (pow b 3.0))) (* 0.5 (/ 1.0 b)))))
c))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.37) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / a)) + (c * ((0.375 * ((a * c) / pow(b, 3.0))) + (0.5 * (1.0 / b))))) / c)) / (a * 3.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 0.37d0) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a * 3.0d0)
else
tmp = (1.0d0 / ((((-0.6666666666666666d0) * (b / a)) + (c * ((0.375d0 * ((a * c) / (b ** 3.0d0))) + (0.5d0 * (1.0d0 / b))))) / c)) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 0.37) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / a)) + (c * ((0.375 * ((a * c) / Math.pow(b, 3.0))) + (0.5 * (1.0 / b))))) / c)) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 0.37: tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0) else: tmp = (1.0 / (((-0.6666666666666666 * (b / a)) + (c * ((0.375 * ((a * c) / math.pow(b, 3.0))) + (0.5 * (1.0 / b))))) / c)) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 0.37) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(c * Float64(Float64(0.375 * Float64(Float64(a * c) / (b ^ 3.0))) + Float64(0.5 * Float64(1.0 / b))))) / c)) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 0.37) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0); else tmp = (1.0 / (((-0.6666666666666666 * (b / a)) + (c * ((0.375 * ((a * c) / (b ^ 3.0))) + (0.5 * (1.0 / b))))) / c)) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 0.37], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(c * N[(N[(0.375 * N[(N[(a * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.37:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{a} + c \cdot \left(0.375 \cdot \frac{a \cdot c}{{b}^{3}} + 0.5 \cdot \frac{1}{b}\right)}{c}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 0.37Initial program 84.1%
neg-sub084.1%
sqr-neg84.1%
associate-+l-84.1%
sub0-neg84.1%
sub-neg84.1%
distribute-neg-in84.1%
remove-double-neg84.1%
sqr-neg84.1%
associate-*l*84.1%
Simplified84.1%
expm1-log1p-u84.1%
expm1-undefine62.0%
Applied egg-rr62.0%
expm1-define84.1%
*-commutative84.1%
Simplified84.1%
Taylor expanded in a around 0 84.1%
*-commutative84.1%
associate-*r*84.2%
Simplified84.2%
if 0.37 < b Initial program 47.3%
neg-sub047.3%
sqr-neg47.3%
associate-+l-47.3%
sub0-neg47.3%
sub-neg47.3%
distribute-neg-in47.3%
remove-double-neg47.3%
sqr-neg47.3%
associate-*l*47.3%
Simplified47.3%
expm1-log1p-u47.3%
expm1-undefine47.2%
Applied egg-rr47.2%
expm1-define47.3%
*-commutative47.3%
Simplified47.3%
flip-+47.1%
pow247.1%
add-sqr-sqrt48.9%
pow248.9%
expm1-log1p-u49.0%
associate-*l*49.0%
pow249.0%
expm1-log1p-u49.0%
associate-*l*49.0%
Applied egg-rr49.0%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in c around 0 93.4%
Final simplification92.1%
(FPCore (a b c)
:precision binary64
(if (<= b 6.5)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/
(/ 1.0 (/ (fma -0.6666666666666666 (/ b c) (* 0.5 (/ a b))) a))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (fma(-0.6666666666666666, (b / c), (0.5 * (a / b))) / a)) / (a * 3.0);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 6.5) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(1.0 / Float64(fma(-0.6666666666666666, Float64(b / c), Float64(0.5 * Float64(a / b))) / a)) / Float64(a * 3.0)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 6.5], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(-0.6666666666666666 * N[(b / c), $MachinePrecision] + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, 0.5 \cdot \frac{a}{b}\right)}{a}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 6.5Initial program 81.5%
if 6.5 < b Initial program 44.8%
neg-sub044.8%
sqr-neg44.8%
associate-+l-44.8%
sub0-neg44.8%
sub-neg44.8%
distribute-neg-in44.8%
remove-double-neg44.8%
sqr-neg44.8%
associate-*l*44.8%
Simplified44.8%
expm1-log1p-u44.7%
expm1-undefine44.7%
Applied egg-rr44.7%
expm1-define44.7%
*-commutative44.7%
Simplified44.7%
flip-+44.6%
pow244.6%
add-sqr-sqrt46.5%
pow246.5%
expm1-log1p-u46.6%
associate-*l*46.6%
pow246.6%
expm1-log1p-u46.6%
associate-*l*46.6%
Applied egg-rr46.6%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in a around 0 89.6%
fma-define89.7%
Simplified89.7%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b 6.8)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/
(/ 1.0 (/ (fma -0.6666666666666666 (/ b a) (* 0.5 (/ c b))) c))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.8) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (fma(-0.6666666666666666, (b / a), (0.5 * (c / b))) / c)) / (a * 3.0);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 6.8) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(1.0 / Float64(fma(-0.6666666666666666, Float64(b / a), Float64(0.5 * Float64(c / b))) / c)) / Float64(a * 3.0)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 6.8], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.8:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{a}, 0.5 \cdot \frac{c}{b}\right)}{c}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 6.79999999999999982Initial program 81.5%
if 6.79999999999999982 < b Initial program 44.8%
neg-sub044.8%
sqr-neg44.8%
associate-+l-44.8%
sub0-neg44.8%
sub-neg44.8%
distribute-neg-in44.8%
remove-double-neg44.8%
sqr-neg44.8%
associate-*l*44.8%
Simplified44.8%
expm1-log1p-u44.7%
expm1-undefine44.7%
Applied egg-rr44.7%
expm1-define44.7%
*-commutative44.7%
Simplified44.7%
flip-+44.6%
pow244.6%
add-sqr-sqrt46.5%
pow246.5%
expm1-log1p-u46.6%
associate-*l*46.6%
pow246.6%
expm1-log1p-u46.6%
associate-*l*46.6%
Applied egg-rr46.6%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in c around 0 89.6%
fma-define89.6%
Simplified89.6%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b 7.6)
(/ (- (sqrt (- (* b b) (* c (* a 3.0)))) b) (* a 3.0))
(/
(/ 1.0 (/ (+ (* -0.6666666666666666 (/ b c)) (* 0.5 (/ a b))) a))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.6) {
tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 7.6d0) then
tmp = (sqrt(((b * b) - (c * (a * 3.0d0)))) - b) / (a * 3.0d0)
else
tmp = (1.0d0 / ((((-0.6666666666666666d0) * (b / c)) + (0.5d0 * (a / b))) / a)) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 7.6) {
tmp = (Math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.6: tmp = (math.sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0) else: tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.6) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 3.0)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / c)) + Float64(0.5 * Float64(a / b))) / a)) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.6) tmp = (sqrt(((b * b) - (c * (a * 3.0)))) - b) / (a * 3.0); else tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.6], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.6:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{c} + 0.5 \cdot \frac{a}{b}}{a}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 7.5999999999999996Initial program 81.5%
if 7.5999999999999996 < b Initial program 44.8%
neg-sub044.8%
sqr-neg44.8%
associate-+l-44.8%
sub0-neg44.8%
sub-neg44.8%
distribute-neg-in44.8%
remove-double-neg44.8%
sqr-neg44.8%
associate-*l*44.8%
Simplified44.8%
expm1-log1p-u44.7%
expm1-undefine44.7%
Applied egg-rr44.7%
expm1-define44.7%
*-commutative44.7%
Simplified44.7%
flip-+44.6%
pow244.6%
add-sqr-sqrt46.5%
pow246.5%
expm1-log1p-u46.6%
associate-*l*46.6%
pow246.6%
expm1-log1p-u46.6%
associate-*l*46.6%
Applied egg-rr46.6%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in a around 0 89.6%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b 6.6)
(/ (- (sqrt (- (* b b) (* a (* 3.0 c)))) b) (* a 3.0))
(/
(/ 1.0 (/ (+ (* -0.6666666666666666 (/ b c)) (* 0.5 (/ a b))) a))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.6) {
tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 6.6d0) then
tmp = (sqrt(((b * b) - (a * (3.0d0 * c)))) - b) / (a * 3.0d0)
else
tmp = (1.0d0 / ((((-0.6666666666666666d0) * (b / c)) + (0.5d0 * (a / b))) / a)) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6.6) {
tmp = (Math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.6: tmp = (math.sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0) else: tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.6) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(a * Float64(3.0 * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / c)) + Float64(0.5 * Float64(a / b))) / a)) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.6) tmp = (sqrt(((b * b) - (a * (3.0 * c)))) - b) / (a * 3.0); else tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.6], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.6:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(3 \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{c} + 0.5 \cdot \frac{a}{b}}{a}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 6.5999999999999996Initial program 81.5%
neg-sub081.5%
sqr-neg81.5%
associate-+l-81.5%
sub0-neg81.5%
sub-neg81.5%
distribute-neg-in81.5%
remove-double-neg81.5%
sqr-neg81.5%
associate-*l*81.4%
Simplified81.4%
expm1-log1p-u81.4%
expm1-undefine66.1%
Applied egg-rr66.1%
expm1-define81.4%
*-commutative81.4%
Simplified81.4%
Taylor expanded in a around 0 81.4%
*-commutative81.4%
associate-*r*81.4%
Simplified81.4%
if 6.5999999999999996 < b Initial program 44.8%
neg-sub044.8%
sqr-neg44.8%
associate-+l-44.8%
sub0-neg44.8%
sub-neg44.8%
distribute-neg-in44.8%
remove-double-neg44.8%
sqr-neg44.8%
associate-*l*44.8%
Simplified44.8%
expm1-log1p-u44.7%
expm1-undefine44.7%
Applied egg-rr44.7%
expm1-define44.7%
*-commutative44.7%
Simplified44.7%
flip-+44.6%
pow244.6%
add-sqr-sqrt46.5%
pow246.5%
expm1-log1p-u46.6%
associate-*l*46.6%
pow246.6%
expm1-log1p-u46.6%
associate-*l*46.6%
Applied egg-rr46.6%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in a around 0 89.6%
Final simplification87.8%
(FPCore (a b c)
:precision binary64
(if (<= b 6.6)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* a 3.0))
(/
(/ 1.0 (/ (+ (* -0.6666666666666666 (/ b c)) (* 0.5 (/ a b))) a))
(* a 3.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.6) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 6.6d0) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (a * 3.0d0)
else
tmp = (1.0d0 / ((((-0.6666666666666666d0) * (b / c)) + (0.5d0 * (a / b))) / a)) / (a * 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 6.6) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0);
} else {
tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.6: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0) else: tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.6) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(a * 3.0)); else tmp = Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / c)) + Float64(0.5 * Float64(a / b))) / a)) / Float64(a * 3.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.6) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (a * 3.0); else tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.6], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.6:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{c} + 0.5 \cdot \frac{a}{b}}{a}}}{a \cdot 3}\\
\end{array}
\end{array}
if b < 6.5999999999999996Initial program 81.5%
neg-sub081.5%
sqr-neg81.5%
associate-+l-81.5%
sub0-neg81.5%
sub-neg81.5%
distribute-neg-in81.5%
remove-double-neg81.5%
sqr-neg81.5%
associate-*l*81.4%
Simplified81.4%
if 6.5999999999999996 < b Initial program 44.8%
neg-sub044.8%
sqr-neg44.8%
associate-+l-44.8%
sub0-neg44.8%
sub-neg44.8%
distribute-neg-in44.8%
remove-double-neg44.8%
sqr-neg44.8%
associate-*l*44.8%
Simplified44.8%
expm1-log1p-u44.7%
expm1-undefine44.7%
Applied egg-rr44.7%
expm1-define44.7%
*-commutative44.7%
Simplified44.7%
flip-+44.6%
pow244.6%
add-sqr-sqrt46.5%
pow246.5%
expm1-log1p-u46.6%
associate-*l*46.6%
pow246.6%
expm1-log1p-u46.6%
associate-*l*46.6%
Applied egg-rr46.6%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in a around 0 89.6%
Final simplification87.8%
(FPCore (a b c) :precision binary64 (/ (/ 1.0 (/ (+ (* -0.6666666666666666 (/ b c)) (* 0.5 (/ a b))) a)) (* a 3.0)))
double code(double a, double b, double c) {
return (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (1.0d0 / ((((-0.6666666666666666d0) * (b / c)) + (0.5d0 * (a / b))) / a)) / (a * 3.0d0)
end function
public static double code(double a, double b, double c) {
return (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0);
}
def code(a, b, c): return (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0)
function code(a, b, c) return Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / c)) + Float64(0.5 * Float64(a / b))) / a)) / Float64(a * 3.0)) end
function tmp = code(a, b, c) tmp = (1.0 / (((-0.6666666666666666 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 3.0); end
code[a_, b_, c_] := N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{c} + 0.5 \cdot \frac{a}{b}}{a}}}{a \cdot 3}
\end{array}
Initial program 52.6%
neg-sub052.6%
sqr-neg52.6%
associate-+l-52.6%
sub0-neg52.6%
sub-neg52.6%
distribute-neg-in52.6%
remove-double-neg52.6%
sqr-neg52.6%
associate-*l*52.6%
Simplified52.6%
expm1-log1p-u52.6%
expm1-undefine49.3%
Applied egg-rr49.3%
expm1-define52.6%
*-commutative52.6%
Simplified52.6%
flip-+52.4%
pow252.4%
add-sqr-sqrt54.2%
pow254.2%
expm1-log1p-u54.3%
associate-*l*54.3%
pow254.3%
expm1-log1p-u54.3%
associate-*l*54.3%
Applied egg-rr54.3%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in a around 0 83.8%
Final simplification83.8%
(FPCore (a b c) :precision binary64 (/ (/ 1.0 (/ (+ (* -0.6666666666666666 (/ b a)) (* 0.5 (/ c b))) c)) (* a 3.0)))
double code(double a, double b, double c) {
return (1.0 / (((-0.6666666666666666 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 3.0);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (1.0d0 / ((((-0.6666666666666666d0) * (b / a)) + (0.5d0 * (c / b))) / c)) / (a * 3.0d0)
end function
public static double code(double a, double b, double c) {
return (1.0 / (((-0.6666666666666666 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 3.0);
}
def code(a, b, c): return (1.0 / (((-0.6666666666666666 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 3.0)
function code(a, b, c) return Float64(Float64(1.0 / Float64(Float64(Float64(-0.6666666666666666 * Float64(b / a)) + Float64(0.5 * Float64(c / b))) / c)) / Float64(a * 3.0)) end
function tmp = code(a, b, c) tmp = (1.0 / (((-0.6666666666666666 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 3.0); end
code[a_, b_, c_] := N[(N[(1.0 / N[(N[(N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\frac{-0.6666666666666666 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}}{c}}}{a \cdot 3}
\end{array}
Initial program 52.6%
neg-sub052.6%
sqr-neg52.6%
associate-+l-52.6%
sub0-neg52.6%
sub-neg52.6%
distribute-neg-in52.6%
remove-double-neg52.6%
sqr-neg52.6%
associate-*l*52.6%
Simplified52.6%
expm1-log1p-u52.6%
expm1-undefine49.3%
Applied egg-rr49.3%
expm1-define52.6%
*-commutative52.6%
Simplified52.6%
flip-+52.4%
pow252.4%
add-sqr-sqrt54.2%
pow254.2%
expm1-log1p-u54.3%
associate-*l*54.3%
pow254.3%
expm1-log1p-u54.3%
associate-*l*54.3%
Applied egg-rr54.3%
associate--r-99.1%
Simplified99.1%
clear-num99.1%
inv-pow99.1%
+-commutative99.1%
fma-define99.1%
neg-mul-199.1%
unpow-prod-down99.1%
metadata-eval99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
unpow-199.1%
associate-*r*99.1%
*-commutative99.1%
sub-neg99.1%
+-commutative99.1%
distribute-lft-neg-in99.1%
metadata-eval99.1%
fma-define99.1%
*-commutative99.1%
+-inverses99.1%
Simplified99.1%
Taylor expanded in c around 0 83.8%
Final simplification83.8%
(FPCore (a b c) :precision binary64 (/ (* c -0.5) b))
double code(double a, double b, double c) {
return (c * -0.5) / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c * (-0.5d0)) / b
end function
public static double code(double a, double b, double c) {
return (c * -0.5) / b;
}
def code(a, b, c): return (c * -0.5) / b
function code(a, b, c) return Float64(Float64(c * -0.5) / b) end
function tmp = code(a, b, c) tmp = (c * -0.5) / b; end
code[a_, b_, c_] := N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot -0.5}{b}
\end{array}
Initial program 52.6%
neg-sub052.6%
sqr-neg52.6%
associate-+l-52.6%
sub0-neg52.6%
sub-neg52.6%
distribute-neg-in52.6%
remove-double-neg52.6%
sqr-neg52.6%
associate-*l*52.6%
Simplified52.6%
Taylor expanded in b around inf 66.4%
associate-*r/66.4%
*-commutative66.4%
Simplified66.4%
(FPCore (a b c) :precision binary64 (* c (/ -0.5 b)))
double code(double a, double b, double c) {
return c * (-0.5 / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c * ((-0.5d0) / b)
end function
public static double code(double a, double b, double c) {
return c * (-0.5 / b);
}
def code(a, b, c): return c * (-0.5 / b)
function code(a, b, c) return Float64(c * Float64(-0.5 / b)) end
function tmp = code(a, b, c) tmp = c * (-0.5 / b); end
code[a_, b_, c_] := N[(c * N[(-0.5 / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \frac{-0.5}{b}
\end{array}
Initial program 52.6%
neg-sub052.6%
sqr-neg52.6%
associate-+l-52.6%
sub0-neg52.6%
sub-neg52.6%
distribute-neg-in52.6%
remove-double-neg52.6%
sqr-neg52.6%
associate-*l*52.6%
Simplified52.6%
expm1-log1p-u52.6%
expm1-undefine49.3%
Applied egg-rr49.3%
expm1-define52.6%
*-commutative52.6%
Simplified52.6%
div-inv52.6%
neg-mul-152.6%
fma-define52.6%
pow252.6%
expm1-log1p-u52.6%
associate-*l*52.6%
*-commutative52.6%
Applied egg-rr52.6%
fma-undefine52.6%
*-commutative52.6%
fma-define52.6%
unpow252.6%
fma-neg52.6%
associate-*r*52.6%
distribute-rgt-neg-in52.6%
metadata-eval52.6%
*-commutative52.6%
associate-/r*52.5%
metadata-eval52.5%
Simplified52.5%
Taylor expanded in a around 0 66.3%
Taylor expanded in c around inf 66.3%
distribute-rgt1-in66.3%
metadata-eval66.3%
mul0-lft66.3%
div066.3%
metadata-eval66.3%
neg-sub066.3%
associate-*r/66.3%
metadata-eval66.3%
distribute-neg-frac66.3%
metadata-eval66.3%
Simplified66.3%
(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 52.6%
neg-sub052.6%
sqr-neg52.6%
associate-+l-52.6%
sub0-neg52.6%
sub-neg52.6%
distribute-neg-in52.6%
remove-double-neg52.6%
sqr-neg52.6%
associate-*l*52.6%
Simplified52.6%
expm1-log1p-u52.6%
expm1-undefine49.3%
Applied egg-rr49.3%
expm1-define52.6%
*-commutative52.6%
Simplified52.6%
div-inv52.6%
neg-mul-152.6%
fma-define52.6%
pow252.6%
expm1-log1p-u52.6%
associate-*l*52.6%
*-commutative52.6%
Applied egg-rr52.6%
fma-undefine52.6%
*-commutative52.6%
fma-define52.6%
unpow252.6%
fma-neg52.6%
associate-*r*52.6%
distribute-rgt-neg-in52.6%
metadata-eval52.6%
*-commutative52.6%
associate-/r*52.5%
metadata-eval52.5%
Simplified52.5%
Taylor expanded in a around 0 66.3%
Taylor expanded in a around 0 3.2%
distribute-rgt1-in3.2%
metadata-eval3.2%
mul0-lft3.2%
metadata-eval3.2%
rem-square-sqrt0.0%
unpow20.0%
associate-*r/0.0%
unpow20.0%
rem-square-sqrt3.2%
metadata-eval3.2%
metadata-eval3.2%
div03.2%
Simplified3.2%
herbie shell --seed 2024108
(FPCore (a b c)
:name "Cubic critical, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))