Average Error: 0.1 → 0.0
Time: 8.1s
Precision: binary64
Cost: 832
\[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
\[\left(\frac{z}{y} \cdot -4 + 2\right) + \frac{4 \cdot x}{y} \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
(FPCore (x y z)
 :precision binary64
 (+ (+ (* (/ z y) -4.0) 2.0) (/ (* 4.0 x) y)))
double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
double code(double x, double y, double z) {
	return (((z / y) * -4.0) + 2.0) + ((4.0 * x) / y);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
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 = (((z / y) * (-4.0d0)) + 2.0d0) + ((4.0d0 * x) / y)
end function
public static double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
public static double code(double x, double y, double z) {
	return (((z / y) * -4.0) + 2.0) + ((4.0 * x) / y);
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
def code(x, y, z):
	return (((z / y) * -4.0) + 2.0) + ((4.0 * x) / y)
function code(x, y, z)
	return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y))
end
function code(x, y, z)
	return Float64(Float64(Float64(Float64(z / y) * -4.0) + 2.0) + Float64(Float64(4.0 * x) / y))
end
function tmp = code(x, y, z)
	tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
end
function tmp = code(x, y, z)
	tmp = (((z / y) * -4.0) + 2.0) + ((4.0 * x) / y);
end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision] + 2.0), $MachinePrecision] + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\left(\frac{z}{y} \cdot -4 + 2\right) + \frac{4 \cdot x}{y}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.1

    \[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
  2. Taylor expanded in z around inf 0.0

    \[\leadsto \color{blue}{1 + \left(-4 \cdot \frac{z}{y} + 4 \cdot \left(0.25 + \frac{x}{y}\right)\right)} \]
  3. Simplified0.0

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

    [Start]0.0

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

    associate-+r+ [=>]0.0

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

    distribute-lft-in [=>]0.0

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

    metadata-eval [=>]0.0

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

    associate-+r+ [=>]0.0

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

    +-commutative [=>]0.0

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

    associate-*r/ [=>]0.0

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

    +-commutative [=>]0.0

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

    associate-+l+ [=>]0.0

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

    *-commutative [=>]0.0

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

    metadata-eval [=>]0.0

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

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

Alternatives

Alternative 1
Error30.7
Cost1376
\[\begin{array}{l} t_0 := \frac{4 \cdot x}{y}\\ t_1 := \frac{z \cdot -4}{y}\\ \mathbf{if}\;y \leq -4 \cdot 10^{+52}:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{+20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -240000000000:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-60}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -7.6 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -8 \cdot 10^{-182}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-197}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{+120}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 2
Error8.9
Cost978
\[\begin{array}{l} \mathbf{if}\;x \leq -4.15 \cdot 10^{+65} \lor \neg \left(x \leq -4.5 \cdot 10^{+28}\right) \land \left(x \leq -2.25 \cdot 10^{-14} \lor \neg \left(x \leq 0.65\right)\right):\\ \;\;\;\;2 + 4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;2 - \frac{z}{\frac{y}{4}}\\ \end{array} \]
Alternative 3
Error30.8
Cost850
\[\begin{array}{l} \mathbf{if}\;x \leq -0.000135 \lor \neg \left(x \leq 2.1 \cdot 10^{+14} \lor \neg \left(x \leq 4.5 \cdot 10^{+59}\right) \land x \leq 10^{+133}\right):\\ \;\;\;\;\frac{4 \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 4
Error0.2
Cost832
\[1 + \frac{4}{\frac{y}{x + \left(y \cdot 0.25 - z\right)}} \]
Alternative 5
Error0.1
Cost832
\[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
Alternative 6
Error11.7
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+49} \lor \neg \left(y \leq 4.2 \cdot 10^{+97}\right):\\ \;\;\;\;2 + 4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{x - z}{y}\\ \end{array} \]
Alternative 7
Error16.1
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+136}:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{+120}:\\ \;\;\;\;4 \cdot \frac{x - z}{y}\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 8
Error37.3
Cost64
\[2 \]

Error

Reproduce

herbie shell --seed 2022364 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
  :precision binary64
  (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))