Average Error: 0.0 → 0.0
Time: 2.5s
Precision: binary64
Cost: 320
\[d1 \cdot d2 + d1 \cdot d3 \]
\[d1 \cdot \left(d2 + d3\right) \]
(FPCore (d1 d2 d3) :precision binary64 (+ (* d1 d2) (* d1 d3)))
(FPCore (d1 d2 d3) :precision binary64 (* d1 (+ d2 d3)))
double code(double d1, double d2, double d3) {
	return (d1 * d2) + (d1 * d3);
}
double code(double d1, double d2, double d3) {
	return d1 * (d2 + 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 * 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 + d3)
end function
public static double code(double d1, double d2, double d3) {
	return (d1 * d2) + (d1 * d3);
}
public static double code(double d1, double d2, double d3) {
	return d1 * (d2 + d3);
}
def code(d1, d2, d3):
	return (d1 * d2) + (d1 * d3)
def code(d1, d2, d3):
	return d1 * (d2 + d3)
function code(d1, d2, d3)
	return Float64(Float64(d1 * d2) + Float64(d1 * d3))
end
function code(d1, d2, d3)
	return Float64(d1 * Float64(d2 + d3))
end
function tmp = code(d1, d2, d3)
	tmp = (d1 * d2) + (d1 * d3);
end
function tmp = code(d1, d2, d3)
	tmp = d1 * (d2 + d3);
end
code[d1_, d2_, d3_] := N[(N[(d1 * d2), $MachinePrecision] + N[(d1 * d3), $MachinePrecision]), $MachinePrecision]
code[d1_, d2_, d3_] := N[(d1 * N[(d2 + d3), $MachinePrecision]), $MachinePrecision]
d1 \cdot d2 + d1 \cdot d3
d1 \cdot \left(d2 + d3\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 0.0

    \[d1 \cdot d2 + d1 \cdot d3 \]
  2. Simplified0.0

    \[\leadsto \color{blue}{d1 \cdot \left(d2 + d3\right)} \]
    Proof
    (*.f64 d1 (+.f64 d2 d3)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 d1 d2) (*.f64 d1 d3))): 3 points increase in error, 1 points decrease in error
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error24.5
Cost588
\[\begin{array}{l} \mathbf{if}\;d2 \leq -1.1205453159504328 \cdot 10^{+117}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq -3.104950165612417 \cdot 10^{+68}:\\ \;\;\;\;d1 \cdot d3\\ \mathbf{elif}\;d2 \leq -3.1084525364303425 \cdot 10^{-144}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d3\\ \end{array} \]
Alternative 2
Error29.9
Cost192
\[d1 \cdot d2 \]

Error

Reproduce

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

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

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