?

Average Accuracy: 99.7% → 100.0%
Time: 5.3s
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.7%
Target100.0%
Herbie100.0%
\[4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right) \]

Derivation?

  1. Initial program 99.7%

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

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

    [Start]99.7

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

    associate-/l* [=>]99.7

    \[ \color{blue}{\frac{4}{\frac{z}{\left(x - y\right) - z \cdot 0.5}}} \]
  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
Accuracy77.3%
Cost978
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+79} \lor \neg \left(y \leq 0.00044 \lor \neg \left(y \leq 1.3 \cdot 10^{+32}\right) \land y \leq 5.2 \cdot 10^{+87}\right):\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{x}{z} + -2\\ \end{array} \]
Alternative 2
Accuracy52.8%
Cost848
\[\begin{array}{l} t_0 := 4 \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+41}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-205}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-22}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{+84}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 3
Accuracy86.2%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+53} \lor \neg \left(y \leq 10^{-60}\right):\\ \;\;\;\;-4 \cdot \frac{y}{z} - 2\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{x}{z} + -2\\ \end{array} \]
Alternative 4
Accuracy83.9%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+54}:\\ \;\;\;\;-4 \cdot \frac{y}{z} - 2\\ \mathbf{elif}\;y \leq 6.7 \cdot 10^{-6}:\\ \;\;\;\;4 \cdot \frac{x}{z} + -2\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{\frac{z}{x - y}}\\ \end{array} \]
Alternative 5
Accuracy53.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+73} \lor \neg \left(y \leq 1.05 \cdot 10^{-5}\right):\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 6
Accuracy43.7%
Cost64
\[-2 \]

Error

Reproduce?

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