?

Average Error: 3.6 → 0
Time: 10.7s
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(b + \left(\left(a + d\right) + c\right)\right) \cdot 2 \]
(FPCore (a b c d) :precision binary64 (* (+ a (+ b (+ c d))) 2.0))
(FPCore (a b c d) :precision binary64 (* (+ b (+ (+ a d) c)) 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 (b + ((a + d) + c)) * 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 = (b + ((a + d) + c)) * 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 (b + ((a + d) + c)) * 2.0;
}
def code(a, b, c, d):
	return (a + (b + (c + d))) * 2.0
def code(a, b, c, d):
	return (b + ((a + d) + c)) * 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(b + Float64(Float64(a + d) + c)) * 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 = (b + ((a + d) + c)) * 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[(b + N[(N[(a + d), $MachinePrecision] + c), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
\left(b + \left(\left(a + d\right) + c\right)\right) \cdot 2

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.6
Target3.8
Herbie0
\[\left(a + b\right) \cdot 2 + \left(c + d\right) \cdot 2 \]

Derivation?

  1. Initial program 3.6

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
  2. Applied egg-rr4.3

    \[\leadsto \color{blue}{\left(\frac{b}{\frac{b - \left(c + d\right)}{b}} - \left(\frac{{\left(c + d\right)}^{2}}{b - \left(c + d\right)} - a\right)\right)} \cdot 2 \]
  3. Taylor expanded in b around 0 3.8

    \[\leadsto \color{blue}{\left(\left(a + b\right) - -1 \cdot \left(c + d\right)\right)} \cdot 2 \]
  4. Simplified3.5

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

    [Start]3.8

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

    +-commutative [=>]3.8

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

    associate--l+ [=>]3.5

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

    mul-1-neg [=>]3.5

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

    +-commutative [=>]3.5

    \[ \left(b + \left(a - \left(-\color{blue}{\left(d + c\right)}\right)\right)\right) \cdot 2 \]
  5. Applied egg-rr0

    \[\leadsto \left(b + \color{blue}{\left(\left(a + d\right) + c\right)}\right) \cdot 2 \]
  6. Final simplification0

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

Alternatives

Alternative 1
Error3.6
Cost576
\[2 \cdot \left(a + \left(b + \left(d + c\right)\right)\right) \]
Alternative 2
Error55.0
Cost320
\[2 \cdot \left(b + c\right) \]
Alternative 3
Error60.1
Cost192
\[b \cdot 2 \]
Alternative 4
Error56.5
Cost192
\[c \cdot 2 \]

Error

Reproduce?

herbie shell --seed 2023083 
(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))