Average Error: 0.0 → 0.0
Time: 9.2s
Precision: binary64
Cost: 704
\[ \begin{array}{c}[d2, d4] = \mathsf{sort}([d2, d4])\\ \end{array} \]
\[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
\[d1 \cdot \left(d4 - d1\right) + d1 \cdot \left(d2 - d3\right) \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (+ (* d1 (- d4 d1)) (* d1 (- d2 d3))))
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 * (d4 - d1)) + (d1 * (d2 - d3));
}
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 * (d4 - d1)) + (d1 * (d2 - d3))
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 * (d4 - d1)) + (d1 * (d2 - d3));
}
def code(d1, d2, d3, d4):
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
def code(d1, d2, d3, d4):
	return (d1 * (d4 - d1)) + (d1 * (d2 - d3))
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(Float64(d1 * Float64(d4 - d1)) + Float64(d1 * Float64(d2 - d3)))
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 * (d4 - d1)) + (d1 * (d2 - d3));
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[(N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision] + N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
d1 \cdot \left(d4 - d1\right) + 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(\left(\left(d2 - d3\right) + d4\right) - d1\right) \]

Derivation

  1. Initial program 0.0

    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
  2. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error31.8
Cost1444
\[\begin{array}{l} t_0 := d1 \cdot \left(-d3\right)\\ \mathbf{if}\;d2 \leq -3.652204141270984 \cdot 10^{+111}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq -3.8098852283530333 \cdot 10^{+59}:\\ \;\;\;\;d1 \cdot d4\\ \mathbf{elif}\;d2 \leq -47164613471564.38:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq -2.504196743172014 \cdot 10^{-94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d2 \leq -6.082324058414277 \cdot 10^{-141}:\\ \;\;\;\;d1 \cdot d4\\ \mathbf{elif}\;d2 \leq -8.18329813168449 \cdot 10^{-196}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d2 \leq -3.639669203377119 \cdot 10^{-220}:\\ \;\;\;\;d1 \cdot \left(-d1\right)\\ \mathbf{elif}\;d2 \leq -1.302525741211711 \cdot 10^{-300}:\\ \;\;\;\;d1 \cdot d4\\ \mathbf{elif}\;d2 \leq 1.041124658518195 \cdot 10^{-21}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d4\\ \end{array} \]
Alternative 2
Error13.3
Cost1112
\[\begin{array}{l} t_0 := d1 \cdot \left(d2 - d1\right)\\ t_1 := d1 \cdot \left(d2 - d3\right)\\ \mathbf{if}\;d4 \leq -5.590421760927496 \cdot 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d4 \leq -8.238071761640793 \cdot 10^{-139}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d4 \leq 1.398593234501758 \cdot 10^{-280}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d4 \leq 4.5111953963710984 \cdot 10^{-203}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d4 \leq 4.6673749424294505 \cdot 10^{-157}:\\ \;\;\;\;\left(d1 + d3\right) \cdot \left(-d1\right)\\ \mathbf{elif}\;d4 \leq 2.0993535538528756 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \end{array} \]
Alternative 3
Error6.9
Cost844
\[\begin{array}{l} t_0 := d1 \cdot \left(d2 - d3\right)\\ t_1 := d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\ \mathbf{if}\;d2 \leq -3.652204141270984 \cdot 10^{+111}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d2 \leq -3.8098852283530333 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d2 \leq -47164613471564.38:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error27.9
Cost784
\[\begin{array}{l} t_0 := d1 \cdot \left(-d3\right)\\ \mathbf{if}\;d4 \leq 4.5111953963710984 \cdot 10^{-203}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d4 \leq 8.282883588352543 \cdot 10^{-35}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d4 \leq 12911890208.959991:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d4 \leq 3.3094202222103796 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d4\\ \end{array} \]
Alternative 5
Error16.8
Cost716
\[\begin{array}{l} t_0 := d1 \cdot \left(d4 - d3\right)\\ \mathbf{if}\;d2 \leq -3.652204141270984 \cdot 10^{+111}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq -1.1188864027033161 \cdot 10^{+46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d2 \leq -47164613471564.38:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error12.4
Cost716
\[\begin{array}{l} t_0 := d1 \cdot \left(d2 - d3\right)\\ \mathbf{if}\;d4 \leq -5.590421760927496 \cdot 10^{-53}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d4 \leq -8.238071761640793 \cdot 10^{-139}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{elif}\;d4 \leq 2.0993535538528756 \cdot 10^{+33}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \end{array} \]
Alternative 7
Error2.8
Cost708
\[\begin{array}{l} \mathbf{if}\;d2 \leq -47164613471564.38:\\ \;\;\;\;d1 \cdot d4 + d1 \cdot \left(d2 - d3\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\ \end{array} \]
Alternative 8
Error31.2
Cost588
\[\begin{array}{l} \mathbf{if}\;d2 \leq -3.652204141270984 \cdot 10^{+111}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq -3.8098852283530333 \cdot 10^{+59}:\\ \;\;\;\;d1 \cdot d4\\ \mathbf{elif}\;d2 \leq -40.21798142111249:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d4\\ \end{array} \]
Alternative 9
Error13.1
Cost584
\[\begin{array}{l} \mathbf{if}\;d2 \leq -5.428544997541594 \cdot 10^{+100}:\\ \;\;\;\;d1 \cdot \left(d2 - d3\right)\\ \mathbf{elif}\;d2 \leq -47164613471564.38:\\ \;\;\;\;d1 \cdot \left(d4 + d2\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \end{array} \]
Alternative 10
Error2.8
Cost580
\[\begin{array}{l} \mathbf{if}\;d2 \leq -47164613471564.38:\\ \;\;\;\;d1 \cdot \left(\left(d4 + d2\right) - d3\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\ \end{array} \]
Alternative 11
Error0.0
Cost576
\[d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right) \]
Alternative 12
Error13.9
Cost452
\[\begin{array}{l} \mathbf{if}\;d2 \leq -47164613471564.38:\\ \;\;\;\;d1 \cdot \left(d4 + d2\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \end{array} \]
Alternative 13
Error60.7
Cost192
\[d1 \cdot d1 \]
Alternative 14
Error43.5
Cost192
\[d1 \cdot d2 \]

Error

Reproduce

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