Average Error: 39.5 → 0.0
Time: 15.0s
Precision: 64
Internal Precision: 128
\[\left(x + 1\right) \cdot \left(x + 1\right) - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -11765340288333386.0 \lor \neg \left(x \le 5.463305768775051 \cdot 10^{+16}\right):\\ \;\;\;\;\sqrt{\left(2 + x\right) \cdot x} \cdot \sqrt{\left(2 + x\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(2 + x\right) \cdot x + -4\right) \cdot \frac{8 \cdot x + {x}^{4}}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(4 - 2 \cdot x\right) \cdot \left(4 - 2 \cdot x\right)}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -11765340288333386.0 or 5.463305768775051e+16 < x

    1. Initial program 0.0

      \[\left(x + 1\right) \cdot \left(x + 1\right) - 1\]
    2. Simplified0.0

      \[\leadsto \color{blue}{\left(x + 2\right) \cdot x}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt0.0

      \[\leadsto \color{blue}{\sqrt{\left(x + 2\right) \cdot x} \cdot \sqrt{\left(x + 2\right) \cdot x}}\]

    if -11765340288333386.0 < x < 5.463305768775051e+16

    1. Initial program 56.0

      \[\left(x + 1\right) \cdot \left(x + 1\right) - 1\]
    2. Simplified0.0

      \[\leadsto \color{blue}{\left(x + 2\right) \cdot x}\]
    3. Using strategy rm
    4. Applied flip3-+0.0

      \[\leadsto \color{blue}{\frac{{x}^{3} + {2}^{3}}{x \cdot x + \left(2 \cdot 2 - x \cdot 2\right)}} \cdot x\]
    5. Applied associate-*l/0.0

      \[\leadsto \color{blue}{\frac{\left({x}^{3} + {2}^{3}\right) \cdot x}{x \cdot x + \left(2 \cdot 2 - x \cdot 2\right)}}\]
    6. Simplified0.0

      \[\leadsto \frac{\color{blue}{{x}^{4} + 8 \cdot x}}{x \cdot x + \left(2 \cdot 2 - x \cdot 2\right)}\]
    7. Using strategy rm
    8. Applied flip-+0.0

      \[\leadsto \frac{{x}^{4} + 8 \cdot x}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(2 \cdot 2 - x \cdot 2\right) \cdot \left(2 \cdot 2 - x \cdot 2\right)}{x \cdot x - \left(2 \cdot 2 - x \cdot 2\right)}}}\]
    9. Applied associate-/r/0.0

      \[\leadsto \color{blue}{\frac{{x}^{4} + 8 \cdot x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(2 \cdot 2 - x \cdot 2\right) \cdot \left(2 \cdot 2 - x \cdot 2\right)} \cdot \left(x \cdot x - \left(2 \cdot 2 - x \cdot 2\right)\right)}\]
    10. Simplified0.1

      \[\leadsto \frac{{x}^{4} + 8 \cdot x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(2 \cdot 2 - x \cdot 2\right) \cdot \left(2 \cdot 2 - x \cdot 2\right)} \cdot \color{blue}{\left(\left(x + 2\right) \cdot x + -4\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -11765340288333386.0 \lor \neg \left(x \le 5.463305768775051 \cdot 10^{+16}\right):\\ \;\;\;\;\sqrt{\left(2 + x\right) \cdot x} \cdot \sqrt{\left(2 + x\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(2 + x\right) \cdot x + -4\right) \cdot \frac{8 \cdot x + {x}^{4}}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(4 - 2 \cdot x\right) \cdot \left(4 - 2 \cdot x\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019010 
(FPCore (x)
  :name "Expanding a square"
  (- (* (+ x 1) (+ x 1)) 1))

Details

Time bar (total: 14.7s)Debug log

sample103.0ms

Algorithm
intervals

simplify157.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
157.0ms
(- (* (+ x 1) (+ x 1)) 1)

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 0.0b

localize7.0ms

Local error

Found 1 expressions with local error:

0.0b
(* (+ x 2) x)

rewrite5.0ms

Algorithm
rewrite-expression-head
Rules
associate-*l*
add-cube-cbrt
associate-*l/
*-un-lft-identity
add-sqr-sqrt
add-log-exp
flip-+
*-commutative
add-exp-log
add-cbrt-cube
flip3-+
pow1
Counts
1 → 13
Calls
1 calls:
Slowest
4.0ms
(* (+ x 2) x)

series26.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
26.0ms
(* (+ x 2) x)

simplify188.0ms

Counts
7 → 16
Calls
7 calls:
Slowest
153.0ms
(* (- (* x x) (* 2 2)) x)
15.0ms
(* (+ (pow x 3) (pow 2 3)) x)
6.0ms
(+ (* 2 x) (pow x 2))
6.0ms
(+ (* 2 x) (pow x 2))
5.0ms
(+ (* 2 x) (pow x 2))

prune63.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 2 expressions with local error:

9.6b
(/ (+ (pow x 4) (* 8 x)) (+ (* x x) (- (* 2 2) (* x 2))))
0.0b
(+ (* x x) (- (* 2 2) (* x 2)))

rewrite21.0ms

Algorithm
rewrite-expression-head
Rules
10×add-cube-cbrt
10×*-un-lft-identity
10×add-sqr-sqrt
times-frac
add-log-exp
add-exp-log
add-cbrt-cube
associate-/l*
flip-+
flip3-+
associate-/r*
associate-/l/
associate-/r/
sum-log
associate-+r+
pow1
div-inv
div-exp
diff-log
frac-2neg
sub-neg
associate-+r-
clear-num
+-commutative
cbrt-undiv
Counts
2 → 46
Calls
2 calls:
Slowest
16.0ms
(/ (+ (pow x 4) (* 8 x)) (+ (* x x) (- (* 2 2) (* x 2))))
4.0ms
(+ (* x x) (- (* 2 2) (* x 2)))

series67.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
58.0ms
(/ (+ (pow x 4) (* 8 x)) (+ (* x x) (- (* 2 2) (* x 2))))
9.0ms
(+ (* x x) (- (* 2 2) (* x 2)))

simplify1.7s

Counts
40 → 52
Calls
40 calls:
Slowest
200.0ms
(+ (* (* x x) (* x x)) (- (* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2))) (* (* x x) (- (* 2 2) (* x 2)))))
126.0ms
(- (* (pow x 4) (pow x 4)) (* (* 8 x) (* 8 x)))
121.0ms
(/ (* (* (+ (pow x 4) (* 8 x)) (+ (pow x 4) (* 8 x))) (+ (pow x 4) (* 8 x))) (* (* (+ (* x x) (- (* 2 2) (* x 2))) (+ (* x x) (- (* 2 2) (* x 2)))) (+ (* x x) (- (* 2 2) (* x 2)))))
117.0ms
(* (exp (* x x)) (/ (exp (* 2 2)) (exp (* x 2))))
88.0ms
(* (exp (* x x)) (exp (- (* 2 2) (* x 2))))

prune316.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize15.0ms

Local error

Found 4 expressions with local error:

9.9b
(/ (+ (pow x 4) (* 8 x)) (- (* (* x x) (* x x)) (* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2)))))
0.1b
(* (* x x) (* x x))
0.0b
(* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2)))
0.0b
(* (+ x 2) x)

