?

Average Accuracy: 99.7% → 99.9%
Time: 10.0s
Precision: binary64
Cost: 7232

?

\[1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y} \]
\[1 + \mathsf{fma}\left(4, 0.75 + \frac{x}{y}, \frac{-4}{\frac{y}{z}}\right) \]
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
(FPCore (x y z)
 :precision binary64
 (+ 1.0 (fma 4.0 (+ 0.75 (/ x y)) (/ -4.0 (/ y z)))))
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 1.0 + fma(4.0, (0.75 + (x / y)), (-4.0 / (y / z)));
}
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(1.0 + fma(4.0, Float64(0.75 + Float64(x / y)), Float64(-4.0 / Float64(y / z))))
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[(1.0 + N[(4.0 * N[(0.75 + N[(x / y), $MachinePrecision]), $MachinePrecision] + N[(-4.0 / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
1 + \mathsf{fma}\left(4, 0.75 + \frac{x}{y}, \frac{-4}{\frac{y}{z}}\right)

Error?

Derivation?

  1. Initial program 99.7%

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

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

    [Start]99.7

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

    associate-/l* [=>]99.5

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

    associate--l+ [=>]99.5

    \[ 1 + \frac{4}{\frac{y}{\color{blue}{x + \left(y \cdot 0.75 - z\right)}}} \]
  3. Taylor expanded in z around inf 100.0%

    \[\leadsto 1 + \color{blue}{\left(-4 \cdot \frac{z}{y} + 4 \cdot \left(0.75 + \frac{x}{y}\right)\right)} \]
  4. Simplified99.9%

    \[\leadsto 1 + \color{blue}{\mathsf{fma}\left(4, 0.75 + \frac{x}{y}, \frac{-4}{\frac{y}{z}}\right)} \]
    Proof

    [Start]100.0

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

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

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

    associate-*r/ [=>]99.9

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

    associate-/l* [=>]99.9

    \[ 1 + \mathsf{fma}\left(4, 0.75 + \frac{x}{y}, \color{blue}{\frac{-4}{\frac{y}{z}}}\right) \]
  5. Final simplification99.9%

    \[\leadsto 1 + \mathsf{fma}\left(4, 0.75 + \frac{x}{y}, \frac{-4}{\frac{y}{z}}\right) \]

Alternatives

Alternative 1
Accuracy99.7%
Cost6848
\[\mathsf{fma}\left(x - z, \frac{4}{y}, 4\right) \]
Alternative 2
Accuracy52.9%
Cost1244
\[\begin{array}{l} t_0 := x \cdot \frac{4}{y}\\ t_1 := -4 \cdot \frac{z}{y}\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{+46}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-308}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-229}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+40}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
Alternative 3
Accuracy52.8%
Cost1244
\[\begin{array}{l} t_0 := -4 \cdot \frac{z}{y}\\ t_1 := x \cdot \frac{4}{y}\\ \mathbf{if}\;y \leq -1.9 \cdot 10^{+45}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-301}:\\ \;\;\;\;\frac{4}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-229}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.7 \cdot 10^{-68}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
Alternative 4
Accuracy52.8%
Cost1244
\[\begin{array}{l} t_0 := \frac{x}{\frac{y}{4}}\\ t_1 := -4 \cdot \frac{z}{y}\\ \mathbf{if}\;y \leq -1.2 \cdot 10^{+45}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.8 \cdot 10^{-290}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-229}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-95}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{-68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
Alternative 5
Accuracy99.5%
Cost832
\[1 + \frac{4}{\frac{y}{x + \left(0.75 \cdot y - z\right)}} \]
Alternative 6
Accuracy99.7%
Cost832
\[1 + \frac{4 \cdot \left(\left(x + 0.75 \cdot y\right) - z\right)}{y} \]
Alternative 7
Accuracy81.2%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -0.26 \lor \neg \left(y \leq 7 \cdot 10^{+42}\right):\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \frac{x - z}{y}\\ \end{array} \]
Alternative 8
Accuracy86.0%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.76 \cdot 10^{+47} \lor \neg \left(z \leq 1.85 \cdot 10^{-75}\right):\\ \;\;\;\;4 + -4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;4 + 4 \cdot \frac{x}{y}\\ \end{array} \]
Alternative 9
Accuracy72.6%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{+77}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+217}:\\ \;\;\;\;4 \cdot \frac{x - z}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
Alternative 10
Accuracy52.3%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{+42}:\\ \;\;\;\;4\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-23}:\\ \;\;\;\;-4 \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;4\\ \end{array} \]
Alternative 11
Accuracy42.7%
Cost64
\[4 \]

Error

Reproduce?

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