2cbrt (problem 3.3.4)

?

Percentage Accurate: 52.7% → 99.6%
Time: 12.2s
Precision: binary64
Cost: 52928

?

\[\sqrt[3]{x + 1} - \sqrt[3]{x} \]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ t_1 := {t_0}^{2}\\ \frac{1}{t_1 + \frac{\sqrt[3]{x}}{\frac{t_1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - t_0\right)}{x + \left(1 + x\right)}}} \end{array} \end{array} \]
(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (pow t_0 2.0)))
   (/
    1.0
    (+
     t_1
     (/ (cbrt x) (/ (+ t_1 (* (cbrt x) (- (cbrt x) t_0))) (+ x (+ 1.0 x))))))))
double code(double x) {
	return cbrt((x + 1.0)) - cbrt(x);
}
double code(double x) {
	double t_0 = cbrt((1.0 + x));
	double t_1 = pow(t_0, 2.0);
	return 1.0 / (t_1 + (cbrt(x) / ((t_1 + (cbrt(x) * (cbrt(x) - t_0))) / (x + (1.0 + x)))));
}
public static double code(double x) {
	return Math.cbrt((x + 1.0)) - Math.cbrt(x);
}
public static double code(double x) {
	double t_0 = Math.cbrt((1.0 + x));
	double t_1 = Math.pow(t_0, 2.0);
	return 1.0 / (t_1 + (Math.cbrt(x) / ((t_1 + (Math.cbrt(x) * (Math.cbrt(x) - t_0))) / (x + (1.0 + x)))));
}
function code(x)
	return Float64(cbrt(Float64(x + 1.0)) - cbrt(x))
end
function code(x)
	t_0 = cbrt(Float64(1.0 + x))
	t_1 = t_0 ^ 2.0
	return Float64(1.0 / Float64(t_1 + Float64(cbrt(x) / Float64(Float64(t_1 + Float64(cbrt(x) * Float64(cbrt(x) - t_0))) / Float64(x + Float64(1.0 + x))))))
