?

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

?

\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
\[4 \cdot \frac{x - y}{z} + -2 \]
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
(FPCore (x y z) :precision binary64 (+ (* 4.0 (/ (- x y) z)) -2.0))
double code(double x, double y, double z) {
	return (4.0 * ((x - y) - (z * 0.5))) / z;
}
double code(double x, double y, double z) {
	return (4.0 * ((x - y) / z)) + -2.0;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (4.0d0 * ((x - y) / z)) + (-2.0d0)
end function
public static double code(double x, double y, double z) {
	return (4.0 * ((x - y) - (z * 0.5))) / z;
}
public static double code(double x, double y, double z) {
	return (4.0 * ((x - y) / z)) + -2.0;
}
def code(x, y, z):
	return (4.0 * ((x - y) - (z * 0.5))) / z
def code(x, y, z):
	return (4.0 * ((x - y) / z)) + -2.0
function code(x, y, z)
	return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z)
end
function code(x, y, z)
	return Float64(Float64(4.0 * Float64(Float64(x - y) / z)) + -2.0)
end
function tmp = code(x, y, z)
	tmp = (4.0 * ((x - y) - (z * 0.5))) / z;
end
function tmp = code(x, y, z)
	tmp = (4.0 * ((x - y) / z)) + -2.0;
end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
4 \cdot \frac{x - y}{z} + -2

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original99.8%
Target100.0%
Herbie100.0%
\[4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right) \]

Derivation?

  1. Initial program 99.8%

    \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
  2. Simplified99.6%

    \[\leadsto \color{blue}{\frac{4}{z} \cdot \left(\left(x - y\right) + z \cdot -0.5\right)} \]
    Proof

    [Start]99.8

    \[ \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]

    associate-*l/ [<=]99.6

    \[ \color{blue}{\frac{4}{z} \cdot \left(\left(x - y\right) - z \cdot 0.5\right)} \]

    sub-neg [=>]99.6

    \[ \frac{4}{z} \cdot \color{blue}{\left(\left(x - y\right) + \left(-z \cdot 0.5\right)\right)} \]

    distribute-rgt-neg-in [=>]99.6

    \[ \frac{4}{z} \cdot \left(\left(x - y\right) + \color{blue}{z \cdot \left(-0.5\right)}\right) \]

    metadata-eval [=>]99.6

    \[ \frac{4}{z} \cdot \left(\left(x - y\right) + z \cdot \color{blue}{-0.5}\right) \]
  3. Taylor expanded in z around 0 100.0%

    \[\leadsto \color{blue}{4 \cdot \frac{x - y}{z} - 2} \]
  4. Final simplification100.0%

    \[\leadsto 4 \cdot \frac{x - y}{z} + -2 \]

Alternatives

Alternative 1
Accuracy52.7%
Cost1112
\[\begin{array}{l} t_0 := y \cdot \frac{-4}{z}\\ t_1 := 4 \cdot \frac{x}{z}\\ \mathbf{if}\;x \leq -7 \cdot 10^{+125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-44}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-166}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq -3.25 \cdot 10^{-233}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+75}:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy52.6%
Cost1112
\[\begin{array}{l} t_0 := \frac{y \cdot -4}{z}\\ t_1 := 4 \cdot \frac{x}{z}\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{+127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-44}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{-76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-166}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq -1.42 \cdot 10^{-232}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{+76}:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy82.8%
Cost845
\[\begin{array}{l} \mathbf{if}\;y \leq -6.6 \cdot 10^{+58}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-81} \lor \neg \left(y \leq 2100000000\right):\\ \;\;\;\;-4 \cdot \left(\frac{y}{z} + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{x}{z} + -2\\ \end{array} \]
Alternative 4
Accuracy82.9%
Cost845
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+54}:\\ \;\;\;\;\frac{\frac{x - y}{z}}{0.25}\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-81} \lor \neg \left(y \leq 2100000000\right):\\ \;\;\;\;-4 \cdot \left(\frac{y}{z} + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{x}{z} + -2\\ \end{array} \]
Alternative 5
Accuracy78.4%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{+126} \lor \neg \left(x \leq 3.5 \cdot 10^{+96}\right):\\ \;\;\;\;4 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\frac{y}{z} + 0.5\right)\\ \end{array} \]
Alternative 6
Accuracy81.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -1.38 \cdot 10^{+127} \lor \neg \left(x \leq 1.4 \cdot 10^{+79}\right):\\ \;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\frac{y}{z} + 0.5\right)\\ \end{array} \]
Alternative 7
Accuracy53.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{+125} \lor \neg \left(x \leq 4 \cdot 10^{+80}\right):\\ \;\;\;\;4 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 8
Accuracy41.6%
Cost64
\[-2 \]

Error

Reproduce?

herbie shell --seed 2023135 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
  :precision binary64

  :herbie-target
  (- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))

  (/ (* 4.0 (- (- x y) (* z 0.5))) z))