?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 0.06

    \[a \cdot \left(\left(b + c\right) + d\right) \]
  2. Taylor expanded in c around 0 0.06

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

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

Alternatives

Alternative 1
Error47.07%
Cost1116
\[\begin{array}{l} \mathbf{if}\;c \leq 9.5 \cdot 10^{-262}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{-244}:\\ \;\;\;\;d \cdot a\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-200}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-182}:\\ \;\;\;\;d \cdot a\\ \mathbf{elif}\;c \leq 6.5 \cdot 10^{-157}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;c \leq 6 \cdot 10^{-140}:\\ \;\;\;\;d \cdot a\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-125}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot c\\ \end{array} \]
Alternative 2
Error15.19%
Cost981
\[\begin{array}{l} t_0 := \left(d + b\right) \cdot a\\ t_1 := a \cdot \left(b + c\right)\\ \mathbf{if}\;d \leq 1.7 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 2.2 \cdot 10^{-126}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{-122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 9 \cdot 10^{-61} \lor \neg \left(d \leq 4.5 \cdot 10^{-37}\right):\\ \;\;\;\;a \cdot \left(d + c\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error21.45%
Cost717
\[\begin{array}{l} \mathbf{if}\;d \leq 3.9 \cdot 10^{-122} \lor \neg \left(d \leq 1.26 \cdot 10^{-92}\right) \land d \leq 1.45 \cdot 10^{-79}:\\ \;\;\;\;a \cdot \left(b + c\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot a\\ \end{array} \]
Alternative 4
Error14.28%
Cost452
\[\begin{array}{l} \mathbf{if}\;d \leq 7.5 \cdot 10^{-132}:\\ \;\;\;\;a \cdot \left(b + c\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(d + c\right)\\ \end{array} \]
Alternative 5
Error0.06%
Cost448
\[a \cdot \left(d + \left(b + c\right)\right) \]
Alternative 6
Error46.68%
Cost324
\[\begin{array}{l} \mathbf{if}\;c \leq 7.5 \cdot 10^{-125}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;a \cdot c\\ \end{array} \]
Alternative 7
Error64.5%
Cost192
\[b \cdot a \]

Error

Reproduce?

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