end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, N[(1.0 / N[(t$95$1 + N[(N[Power[x, 1/3], $MachinePrecision] / N[(N[(t$95$1 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\sqrt[3]{x + 1} - \sqrt[3]{x}
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := {t_0}^{2}\\
\frac{1}{t_1 + \frac{\sqrt[3]{x}}{\frac{t_1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - t_0\right)}{x + \left(1 + x\right)}}}
\end{array}
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 12 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 54.8%

    \[\sqrt[3]{x + 1} - \sqrt[3]{x} \]
  2. Applied egg-rr56.1%

    \[\leadsto \color{blue}{\left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)}} \]
    Step-by-step derivation

    [Start]54.8%

    \[ \sqrt[3]{x + 1} - \sqrt[3]{x} \]

    flip3-- [=>]54.8%

    \[ \color{blue}{\frac{{\left(\sqrt[3]{x + 1}\right)}^{3} - {\left(\sqrt[3]{x}\right)}^{3}}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x} + \sqrt[3]{x + 1} \cdot \sqrt[3]{x}\right)}} \]

    div-inv [=>]54.8%

    \[ \color{blue}{\left({\left(\sqrt[3]{x + 1}\right)}^{3} - {\left(\sqrt[3]{x}\right)}^{3}\right) \cdot \frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x} + \sqrt[3]{x + 1} \cdot \sqrt[3]{x}\right)}} \]

    rem-cube-cbrt [=>]54.8%

    \[ \left(\color{blue}{\left(x + 1\right)} - {\left(\sqrt[3]{x}\right)}^{3}\right) \cdot \frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x} + \sqrt[3]{x + 1} \cdot \sqrt[3]{x}\right)} \]

    rem-cube-cbrt [=>]56.1%

    \[ \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x} + \sqrt[3]{x + 1} \cdot \sqrt[3]{x}\right)} \]

    cbrt-unprod [=>]56.1%

    \[ \left(\left(x + 1\right) - x\right) \cdot \frac{1}{\color{blue}{\sqrt[3]{\left(x + 1\right) \cdot \left(x + 1\right)}} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x} + \sqrt[3]{x + 1} \cdot \sqrt[3]{x}\right)} \]

    pow2 [=>]56.1%

    \[ \left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt[3]{\color{blue}{{\left(x + 1\right)}^{2}}} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x} + \sqrt[3]{x + 1} \cdot \sqrt[3]{x}\right)} \]

    distribute-rgt-out [=>]56.1%

    \[ \left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \color{blue}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{x + 1}\right)}} \]

    +-commutative [<=]56.1%

    \[ \left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \color{blue}{\left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)}} \]
  3. Simplified75.8%

    \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)}} \]
    Step-by-step derivation

    [Start]56.1%

    \[ \left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)} \]

    associate-*r/ [=>]56.1%

    \[ \color{blue}{\frac{\left(\left(x + 1\right) - x\right) \cdot 1}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)}} \]

    *-rgt-identity [=>]56.1%

    \[ \frac{\color{blue}{\left(x + 1\right) - x}}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)} \]

    +-commutative [=>]56.1%

    \[ \frac{\color{blue}{\left(1 + x\right)} - x}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)} \]

    associate--l+ [=>]75.8%

    \[ \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)} \]

    +-inverses [=>]75.8%

    \[ \frac{1 + \color{blue}{0}}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)} \]

    metadata-eval [=>]75.8%

    \[ \frac{\color{blue}{1}}{\sqrt[3]{{\left(x + 1\right)}^{2}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right)} \]

    +-commutative [=>]75.8%

    \[ \frac{1}{\color{blue}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x + 1} + \sqrt[3]{x}\right) + \sqrt[3]{{\left(x + 1\right)}^{2}}}} \]

    fma-def [=>]75.8%

    \[ \frac{1}{\color{blue}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x + 1} + \sqrt[3]{x}, \sqrt[3]{{\left(x + 1\right)}^{2}}\right)}} \]

    +-commutative [=>]75.8%

    \[ \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{\color{blue}{1 + x}} + \sqrt[3]{x}, \sqrt[3]{{\left(x + 1\right)}^{2}}\right)} \]

    +-commutative [=>]75.8%

    \[ \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, \sqrt[3]{{\color{blue}{\left(1 + x\right)}}^{2}}\right)} \]
  4. Applied egg-rr99.2%

    \[\leadsto \frac{1}{\color{blue}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)}} \]
    Step-by-step derivation

    [Start]75.8%

    \[ \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)} \]

    fma-udef [=>]75.8%

    \[ \frac{1}{\color{blue}{\sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right) + \sqrt[3]{{\left(1 + x\right)}^{2}}}} \]

    pow1/3 [=>]74.8%

    \[ \frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right) + \color{blue}{{\left({\left(1 + x\right)}^{2}\right)}^{0.3333333333333333}}} \]

    unpow2 [=>]74.8%

    \[ \frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right) + {\color{blue}{\left(\left(1 + x\right) \cdot \left(1 + x\right)\right)}}^{0.3333333333333333}} \]

    pow-prod-down [<=]74.4%

    \[ \frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right) + \color{blue}{{\left(1 + x\right)}^{0.3333333333333333} \cdot {\left(1 + x\right)}^{0.3333333333333333}}} \]

    +-commutative [<=]74.4%

    \[ \frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right) + {\color{blue}{\left(x + 1\right)}}^{0.3333333333333333} \cdot {\left(1 + x\right)}^{0.3333333333333333}} \]

    pow1/3 [<=]74.7%

    \[ \frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right) + \color{blue}{\sqrt[3]{x + 1}} \cdot {\left(1 + x\right)}^{0.3333333333333333}} \]

    +-commutative [<=]74.7%

    \[ \frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right) + \sqrt[3]{x + 1} \cdot {\color{blue}{\left(x + 1\right)}}^{0.3333333333333333}} \]

    pow1/3 [<=]99.2%

    \[ \frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right) + \sqrt[3]{x + 1} \cdot \color{blue}{\sqrt[3]{x + 1}}} \]

    +-commutative [=>]99.2%

    \[ \frac{1}{\color{blue}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1} + \sqrt[3]{x} \cdot \left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right)}} \]

    +-commutative [=>]99.2%

    \[ \frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1} + \sqrt[3]{x} \cdot \color{blue}{\left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)}} \]

    +-commutative [<=]99.2%

    \[ \frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{\color{blue}{x + 1}}\right)} \]

    distribute-rgt-in [=>]99.2%

    \[ \frac{1}{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1} + \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x} + \sqrt[3]{x + 1} \cdot \sqrt[3]{x}\right)}} \]

    fma-def [=>]99.2%

    \[ \frac{1}{\color{blue}{\mathsf{fma}\left(\sqrt[3]{x + 1}, \sqrt[3]{x + 1}, \sqrt[3]{x} \cdot \sqrt[3]{x} + \sqrt[3]{x + 1} \cdot \sqrt[3]{x}\right)}} \]
  5. Applied egg-rr89.0%

    \[\leadsto \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \color{blue}{\frac{\sqrt[3]{x} \cdot \left(x + \left(1 + x\right)\right)}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - \sqrt[3]{1 + x}\right)}}} \]
    Step-by-step derivation

    [Start]99.2%

    \[ \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)} \]

    +-commutative [=>]99.2%

    \[ \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \color{blue}{\left(\sqrt[3]{1 + x} + \sqrt[3]{x}\right)}} \]

    flip3-+ [=>]99.2%

    \[ \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \color{blue}{\frac{{\left(\sqrt[3]{1 + x}\right)}^{3} + {\left(\sqrt[3]{x}\right)}^{3}}{\sqrt[3]{1 + x} \cdot \sqrt[3]{1 + x} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x} - \sqrt[3]{1 + x} \cdot \sqrt[3]{x}\right)}}} \]

    associate-*r/ [=>]88.7%

    \[ \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \color{blue}{\frac{\sqrt[3]{x} \cdot \left({\left(\sqrt[3]{1 + x}\right)}^{3} + {\left(\sqrt[3]{x}\right)}^{3}\right)}{\sqrt[3]{1 + x} \cdot \sqrt[3]{1 + x} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x} - \sqrt[3]{1 + x} \cdot \sqrt[3]{x}\right)}}} \]
  6. Simplified99.7%

    \[\leadsto \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \color{blue}{\frac{\sqrt[3]{x}}{\frac{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - \sqrt[3]{1 + x}\right)}{x + \left(1 + x\right)}}}} \]
    Step-by-step derivation

    [Start]89.0%

    \[ \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \frac{\sqrt[3]{x} \cdot \left(x + \left(1 + x\right)\right)}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - \sqrt[3]{1 + x}\right)}} \]

    associate-/l* [=>]99.7%

    \[ \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \color{blue}{\frac{\sqrt[3]{x}}{\frac{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - \sqrt[3]{1 + x}\right)}{x + \left(1 + x\right)}}}} \]
  7. Final simplification99.7%

    \[\leadsto \frac{1}{{\left(\sqrt[3]{1 + x}\right)}^{2} + \frac{\sqrt[3]{x}}{\frac{{\left(\sqrt[3]{1 + x}\right)}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - \sqrt[3]{1 + x}\right)}{x + \left(1 + x\right)}}} \]

