?

Average Accuracy: 99.9% → 99.9%
Time: 6.1s
Precision: binary64
Cost: 576

?

\[\left(\left(\left(56789 \leq a \land a \leq 98765\right) \land \left(0 \leq b \land b \leq 1\right)\right) \land \left(0 \leq c \land c \leq 0.0016773\right)\right) \land \left(0 \leq d \land d \leq 0.0016773\right)\]
\[a \cdot \left(\left(b + c\right) + d\right) \]
\[a \cdot \left(c + b\right) + a \cdot d \]
(FPCore (a b c d) :precision binary64 (* a (+ (+ b c) d)))
(FPCore (a b c d) :precision binary64 (+ (* a (+ c b)) (* a d)))
double code(double a, double b, double c, double d) {
	return a * ((b + c) + d);
}
double code(double a, double b, double c, double d) {
	return (a * (c + b)) + (a * d);
}
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)
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 = (a * (c + b)) + (a * d)
end function
public static double code(double a, double b, double c, double d) {
	return a * ((b + c) + d);
}
public static double code(double a, double b, double c, double d) {
	return (a * (c + b)) + (a * d);
}
def code(a, b, c, d):
	return a * ((b + c) + d)
def code(a, b, c, d):
	return (a * (c + b)) + (a * d)
function code(a, b, c, d)
	return Float64(a * Float64(Float64(b + c) + d))
end
function code(a, b, c, d)
	return Float64(Float64(a * Float64(c + b)) + Float64(a * d))
end
function tmp = code(a, b, c, d)
	tmp = a * ((b + c) + d);
end
function tmp = code(a, b, c, d)
	tmp = (a * (c + b)) + (a * d);
end
code[a_, b_, c_, d_] := N[(a * N[(N[(b + c), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_, d_] := N[(N[(a * N[(c + b), $MachinePrecision]), $MachinePrecision] + N[(a * d), $MachinePrecision]), $MachinePrecision]
a \cdot \left(\left(b + c\right) + d\right)
a \cdot \left(c + b\right) + a \cdot d

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original99.9%
Target99.9%
Herbie99.9%
\[a \cdot b + a \cdot \left(c + d\right) \]

Derivation?

  1. Initial program 99.9%

    \[a \cdot \left(\left(b + c\right) + d\right) \]
  2. Simplified99.9%

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

    [Start]99.9

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

    +-commutative [=>]99.9

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

    associate-+l+ [=>]99.9

    \[ a \cdot \color{blue}{\left(c + \left(b + d\right)\right)} \]
  3. Taylor expanded in d around 0 99.9%

    \[\leadsto \color{blue}{a \cdot \left(c + b\right) + a \cdot d} \]
  4. Final simplification99.9%

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

Alternatives

Alternative 1
Accuracy52.5%
Cost720
\[\begin{array}{l} \mathbf{if}\;c \leq 5.9 \cdot 10^{-264}:\\ \;\;\;\;a \cdot d\\ \mathbf{elif}\;c \leq 1.18 \cdot 10^{-225}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \leq 9.8 \cdot 10^{-167}:\\ \;\;\;\;a \cdot d\\ \mathbf{elif}\;c \leq 6.4 \cdot 10^{-108}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;a \cdot c\\ \end{array} \]
Alternative 2
Accuracy77.7%
Cost717
\[\begin{array}{l} \mathbf{if}\;d \leq 3 \cdot 10^{-131} \lor \neg \left(d \leq 7.4 \cdot 10^{-106}\right) \land d \leq 2.2 \cdot 10^{-98}:\\ \;\;\;\;a \cdot \left(c + b\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot d\\ \end{array} \]
Alternative 3
Accuracy85.6%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 5.2 \cdot 10^{-121}:\\ \;\;\;\;a \cdot \left(c + d\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(c + b\right)\\ \end{array} \]
Alternative 4
Accuracy84.8%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 2.8 \cdot 10^{-103}:\\ \;\;\;\;a \cdot \left(c + d\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(b + d\right)\\ \end{array} \]
Alternative 5
Accuracy99.9%
Cost448
\[a \cdot \left(c + \left(b + d\right)\right) \]
Alternative 6
Accuracy52.8%
Cost324
\[\begin{array}{l} \mathbf{if}\;b \leq 2.8 \cdot 10^{-103}:\\ \;\;\;\;a \cdot c\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 7
Accuracy35.7%
Cost192
\[a \cdot b \]

Error

Reproduce?

herbie shell --seed 2023141 
(FPCore (a b c d)
  :name "Expression, p14"
  :precision binary64
  :pre (and (and (and (and (<= 56789.0 a) (<= a 98765.0)) (and (<= 0.0 b) (<= b 1.0))) (and (<= 0.0 c) (<= c 0.0016773))) (and (<= 0.0 d) (<= d 0.0016773)))

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

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