rewrite31.0ms

Algorithm
rewrite-expression-head
Rules
16×add-cube-cbrt
16×*-un-lft-identity
16×add-sqr-sqrt
14×pow1
12×times-frac
10×add-exp-log
10×add-cbrt-cube
associate-*l*
flip--
flip3--
pow2
associate-*r*
difference-of-squares
add-log-exp
associate-*l/
associate-/r*
frac-times
associate-/l*
pow-prod-up
*-commutative
pow-prod-down
associate-/l/
flip-+
cbrt-unprod
associate-/r/
associate-*r/
prod-exp
distribute-rgt-out--
pow-plus
flip3-+
distribute-lft-in
sub-neg
distribute-rgt-in
div-inv
div-exp
frac-2neg
clear-num
cbrt-undiv
Counts
4 → 100
Calls
4 calls:
Slowest
16.0ms
(/ (+ (pow x 4) (* 8 x)) (- (* (* x x) (* x x)) (* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2)))))
8.0ms
(* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2)))
3.0ms
(* (* x x) (* x x))
2.0ms
(* (+ x 2) x)

series68.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
27.0ms
(/ (+ (pow x 4) (* 8 x)) (- (* (* x x) (* x x)) (* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2)))))
19.0ms
(* (+ x 2) x)
13.0ms
(* (* x x) (* x x))
8.0ms
(* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2)))