Alternatives

Alternative 1
Accuracy99.6%
Cost52928
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ t_1 := {t_0}^{2}\\ \frac{1}{t_1 + \frac{\sqrt[3]{x}}{\frac{t_1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} - t_0\right)}{x + \left(1 + x\right)}}} \end{array} \]
Alternative 2
Accuracy99.2%
Cost45956
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ t_1 := {t_0}^{2}\\ \mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\ \;\;\;\;\frac{1}{t_1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(t_1 + \sqrt[3]{x + x \cdot x}\right) + \sqrt[3]{x \cdot x}}\\ \end{array} \]
Alternative 3
Accuracy60.3%
Cost33092
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ t_1 := t_0 - \sqrt[3]{x}\\ \mathbf{if}\;t_1 \leq 0:\\ \;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy99.2%
Cost32896
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ \frac{1}{{t_0}^{2} + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)} \end{array} \]
Alternative 5
Accuracy79.1%
Cost26889
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{+154} \lor \neg \left(x \leq 1.35 \cdot 10^{+154}\right):\\ \;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left({t_0}^{2} + \sqrt[3]{x + x \cdot x}\right) + \sqrt[3]{x \cdot x}}\\ \end{array} \]
Alternative 6
Accuracy79.1%
Cost26889
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{+154} \lor \neg \left(x \leq 1.35 \cdot 10^{+154}\right):\\ \;\;\;\;\frac{1}{1 + \sqrt[3]{x} \cdot \left(t_0 + \sqrt[3]{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{t_0}^{2} + \left(\sqrt[3]{x \cdot x} + \sqrt[3]{x \cdot \left(1 + x\right)}\right)}\\ \end{array} \]
Alternative 7
Accuracy52.7%
Cost19520
\[\left|\sqrt[3]{x} - \sqrt[3]{1 + x}\right| \]
Alternative 8
Accuracy52.7%
Cost13120
\[\sqrt[3]{1 + x} - \sqrt[3]{x} \]
Alternative 9
Accuracy50.5%
Cost6848
\[1 + \left(x \cdot 0.3333333333333333 - \sqrt[3]{x}\right) \]
Alternative 10
Accuracy50.3%
Cost6592
\[1 - \sqrt[3]{x} \]
Alternative 11
Accuracy3.7%
Cost64
\[0 \]
Alternative 12
Accuracy49.5%
Cost64
\[1 \]

Reproduce?

herbie shell --seed 2023167 
(FPCore (x)
  :name "2cbrt (problem 3.3.4)"
  :precision binary64
  (- (cbrt (+ x 1.0)) (cbrt x)))