?

Average Accuracy: 100.0% → 100.0%
Time: 8.8s
Precision: binary64
Cost: 576

?

\[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
\[d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right) \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ (- d2 d3) (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
double code(double d1, double d2, double d3, double d4) {
	return d1 * ((d2 - d3) + (d4 - d1));
}
real(8) function code(d1, d2, d3, d4)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8), intent (in) :: d4
    code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
real(8) function code(d1, d2, d3, d4)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8), intent (in) :: d4
    code = d1 * ((d2 - d3) + (d4 - d1))
end function
public static double code(double d1, double d2, double d3, double d4) {
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
public static double code(double d1, double d2, double d3, double d4) {
	return d1 * ((d2 - d3) + (d4 - d1));
}
def code(d1, d2, d3, d4):
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
def code(d1, d2, d3, d4):
	return d1 * ((d2 - d3) + (d4 - d1))
function code(d1, d2, d3, d4)
	return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1))
end
function code(d1, d2, d3, d4)
	return Float64(d1 * Float64(Float64(d2 - d3) + Float64(d4 - d1)))
end
function tmp = code(d1, d2, d3, d4)
	tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
end
function tmp = code(d1, d2, d3, d4)
	tmp = d1 * ((d2 - d3) + (d4 - d1));
end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 - d3), $MachinePrecision] + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original100.0%
Target100.0%
Herbie100.0%
\[d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right) \]

Derivation?

  1. Initial program 100.0%

    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
  2. Simplified100.0%

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

    [Start]100.0

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

    associate--l+ [=>]100.0

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

    distribute-lft-out-- [=>]100.0

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

    distribute-rgt-out-- [=>]100.0

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

    distribute-lft-out [=>]100.0

    \[ \color{blue}{d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)} \]
  3. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy70.2%
Cost1112
\[\begin{array}{l} t_0 := d1 \cdot \left(d2 - d1\right)\\ t_1 := d1 \cdot \left(-d3\right)\\ t_2 := d1 \cdot \left(d2 + d4\right)\\ \mathbf{if}\;d3 \leq -9.8 \cdot 10^{+123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d3 \leq -2.6 \cdot 10^{+27}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d3 \leq -7.4 \cdot 10^{-46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d3 \leq 1.7 \cdot 10^{-209}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d3 \leq 8.5 \cdot 10^{-152}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d3 \leq 4.5 \cdot 10^{+96}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy75.8%
Cost848
\[\begin{array}{l} t_0 := d1 \cdot \left(d2 - d3\right)\\ t_1 := d1 \cdot \left(d2 + d4\right)\\ \mathbf{if}\;d3 \leq -0.006:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d3 \leq 2.95 \cdot 10^{-207}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d3 \leq 1.8 \cdot 10^{-150}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{elif}\;d3 \leq 5.6 \cdot 10^{+81}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Accuracy67.7%
Cost717
\[\begin{array}{l} \mathbf{if}\;d2 \leq -2.5 \cdot 10^{+34}:\\ \;\;\;\;d1 \cdot \left(d2 + d4\right)\\ \mathbf{elif}\;d2 \leq -7.4 \cdot 10^{-259} \lor \neg \left(d2 \leq 3.4 \cdot 10^{-308}\right):\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d1\right)\\ \end{array} \]
Alternative 4
Accuracy63.6%
Cost716
\[\begin{array}{l} \mathbf{if}\;d2 \leq -7.5 \cdot 10^{+33}:\\ \;\;\;\;d1 \cdot \left(d2 + d4\right)\\ \mathbf{elif}\;d2 \leq -1 \cdot 10^{-170}:\\ \;\;\;\;d1 \cdot \left(\left(-d3\right) - d1\right)\\ \mathbf{elif}\;d2 \leq 3.4 \cdot 10^{-308}:\\ \;\;\;\;d1 \cdot \left(d4 - d1\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \end{array} \]
Alternative 5
Accuracy95.1%
Cost713
\[\begin{array}{l} \mathbf{if}\;d3 \leq -1.05 \cdot 10^{+45} \lor \neg \left(d3 \leq 6.9 \cdot 10^{+34}\right):\\ \;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\ \end{array} \]
Alternative 6
Accuracy88.6%
Cost712
\[\begin{array}{l} \mathbf{if}\;d3 \leq -2.6 \cdot 10^{+102}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \mathbf{elif}\;d3 \leq 7.8 \cdot 10^{+82}:\\ \;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d2 - d3\right)\\ \end{array} \]
Alternative 7
Accuracy72.1%
Cost585
\[\begin{array}{l} \mathbf{if}\;d3 \leq -5.8 \cdot 10^{+125} \lor \neg \left(d3 \leq 5 \cdot 10^{+96}\right):\\ \;\;\;\;d1 \cdot \left(-d3\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d2 + d4\right)\\ \end{array} \]
Alternative 8
Accuracy53.4%
Cost584
\[\begin{array}{l} \mathbf{if}\;d2 \leq -1.32 \cdot 10^{-22}:\\ \;\;\;\;d1 \cdot \left(d2 + d4\right)\\ \mathbf{elif}\;d2 \leq -1.2 \cdot 10^{-170}:\\ \;\;\;\;d1 \cdot \left(-d3\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d1\right)\\ \end{array} \]
Alternative 9
Accuracy83.1%
Cost580
\[\begin{array}{l} \mathbf{if}\;d2 \leq -1.35 \cdot 10^{+31}:\\ \;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\ \end{array} \]
Alternative 10
Accuracy40.5%
Cost520
\[\begin{array}{l} \mathbf{if}\;d2 \leq -2.5 \cdot 10^{+34}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq -4.4 \cdot 10^{-171}:\\ \;\;\;\;d1 \cdot \left(-d3\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d4\\ \end{array} \]
Alternative 11
Accuracy40.7%
Cost324
\[\begin{array}{l} \mathbf{if}\;d4 \leq 5.5 \cdot 10^{-13}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d4\\ \end{array} \]
Alternative 12
Accuracy31.9%
Cost192
\[d1 \cdot d4 \]

Error

Reproduce?

herbie shell --seed 2023151 
(FPCore (d1 d2 d3 d4)
  :name "FastMath dist4"
  :precision binary64

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

  (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))