?

Average Error: 0.1 → 0.0
Time: 7.2s
Precision: binary64
Cost: 832

?

\[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
\[\left(-4 \cdot \frac{y}{z} + 4 \cdot \frac{x}{z}\right) - 2 \]
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
(FPCore (x y z)
 :precision binary64
 (- (+ (* -4.0 (/ y z)) (* 4.0 (/ x 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 * (y / z)) + (4.0 * (x / 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) * (y / z)) + (4.0d0 * (x / 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 * (y / z)) + (4.0 * (x / 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 * (y / z)) + (4.0 * (x / 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(Float64(-4.0 * Float64(y / z)) + Float64(4.0 * Float64(x / 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 * (y / z)) + (4.0 * (x / 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[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\left(-4 \cdot \frac{y}{z} + 4 \cdot \frac{x}{z}\right) - 2

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.1
Target0.0
Herbie0.0
\[4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right) \]

Derivation?

  1. Initial program 0.1

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

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

    [Start]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-13 [=>]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-7 [=>]0.1

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

    metadata-eval [=>]0.1

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

    metadata-eval [<=]0.1

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

    metadata-eval [<=]0.1

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

    metadata-eval [<=]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-23 [<=]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-74 [<=]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-23 [=>]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1

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

    metadata-eval [=>]0.1

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

    rational_best_oopsla_all_46_json_45_simplify-52 [=>]0.1

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

    \[\leadsto \color{blue}{\left(-4 \cdot \frac{y}{z} + 4 \cdot \frac{x}{z}\right) - 2} \]
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error20.3
Cost2008
\[\begin{array}{l} t_0 := 4 \cdot \frac{x - y}{z}\\ \mathbf{if}\;x - y \leq -2 \cdot 10^{-22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x - y \leq 2 \cdot 10^{-123}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x - y \leq 2 \cdot 10^{-106}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x - y \leq 8.2 \cdot 10^{+57}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x - y \leq 2 \cdot 10^{+74}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x - y \leq 2 \cdot 10^{+104}:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error31.5
Cost980
\[\begin{array}{l} t_0 := 4 \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -1 \cdot 10^{+176}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{+119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8200000000:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-174}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+97}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
Alternative 3
Error9.4
Cost976
\[\begin{array}{l} t_0 := \frac{y}{z} \cdot -4 - 2\\ \mathbf{if}\;y \leq -7.6 \cdot 10^{+167}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.2 \cdot 10^{+65}:\\ \;\;\;\;4 \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq -1.72 \cdot 10^{+31}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+20}:\\ \;\;\;\;\frac{x}{z} \cdot 4 - 2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error11.5
Cost712
\[\begin{array}{l} t_0 := 4 \cdot \frac{x - y}{z}\\ \mathbf{if}\;y \leq -1.9 \cdot 10^{+110}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+25}:\\ \;\;\;\;\frac{x}{z} \cdot 4 - 2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error29.6
Cost584
\[\begin{array}{l} t_0 := -4 \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -1 \cdot 10^{+110}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+54}:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.0
Cost576
\[4 \cdot \frac{x - y}{z} - 2 \]
Alternative 7
Error36.7
Cost64
\[-2 \]

Error

Reproduce?

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