?

Average Error: 0.15% → 0.14%
Time: 6.1s
Precision: binary64
Cost: 832

?

\[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y} \]
\[\frac{4 \cdot x}{y} + \left(2 + \frac{z}{y} \cdot -4\right) \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
(FPCore (x y z)
 :precision binary64
 (+ (/ (* 4.0 x) y) (+ 2.0 (* (/ z y) -4.0))))
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 ((4.0 * x) / y) + (2.0 + ((z / y) * -4.0));
}
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 = ((4.0d0 * x) / y) + (2.0d0 + ((z / y) * (-4.0d0)))
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 ((4.0 * x) / y) + (2.0 + ((z / y) * -4.0));
}
def code(x, y, z):
	return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
def code(x, y, z):
	return ((4.0 * x) / y) + (2.0 + ((z / y) * -4.0))
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(4.0 * x) / y) + Float64(2.0 + Float64(Float64(z / y) * -4.0)))
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 = ((4.0 * x) / y) + (2.0 + ((z / y) * -4.0));
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[(4.0 * x), $MachinePrecision] / y), $MachinePrecision] + N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\frac{4 \cdot x}{y} + \left(2 + \frac{z}{y} \cdot -4\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.15

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

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

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

    [Start]0.03

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

    associate-+r+ [=>]0.03

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

    distribute-lft-in [=>]0.03

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

    metadata-eval [=>]0.03

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

    associate-+r+ [=>]0.02

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

    +-commutative [=>]0.02

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

    associate-*r/ [=>]0.15

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

    +-commutative [=>]0.15

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

    associate-+l+ [=>]0.14

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

    *-commutative [=>]0.14

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

    metadata-eval [=>]0.14

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

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

Alternatives

Alternative 1
Error47.8%
Cost848
\[\begin{array}{l} t_0 := \frac{z}{y} \cdot -4\\ \mathbf{if}\;z \leq -3.3 \cdot 10^{+34}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.85 \cdot 10^{-289}:\\ \;\;\;\;2\\ \mathbf{elif}\;z \leq 1.28 \cdot 10^{-284}:\\ \;\;\;\;\frac{4}{\frac{y}{x}}\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+59}:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error47.75%
Cost848
\[\begin{array}{l} t_0 := \frac{z}{y} \cdot -4\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{+34}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.1 \cdot 10^{-292}:\\ \;\;\;\;2\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-283}:\\ \;\;\;\;\frac{4 \cdot x}{y}\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+62}:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.27%
Cost832
\[1 + \frac{4}{\frac{y}{x + \left(y \cdot 0.25 - z\right)}} \]
Alternative 4
Error17.96%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{+35} \lor \neg \left(z \leq 3.9 \cdot 10^{+62}\right):\\ \;\;\;\;\frac{-4}{y} \cdot \left(z - x\right)\\ \mathbf{else}:\\ \;\;\;\;2 + 4 \cdot \frac{x}{y}\\ \end{array} \]
Alternative 5
Error13.84%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-18} \lor \neg \left(x \leq 3.2 \cdot 10^{-31}\right):\\ \;\;\;\;2 + 4 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;2 + z \cdot \frac{-4}{y}\\ \end{array} \]
Alternative 6
Error26.37%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.65 \cdot 10^{+171}:\\ \;\;\;\;2\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+184}:\\ \;\;\;\;\frac{-4}{y} \cdot \left(z - x\right)\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 7
Error46.55%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+35} \lor \neg \left(z \leq 3.2 \cdot 10^{+59}\right):\\ \;\;\;\;\frac{z}{y} \cdot -4\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
Alternative 8
Error57.09%
Cost64
\[2 \]

Error

Reproduce?

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