?

Average Error: 0.07% → 0.06%
Time: 7.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) \]
\[\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.07%
Target0.06%
Herbie0.06%
\[a \cdot b + a \cdot \left(c + d\right) \]

Derivation?

  1. Initial program 0.07

    \[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.09%
Cost852
\[\begin{array}{l} \mathbf{if}\;b \leq 1.85 \cdot 10^{-208}:\\ \;\;\;\;d \cdot a\\ \mathbf{elif}\;b \leq 4.1 \cdot 10^{-196}:\\ \;\;\;\;a \cdot c\\ \mathbf{elif}\;b \leq 1.05 \cdot 10^{-185}:\\ \;\;\;\;d \cdot a\\ \mathbf{elif}\;b \leq 9.2 \cdot 10^{-164}:\\ \;\;\;\;a \cdot c\\ \mathbf{elif}\;b \leq 1.1 \cdot 10^{-160}:\\ \;\;\;\;d \cdot a\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \]
Alternative 2
Error22.3%
Cost717
\[\begin{array}{l} \mathbf{if}\;d \leq 1.5 \cdot 10^{-121} \lor \neg \left(d \leq 2.9 \cdot 10^{-74}\right) \land d \leq 2.5 \cdot 10^{-64}:\\ \;\;\;\;a \cdot \left(b + c\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot a\\ \end{array} \]
Alternative 3
Error14.94%
Cost716
\[\begin{array}{l} t_0 := a \cdot \left(b + c\right)\\ \mathbf{if}\;d \leq 9.6 \cdot 10^{-147}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.22 \cdot 10^{-138}:\\ \;\;\;\;a \cdot \left(d + c\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-133}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(d + b\right) \cdot a\\ \end{array} \]
Alternative 4
Error14.88%
Cost452
\[\begin{array}{l} \mathbf{if}\;d \leq 6 \cdot 10^{-147}:\\ \;\;\;\;a \cdot \left(b + c\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(d + c\right)\\ \end{array} \]
Alternative 5
Error0.07%
Cost448
\[a \cdot \left(d + \left(b + c\right)\right) \]
Alternative 6
Error47.6%
Cost324
\[\begin{array}{l} \mathbf{if}\;b \leq 8.6 \cdot 10^{-160}:\\ \;\;\;\;a \cdot c\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \]
Alternative 7
Error64.69%
Cost192
\[b \cdot a \]

Error

Reproduce?

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