?

Average Accuracy: 94.3% → 100.0%
Time: 17.6s
Precision: binary64
Cost: 576

?

\[\left(\left(\left(-14 \leq a \land a \leq -13\right) \land \left(-3 \leq b \land b \leq -2\right)\right) \land \left(3 \leq c \land c \leq 3.5\right)\right) \land \left(12.5 \leq d \land d \leq 13.5\right)\]
\[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
\[\left(\left(d + a\right) + \left(c + b\right)\right) \cdot 2 \]
(FPCore (a b c d) :precision binary64 (* (+ a (+ b (+ c d))) 2.0))
(FPCore (a b c d) :precision binary64 (* (+ (+ d a) (+ c b)) 2.0))
double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
double code(double a, double b, double c, double d) {
	return ((d + a) + (c + b)) * 2.0;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = (a + (b + (c + d))) * 2.0d0
end function
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((d + a) + (c + b)) * 2.0d0
end function
public static double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
public static double code(double a, double b, double c, double d) {
	return ((d + a) + (c + b)) * 2.0;
}
def code(a, b, c, d):
	return (a + (b + (c + d))) * 2.0
def code(a, b, c, d):
	return ((d + a) + (c + b)) * 2.0
function code(a, b, c, d)
	return Float64(Float64(a + Float64(b + Float64(c + d))) * 2.0)
end
function code(a, b, c, d)
	return Float64(Float64(Float64(d + a) + Float64(c + b)) * 2.0)
end
function tmp = code(a, b, c, d)
	tmp = (a + (b + (c + d))) * 2.0;
end
function tmp = code(a, b, c, d)
	tmp = ((d + a) + (c + b)) * 2.0;
end
code[a_, b_, c_, d_] := N[(N[(a + N[(b + N[(c + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
code[a_, b_, c_, d_] := N[(N[(N[(d + a), $MachinePrecision] + N[(c + b), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
\left(\left(d + a\right) + \left(c + b\right)\right) \cdot 2

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original94.3%
Target94.1%
Herbie100.0%
\[\left(a + b\right) \cdot 2 + \left(c + d\right) \cdot 2 \]

Derivation?

  1. Initial program 94.3%

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
  2. Applied egg-rr93.8%

    \[\leadsto \color{blue}{\frac{{\left(b + \left(c + d\right)\right)}^{2} - a \cdot a}{b + \left(\left(c + d\right) - a\right)}} \cdot 2 \]
    Proof

    [Start]94.3

    \[ \left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]

    +-commutative [=>]94.3

    \[ \color{blue}{\left(\left(b + \left(c + d\right)\right) + a\right)} \cdot 2 \]

    flip-+ [=>]93.8

    \[ \color{blue}{\frac{\left(b + \left(c + d\right)\right) \cdot \left(b + \left(c + d\right)\right) - a \cdot a}{\left(b + \left(c + d\right)\right) - a}} \cdot 2 \]

    pow2 [=>]93.8

    \[ \frac{\color{blue}{{\left(b + \left(c + d\right)\right)}^{2}} - a \cdot a}{\left(b + \left(c + d\right)\right) - a} \cdot 2 \]

    associate--l+ [=>]93.8

    \[ \frac{{\left(b + \left(c + d\right)\right)}^{2} - a \cdot a}{\color{blue}{b + \left(\left(c + d\right) - a\right)}} \cdot 2 \]
  3. Applied egg-rr94.4%

    \[\leadsto \frac{\color{blue}{\left(b + \left(\left(c + d\right) + a\right)\right) \cdot \left(\left(c + d\right) + \left(b - a\right)\right)}}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]
    Proof

    [Start]93.8

    \[ \frac{{\left(b + \left(c + d\right)\right)}^{2} - a \cdot a}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]

    unpow2 [=>]93.8

    \[ \frac{\color{blue}{\left(b + \left(c + d\right)\right) \cdot \left(b + \left(c + d\right)\right)} - a \cdot a}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]

    difference-of-squares [=>]94.3

    \[ \frac{\color{blue}{\left(\left(b + \left(c + d\right)\right) + a\right) \cdot \left(\left(b + \left(c + d\right)\right) - a\right)}}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]

    associate-+l+ [=>]94.4

    \[ \frac{\color{blue}{\left(b + \left(\left(c + d\right) + a\right)\right)} \cdot \left(\left(b + \left(c + d\right)\right) - a\right)}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]

    +-commutative [=>]94.4

    \[ \frac{\left(b + \left(\left(c + d\right) + a\right)\right) \cdot \left(\color{blue}{\left(\left(c + d\right) + b\right)} - a\right)}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]

    associate--l+ [=>]94.4

    \[ \frac{\left(b + \left(\left(c + d\right) + a\right)\right) \cdot \color{blue}{\left(\left(c + d\right) + \left(b - a\right)\right)}}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]
  4. Simplified99.3%

    \[\leadsto \frac{\color{blue}{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \left(c + \left(d + \left(b - a\right)\right)\right)}}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]
    Proof

    [Start]94.4

    \[ \frac{\left(b + \left(\left(c + d\right) + a\right)\right) \cdot \left(\left(c + d\right) + \left(b - a\right)\right)}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]

    associate-+l+ [=>]99.5

    \[ \frac{\left(b + \color{blue}{\left(c + \left(d + a\right)\right)}\right) \cdot \left(\left(c + d\right) + \left(b - a\right)\right)}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]

    associate-+l+ [=>]99.3

    \[ \frac{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \color{blue}{\left(c + \left(d + \left(b - a\right)\right)\right)}}{b + \left(\left(c + d\right) - a\right)} \cdot 2 \]
  5. Taylor expanded in b around 0 99.4%

    \[\leadsto \frac{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \left(c + \left(d + \left(b - a\right)\right)\right)}{\color{blue}{\left(c + \left(d + b\right)\right) - a}} \cdot 2 \]
  6. Simplified99.8%

    \[\leadsto \frac{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \left(c + \left(d + \left(b - a\right)\right)\right)}{\color{blue}{c + \left(d + \left(b - a\right)\right)}} \cdot 2 \]
    Proof

    [Start]99.4

    \[ \frac{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \left(c + \left(d + \left(b - a\right)\right)\right)}{\left(c + \left(d + b\right)\right) - a} \cdot 2 \]

    associate-+r+ [=>]99.4

    \[ \frac{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \left(c + \left(d + \left(b - a\right)\right)\right)}{\color{blue}{\left(\left(c + d\right) + b\right)} - a} \cdot 2 \]

    associate-+r- [<=]99.4

    \[ \frac{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \left(c + \left(d + \left(b - a\right)\right)\right)}{\color{blue}{\left(c + d\right) + \left(b - a\right)}} \cdot 2 \]

    associate-+r+ [<=]99.8

    \[ \frac{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \left(c + \left(d + \left(b - a\right)\right)\right)}{\color{blue}{c + \left(d + \left(b - a\right)\right)}} \cdot 2 \]
  7. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(\left(d + a\right) + \left(c + b\right)\right)} \cdot 2 \]
    Proof

    [Start]99.8

    \[ \frac{\left(b + \left(c + \left(d + a\right)\right)\right) \cdot \left(c + \left(d + \left(b - a\right)\right)\right)}{c + \left(d + \left(b - a\right)\right)} \cdot 2 \]

    associate-/l* [=>]100.0

    \[ \color{blue}{\frac{b + \left(c + \left(d + a\right)\right)}{\frac{c + \left(d + \left(b - a\right)\right)}{c + \left(d + \left(b - a\right)\right)}}} \cdot 2 \]

    flip3-+ [=>]98.3

    \[ \frac{\color{blue}{\frac{{b}^{3} + {\left(c + \left(d + a\right)\right)}^{3}}{b \cdot b + \left(\left(c + \left(d + a\right)\right) \cdot \left(c + \left(d + a\right)\right) - b \cdot \left(c + \left(d + a\right)\right)\right)}}}{\frac{c + \left(d + \left(b - a\right)\right)}{c + \left(d + \left(b - a\right)\right)}} \cdot 2 \]

    associate-/l/ [=>]98.3

    \[ \color{blue}{\frac{{b}^{3} + {\left(c + \left(d + a\right)\right)}^{3}}{\frac{c + \left(d + \left(b - a\right)\right)}{c + \left(d + \left(b - a\right)\right)} \cdot \left(b \cdot b + \left(\left(c + \left(d + a\right)\right) \cdot \left(c + \left(d + a\right)\right) - b \cdot \left(c + \left(d + a\right)\right)\right)\right)}} \cdot 2 \]

    *-inverses [=>]98.3

    \[ \frac{{b}^{3} + {\left(c + \left(d + a\right)\right)}^{3}}{\color{blue}{1} \cdot \left(b \cdot b + \left(\left(c + \left(d + a\right)\right) \cdot \left(c + \left(d + a\right)\right) - b \cdot \left(c + \left(d + a\right)\right)\right)\right)} \cdot 2 \]

    *-un-lft-identity [<=]98.3

    \[ \frac{{b}^{3} + {\left(c + \left(d + a\right)\right)}^{3}}{\color{blue}{b \cdot b + \left(\left(c + \left(d + a\right)\right) \cdot \left(c + \left(d + a\right)\right) - b \cdot \left(c + \left(d + a\right)\right)\right)}} \cdot 2 \]

    flip3-+ [<=]100.0

    \[ \color{blue}{\left(b + \left(c + \left(d + a\right)\right)\right)} \cdot 2 \]

    associate-+r+ [=>]100.0

    \[ \color{blue}{\left(\left(b + c\right) + \left(d + a\right)\right)} \cdot 2 \]

    +-commutative [=>]100.0

    \[ \color{blue}{\left(\left(d + a\right) + \left(b + c\right)\right)} \cdot 2 \]

    +-commutative [=>]100.0

    \[ \left(\left(d + a\right) + \color{blue}{\left(c + b\right)}\right) \cdot 2 \]
  8. Final simplification100.0%

    \[\leadsto \left(\left(d + a\right) + \left(c + b\right)\right) \cdot 2 \]

Alternatives

Alternative 1
Accuracy13.9%
Cost708
\[\begin{array}{l} \mathbf{if}\;d + c \leq 16:\\ \;\;\;\;2 \cdot \left(\left(c + b\right) + -1\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(c + -1\right)\\ \end{array} \]
Alternative 2
Accuracy94.3%
Cost576
\[2 \cdot \left(a + \left(b + \left(d + c\right)\right)\right) \]
Alternative 3
Accuracy95.7%
Cost576
\[2 \cdot \left(c + \left(a + \left(d + b\right)\right)\right) \]
Alternative 4
Accuracy12.0%
Cost320
\[2 \cdot \left(c + -1\right) \]
Alternative 5
Accuracy6.2%
Cost192
\[b \cdot 2 \]
Alternative 6
Accuracy11.7%
Cost192
\[c \cdot 2 \]

Error

Reproduce?

herbie shell --seed 2023138 
(FPCore (a b c d)
  :name "Expression, p6"
  :precision binary64
  :pre (and (and (and (and (<= -14.0 a) (<= a -13.0)) (and (<= -3.0 b) (<= b -2.0))) (and (<= 3.0 c) (<= c 3.5))) (and (<= 12.5 d) (<= d 13.5)))

  :herbie-target
  (+ (* (+ a b) 2.0) (* (+ c d) 2.0))

  (* (+ a (+ b (+ c d))) 2.0))