Average Error: 0.1 → 0.1
Time: 16.8s
Precision: binary64
Cost: 576
\[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
\[2 + \frac{\left(x - z\right) \cdot 4}{y} \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
(FPCore (x y z) :precision binary64 (+ 2.0 (/ (* (- x z) 4.0) 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 2.0 + (((x - z) * 4.0) / 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 = 2.0d0 + (((x - z) * 4.0d0) / 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 2.0 + (((x - z) * 4.0) / y);
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
def code(x, y, z):
	return 2.0 + (((x - z) * 4.0) / 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(2.0 + Float64(Float64(Float64(x - z) * 4.0) / 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 = 2.0 + (((x - z) * 4.0) / 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[(2.0 + N[(N[(N[(x - z), $MachinePrecision] * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
2 + \frac{\left(x - z\right) \cdot 4}{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 y around 0 0.0

    \[\leadsto \color{blue}{2 + 4 \cdot \frac{x - z}{y}} \]
  3. Simplified0.1

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

Alternatives

Alternative 1
Error31.0
Cost1112
\[\begin{array}{l} t_0 := \frac{-4 \cdot z}{y}\\ t_1 := \frac{4 \cdot x}{y}\\ \mathbf{if}\;x \leq -3.1 \cdot 10^{+97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -4.3 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.95 \cdot 10^{-209}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-308}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+50}:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error30.7
Cost1112
\[\begin{array}{l} t_0 := 1 + \frac{-4 \cdot z}{y}\\ t_1 := \frac{4 \cdot x}{y}\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{+95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6 \cdot 10^{+44}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq -7.8 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-209}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-276}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.62 \cdot 10^{+50}:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error29.6
Cost976
\[\begin{array}{l} t_0 := 1 + \frac{4 \cdot x}{y}\\ \mathbf{if}\;x \leq -1.1 \cdot 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -7.9 \cdot 10^{-209}:\\ \;\;\;\;2\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-278}:\\ \;\;\;\;1 + \frac{-4 \cdot z}{y}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+50}:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error14.7
Cost976
\[\begin{array}{l} t_0 := 2 + \frac{-4 \cdot z}{y}\\ t_1 := 1 + \frac{4 \cdot x}{y}\\ \mathbf{if}\;x \leq -2.2 \cdot 10^{+98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{+201}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error11.0
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+68}:\\ \;\;\;\;2 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+50}:\\ \;\;\;\;2 + \frac{-4 \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(\frac{x}{y} - \frac{z}{y}\right)\\ \end{array} \]
Alternative 6
Error9.5
Cost712
\[\begin{array}{l} t_0 := 2 + \frac{4 \cdot x}{y}\\ \mathbf{if}\;x \leq -7.6 \cdot 10^{+70}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+67}:\\ \;\;\;\;2 + \frac{-4 \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error11.0
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+68}:\\ \;\;\;\;2 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;x \leq 1.62 \cdot 10^{+50}:\\ \;\;\;\;2 + \frac{-4 \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{4 \cdot \left(x - z\right)}{y}\\ \end{array} \]
Alternative 8
Error30.8
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{-31}:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-44}:\\ \;\;\;\;\frac{-4 \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 9
Error57.8
Cost64
\[1 \]
Alternative 10
Error36.9
Cost64
\[2 \]

Error

Reproduce

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