Average Error: 0.2 → 0.0
Time: 14.3s
Precision: binary64
Cost: 576
\[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y} \]
\[4 + 4 \cdot \frac{x - z}{y} \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
(FPCore (x y z) :precision binary64 (+ 4.0 (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
double code(double x, double y, double z) {
	return 4.0 + (4.0 * ((x - z) / 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.75d0)) - 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 = 4.0d0 + (4.0d0 * ((x - z) / y))
end function
public static double code(double x, double y, double z) {
	return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
public static double code(double x, double y, double z) {
	return 4.0 + (4.0 * ((x - z) / y));
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
def code(x, y, z):
	return 4.0 + (4.0 * ((x - z) / y))
function code(x, y, z)
	return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y))
end
function code(x, y, z)
	return Float64(4.0 + Float64(4.0 * Float64(Float64(x - z) / y)))
end
function tmp = code(x, y, z)
	tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
end
function tmp = code(x, y, z)
	tmp = 4.0 + (4.0 * ((x - z) / y));
end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(4.0 + N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
4 + 4 \cdot \frac{x - z}{y}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.2

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

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

    \[\leadsto \color{blue}{4 + 4 \cdot \frac{x - z}{y}} \]

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}:\\ \;\;\;\;4\\ \mathbf{elif}\;x \leq -4.3 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.95 \cdot 10^{-209}:\\ \;\;\;\;4\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-308}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+50}:\\ \;\;\;\;4\\ \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}:\\ \;\;\;\;4\\ \mathbf{elif}\;x \leq -7.8 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-209}:\\ \;\;\;\;4\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-276}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.62 \cdot 10^{+50}:\\ \;\;\;\;4\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error29.7
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}:\\ \;\;\;\;4\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-278}:\\ \;\;\;\;1 + \frac{-4 \cdot z}{y}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+50}:\\ \;\;\;\;4\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error14.8
Cost976
\[\begin{array}{l} t_0 := 4 + \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}:\\ \;\;\;\;4 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+50}:\\ \;\;\;\;4 + \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 := 4 + \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}:\\ \;\;\;\;4 + \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}:\\ \;\;\;\;4 + \frac{4 \cdot x}{y}\\ \mathbf{elif}\;x \leq 1.62 \cdot 10^{+50}:\\ \;\;\;\;4 + \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}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-44}:\\ \;\;\;\;\frac{-4 \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
Alternative 9
Error58.2
Cost64
\[1 \]
Alternative 10
Error36.8
Cost64
\[4 \]

Error

Reproduce

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