?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.0
\[a \cdot b + a \cdot \left(c + d\right) \]

Derivation?

  1. Initial program 0.0

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

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

    [Start]0.0

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

    +-commutative [=>]0.0

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

    associate-+l+ [=>]0.0

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

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

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

Alternatives

Alternative 1
Error30.1
Cost1248
\[\begin{array}{l} \mathbf{if}\;d \leq 3.2 \cdot 10^{-285}:\\ \;\;\;\;a \cdot c\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-244}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 6 \cdot 10^{-241}:\\ \;\;\;\;a \cdot c\\ \mathbf{elif}\;d \leq 9.5 \cdot 10^{-221}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 5.1 \cdot 10^{-188}:\\ \;\;\;\;a \cdot c\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-161}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;d \leq 4.1 \cdot 10^{-148}:\\ \;\;\;\;a \cdot c\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-128}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;d \cdot a\\ \end{array} \]
Alternative 2
Error10.0
Cost848
\[\begin{array}{l} t_0 := a \cdot \left(d + b\right)\\ t_1 := a \cdot \left(d + c\right)\\ \mathbf{if}\;b \leq 1.8 \cdot 10^{-181}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{-159}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{-142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 8.8 \cdot 10^{-82}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(b + c\right)\\ \end{array} \]
Alternative 3
Error30.6
Cost589
\[\begin{array}{l} \mathbf{if}\;b \leq 4.2 \cdot 10^{-180} \lor \neg \left(b \leq 4.2 \cdot 10^{-160}\right) \land b \leq 1.15 \cdot 10^{-141}:\\ \;\;\;\;a \cdot c\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \]
Alternative 4
Error0.0
Cost576
\[a \cdot \left(d + c\right) + b \cdot a \]
Alternative 5
Error13.3
Cost452
\[\begin{array}{l} \mathbf{if}\;d \leq 9.8 \cdot 10^{-108}:\\ \;\;\;\;a \cdot \left(b + c\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot a\\ \end{array} \]
Alternative 6
Error9.7
Cost452
\[\begin{array}{l} \mathbf{if}\;d \leq 2.3 \cdot 10^{-128}:\\ \;\;\;\;a \cdot \left(b + c\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(d + c\right)\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[a \cdot \left(c + \left(d + b\right)\right) \]
Alternative 8
Error41.5
Cost192
\[b \cdot a \]

Error

Reproduce?

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