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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{4}{y}, x - z, 4\right)} \]
    Proof
    (fma.f64 (/.f64 4 y) (-.f64 x z) 4): 0 points increase in error, 0 points decrease in error
    (fma.f64 (/.f64 4 y) (Rewrite<= unsub-neg_binary64 (+.f64 x (neg.f64 z))) 4): 0 points increase in error, 0 points decrease in error
    (Rewrite=> fma-udef_binary64 (+.f64 (*.f64 (/.f64 4 y) (+.f64 x (neg.f64 z))) 4)): 1 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))) 4): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 4 (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= metadata-eval (+.f64 3 1)) (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (Rewrite<= metadata-eval (*.f64 4 3/4)) 1) (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (*.f64 (Rewrite<= metadata-eval (/.f64 4 1)) 3/4) 1) (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (*.f64 (/.f64 4 (Rewrite<= *-inverses_binary64 (/.f64 y y))) 3/4) 1) (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (*.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 4 y) y)) 3/4) 1) (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (*.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 4 y) y)) 3/4) 1) (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))): 15 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (Rewrite<= associate-*r*_binary64 (*.f64 (/.f64 4 y) (*.f64 y 3/4))) 1) (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))): 19 points increase in error, 6 points decrease in error
    (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 1 (*.f64 (/.f64 4 y) (*.f64 y 3/4)))) (*.f64 (+.f64 x (neg.f64 z)) (/.f64 4 y))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 1 (*.f64 (/.f64 4 y) (*.f64 y 3/4))) (Rewrite=> *-commutative_binary64 (*.f64 (/.f64 4 y) (+.f64 x (neg.f64 z))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+r+_binary64 (+.f64 1 (+.f64 (*.f64 (/.f64 4 y) (*.f64 y 3/4)) (*.f64 (/.f64 4 y) (+.f64 x (neg.f64 z)))))): 1 points increase in error, 0 points decrease in error
    (+.f64 1 (Rewrite<= distribute-lft-in_binary64 (*.f64 (/.f64 4 y) (+.f64 (*.f64 y 3/4) (+.f64 x (neg.f64 z)))))): 4 points increase in error, 0 points decrease in error
    (+.f64 1 (*.f64 (/.f64 4 y) (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (*.f64 y 3/4) x) (neg.f64 z))))): 0 points increase in error, 0 points decrease in error
    (+.f64 1 (*.f64 (/.f64 4 y) (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 x (*.f64 y 3/4))) (neg.f64 z)))): 0 points increase in error, 0 points decrease in error
    (+.f64 1 (*.f64 (/.f64 4 y) (Rewrite<= sub-neg_binary64 (-.f64 (+.f64 x (*.f64 y 3/4)) z)))): 0 points increase in error, 0 points decrease in error
    (+.f64 1 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 4 (-.f64 (+.f64 x (*.f64 y 3/4)) z)) y))): 8 points increase in error, 55 points decrease in error
  3. Taylor expanded in x around 0 0.0

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

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

Alternatives

Alternative 1
Error33.3
Cost1772
\[\begin{array}{l} t_0 := \frac{4 \cdot x}{y}\\ t_1 := \frac{-4}{\frac{y}{z}}\\ \mathbf{if}\;z \leq -6 \cdot 10^{+115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -13033143112086.287:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq -1.6698256729601001 \cdot 10^{-46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.9499998654226211 \cdot 10^{-75}:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq -4.220638688878653 \cdot 10^{-103}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.4053463210512425 \cdot 10^{-236}:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq 6.96397652881996 \cdot 10^{-175}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.703601269611222 \cdot 10^{-148}:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq 4.454191286218944 \cdot 10^{+58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{+198}:\\ \;\;\;\;4\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error33.3
Cost1772
\[\begin{array}{l} t_0 := \frac{4 \cdot x}{y}\\ t_1 := -4 \cdot \frac{z}{y}\\ \mathbf{if}\;z \leq -6 \cdot 10^{+115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -13033143112086.287:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq -1.6698256729601001 \cdot 10^{-46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.9499998654226211 \cdot 10^{-75}:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq -4.220638688878653 \cdot 10^{-103}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.4053463210512425 \cdot 10^{-236}:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq 6.96397652881996 \cdot 10^{-175}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.703601269611222 \cdot 10^{-148}:\\ \;\;\;\;4\\ \mathbf{elif}\;z \leq 4.454191286218944 \cdot 10^{+58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{+198}:\\ \;\;\;\;4\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error13.7
Cost712
\[\begin{array}{l} t_0 := \frac{4 \cdot x}{y}\\ \mathbf{if}\;x \leq -8.5 \cdot 10^{+103}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+96}:\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error11.8
Cost712
\[\begin{array}{l} t_0 := 4 \cdot \frac{x - z}{y}\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+90}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1913421380946955.3:\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error9.0
Cost712
\[\begin{array}{l} t_0 := 4 + 4 \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -1.8634831113367157 \cdot 10^{-36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.504404063299271 \cdot 10^{-60}:\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error30.3
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -6.1357863236753954 \cdot 10^{+29}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 1.6469088278349683 \cdot 10^{+105}:\\ \;\;\;\;\frac{-4}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
Alternative 7
Error0.2
Cost576
\[4 + \frac{4}{y} \cdot \left(x - z\right) \]
Alternative 8
Error36.4
Cost64
\[4 \]

Error

Reproduce

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