simplify7.3s

Counts
88 → 112
Calls
88 calls:
Slowest
486.0ms
(* (* (* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2))) (- (* 2 2) (* x 2))) (* (* (- (* 2 2) (* x 2)) (- (* 2 2) (* x 2))) (- (* 2 2) (* x 2))))
351.0ms
(* (- (* 2 2) (* x 2)) (- (* x 2)))
350.0ms
(* (- (* 2 2) (* x 2)) (- (* x 2)))
317.0ms
(* (+ (* 2 2) (* x 2)) (+ (* (* 2 2) (* 2 2)) (+ (* (* x 2) (* x 2)) (* (* 2 2) (* x 2)))))
287.0ms
(* (- (* (* 2 2) (* 2 2)) (* (* x 2) (* x 2))) (- (* 2 2) (* x 2)))

prune900.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize8.0ms

Local error

Found 4 expressions with local error:

0.2b
(* (sqrt (* (+ x 2) x)) (sqrt (* (+ x 2) x)))
0.0b
(* (+ x 2) x)
0.0b
(* (+ x 2) x)
0.0b
(sqrt (* (+ x 2) x))

rewrite15.0ms

Algorithm
rewrite-expression-head
Rules
20×associate-*l/
14×sqrt-div
10×associate-*l*
flip-+
flip3-+
pow1
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
pow1/2
add-log-exp
associate-*r*
frac-times
sqrt-prod
*-commutative
pow-prod-up
associate-*r/
pow-prod-down
cbrt-unprod
prod-exp
sqrt-unprod
pow-plus
rem-square-sqrt
pow2
Counts
4 → 71
Calls
4 calls:
Slowest
9.0ms
(* (sqrt (* (+ x 2) x)) (sqrt (* (+ x 2) x)))
2.0ms
(* (+ x 2) x)
2.0ms
(* (+ x 2) x)
1.0ms
(sqrt (* (+ x 2) x))

series73.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
24.0ms
(* (sqrt (* (+ x 2) x)) (sqrt (* (+ x 2) x)))
17.0ms
(* (+ x 2) x)
17.0ms
(* (+ x 2) x)
15.0ms
(sqrt (* (+ x 2) x))

simplify1.9s

Counts
53 → 83
Calls
53 calls:
Slowest
176.0ms
(* (sqrt (* (+ (pow x 3) (pow 2 3)) x)) (sqrt (* (- (* x x) (* 2 2)) x)))
169.0ms
(sqrt (* (- (* x x) (* 2 2)) x))
157.0ms
(* (sqrt (* (- (* x x) (* 2 2)) x)) (sqrt (* (+ (pow x 3) (pow 2 3)) x)))
154.0ms
(* (sqrt (* (- (* x x) (* 2 2)) x)) (sqrt (* (- (* x x) (* 2 2)) x)))
146.0ms
(* (- (* x x) (* 2 2)) x)

prune613.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes31.0ms

Accuracy

99.7% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 9.7b

bsearch73.0ms

end0.0ms

sample1.0s

Algorithm
intervals