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

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. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{4}{y}, x - z, 2\right)} \]
  3. Taylor expanded in x around 0 0.0

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

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

Alternatives

Alternative 1
Error30.0
Cost1376
\[\begin{array}{l} t_0 := \frac{4}{\frac{y}{x}}\\ t_1 := -4 \cdot \frac{z}{y}\\ \mathbf{if}\;y \leq -1.2411813814993641 \cdot 10^{+72}:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq -3756988686666884600:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.02 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.6 \cdot 10^{-271}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.0452587259456844 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.269367655608502 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 2
Error30.0
Cost1376
\[\begin{array}{l} t_0 := x \cdot \frac{4}{y}\\ t_1 := -4 \cdot \frac{z}{y}\\ \mathbf{if}\;y \leq -1.2411813814993641 \cdot 10^{+72}:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq -3756988686666884600:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.02 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.6 \cdot 10^{-271}:\\ \;\;\;\;\frac{4}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.0452587259456844 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.269367655608502 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 3
Error30.0
Cost1376
\[\begin{array}{l} t_0 := 4 \cdot \frac{x}{y}\\ t_1 := -4 \cdot \frac{z}{y}\\ \mathbf{if}\;y \leq -1.2411813814993641 \cdot 10^{+72}:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq -3756988686666884600:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.02 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.6 \cdot 10^{-271}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.0452587259456844 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.269367655608502 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 4
Error15.2
Cost976
\[\begin{array}{l} t_0 := 4 \cdot \frac{x}{y}\\ t_1 := 2 + -4 \cdot \frac{z}{y}\\ \mathbf{if}\;x \leq -1.52 \cdot 10^{+228}:\\ \;\;\;\;x \cdot \frac{4}{y}\\ \mathbf{elif}\;x \leq -8.4 \cdot 10^{+114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.6889807760331217 \cdot 10^{+52}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{+210}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error30.9
Cost848
\[\begin{array}{l} t_0 := -4 \cdot \frac{z}{y}\\ \mathbf{if}\;z \leq -11791462038.527077:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.1093947045513385 \cdot 10^{-45}:\\ \;\;\;\;2\\ \mathbf{elif}\;z \leq 3.6745690502585793 \cdot 10^{+40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.9721770682535117 \cdot 10^{+53}:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error9.4
Cost844
\[\begin{array}{l} t_0 := 2 + -4 \cdot \frac{z}{y}\\ \mathbf{if}\;z \leq -1005286241854.361:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.1093947045513385 \cdot 10^{-45}:\\ \;\;\;\;2 + \frac{4}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 1.8019296837130653 \cdot 10^{+34}:\\ \;\;\;\;4 \cdot \frac{x - z}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error8.6
Cost712
\[\begin{array}{l} t_0 := 2 + -4 \cdot \frac{z}{y}\\ \mathbf{if}\;z \leq -1005286241854.361:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 30013367833357844:\\ \;\;\;\;2 + x \cdot \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error8.6
Cost712
\[\begin{array}{l} t_0 := 2 + -4 \cdot \frac{z}{y}\\ \mathbf{if}\;z \leq -1005286241854.361:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 30013367833357844:\\ \;\;\;\;2 + \frac{4}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error0.2
Cost576
\[2 + \frac{4}{y} \cdot \left(x - z\right) \]
Alternative 10
Error37.2
Cost64
\[2 \]

Error

Reproduce

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