?

Average Error: 0.1 → 0.1
Time: 2.4s
Precision: binary64
Cost: 576

?

\[ \begin{array}{c}[d2, d3] = \mathsf{sort}([d2, d3])\\ \end{array} \]
\[\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3 \]
\[d1 \cdot \left(d2 + 3\right) + d1 \cdot d3 \]
(FPCore (d1 d2 d3) :precision binary64 (+ (+ (* d1 3.0) (* d1 d2)) (* d1 d3)))
(FPCore (d1 d2 d3) :precision binary64 (+ (* d1 (+ d2 3.0)) (* d1 d3)))
double code(double d1, double d2, double d3) {
	return ((d1 * 3.0) + (d1 * d2)) + (d1 * d3);
}
double code(double d1, double d2, double d3) {
	return (d1 * (d2 + 3.0)) + (d1 * d3);
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    code = ((d1 * 3.0d0) + (d1 * d2)) + (d1 * d3)
end function
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    code = (d1 * (d2 + 3.0d0)) + (d1 * d3)
end function
public static double code(double d1, double d2, double d3) {
	return ((d1 * 3.0) + (d1 * d2)) + (d1 * d3);
}
public static double code(double d1, double d2, double d3) {
	return (d1 * (d2 + 3.0)) + (d1 * d3);
}
def code(d1, d2, d3):
	return ((d1 * 3.0) + (d1 * d2)) + (d1 * d3)
def code(d1, d2, d3):
	return (d1 * (d2 + 3.0)) + (d1 * d3)
function code(d1, d2, d3)
	return Float64(Float64(Float64(d1 * 3.0) + Float64(d1 * d2)) + Float64(d1 * d3))
end
function code(d1, d2, d3)
	return Float64(Float64(d1 * Float64(d2 + 3.0)) + Float64(d1 * d3))
end
function tmp = code(d1, d2, d3)
	tmp = ((d1 * 3.0) + (d1 * d2)) + (d1 * d3);
end
function tmp = code(d1, d2, d3)
	tmp = (d1 * (d2 + 3.0)) + (d1 * d3);
end
code[d1_, d2_, d3_] := N[(N[(N[(d1 * 3.0), $MachinePrecision] + N[(d1 * d2), $MachinePrecision]), $MachinePrecision] + N[(d1 * d3), $MachinePrecision]), $MachinePrecision]
code[d1_, d2_, d3_] := N[(N[(d1 * N[(d2 + 3.0), $MachinePrecision]), $MachinePrecision] + N[(d1 * d3), $MachinePrecision]), $MachinePrecision]
\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3
d1 \cdot \left(d2 + 3\right) + d1 \cdot d3

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.1
Target0.1
Herbie0.1
\[d1 \cdot \left(\left(3 + d2\right) + d3\right) \]

Derivation?

  1. Initial program 0.1

    \[\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3 \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\left(d1 \cdot d3 + d1 \cdot 3\right) + d1 \cdot d2} \]
    Proof

    [Start]0.1

    \[ \left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3 \]

    rational.json-simplify-1 [=>]0.1

    \[ \color{blue}{d1 \cdot d3 + \left(d1 \cdot 3 + d1 \cdot d2\right)} \]

    rational.json-simplify-33 [=>]0.1

    \[ \color{blue}{\left(d1 \cdot d3 + d1 \cdot 3\right) + d1 \cdot d2} \]
  3. Taylor expanded in d1 around 0 0.1

    \[\leadsto \color{blue}{d1 \cdot \left(3 + \left(d2 + d3\right)\right)} \]
  4. Taylor expanded in d3 around 0 0.1

    \[\leadsto \color{blue}{d1 \cdot d3 + d1 \cdot \left(3 + d2\right)} \]
  5. Simplified0.1

    \[\leadsto \color{blue}{d1 \cdot \left(d2 + 3\right) + d1 \cdot d3} \]
    Proof

    [Start]0.1

    \[ d1 \cdot d3 + d1 \cdot \left(3 + d2\right) \]

    rational.json-simplify-1 [=>]0.1

    \[ \color{blue}{d1 \cdot \left(3 + d2\right) + d1 \cdot d3} \]

    rational.json-simplify-1 [=>]0.1

    \[ d1 \cdot \color{blue}{\left(d2 + 3\right)} + d1 \cdot d3 \]
  6. Final simplification0.1

    \[\leadsto d1 \cdot \left(d2 + 3\right) + d1 \cdot d3 \]

Alternatives

Alternative 1
Error17.4
Cost720
\[\begin{array}{l} \mathbf{if}\;d2 \leq -5200000000:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{elif}\;d2 \leq -3.6 \cdot 10^{-181}:\\ \;\;\;\;d1 \cdot 3\\ \mathbf{elif}\;d2 \leq -3.8 \cdot 10^{-198}:\\ \;\;\;\;d1 \cdot d3\\ \mathbf{elif}\;d2 \leq 1.5 \cdot 10^{-181}:\\ \;\;\;\;d1 \cdot 3\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d3\\ \end{array} \]
Alternative 2
Error4.9
Cost452
\[\begin{array}{l} \mathbf{if}\;d2 \leq -31500000000:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(3 + d3\right)\\ \end{array} \]
Alternative 3
Error1.2
Cost452
\[\begin{array}{l} \mathbf{if}\;d2 \leq -5200000000:\\ \;\;\;\;d1 \cdot \left(d3 + d2\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(3 + d3\right)\\ \end{array} \]
Alternative 4
Error1.0
Cost452
\[\begin{array}{l} \mathbf{if}\;d3 \leq 3:\\ \;\;\;\;\left(d2 + 3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d3 + d2\right)\\ \end{array} \]
Alternative 5
Error0.1
Cost448
\[d1 \cdot \left(3 + \left(d2 + d3\right)\right) \]
Alternative 6
Error23.4
Cost324
\[\begin{array}{l} \mathbf{if}\;d3 \leq 650000000:\\ \;\;\;\;d1 \cdot 3\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d3\\ \end{array} \]
Alternative 7
Error43.4
Cost192
\[d1 \cdot 3 \]

Error

Reproduce?

herbie shell --seed 2023053 
(FPCore (d1 d2 d3)
  :name "FastMath test3"
  :precision binary64

  :herbie-target
  (* d1 (+ (+ 3.0 d2) d3))

  (+ (+ (* d1 3.0) (* d1 d2)) (* d1 d3)))