Average Error: 10.1 → 0.0
Time: 5.4s
Precision: binary64
Cost: 576
\[\frac{x + y \cdot \left(z - x\right)}{z}\]
\[y + \frac{x}{z} \cdot \left(1 - y\right)\]
\frac{x + y \cdot \left(z - x\right)}{z}
y + \frac{x}{z} \cdot \left(1 - y\right)
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z) :precision binary64 (+ y (* (/ x z) (- 1.0 y))))
double code(double x, double y, double z) {
	return (x + (y * (z - x))) / z;
}
double code(double x, double y, double z) {
	return y + ((x / z) * (1.0 - y));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.1
Target0.0
Herbie0.0
\[\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}\]

Alternatives

Alternative 1
Error0.8
Cost776
\[\begin{array}{l} \mathbf{if}\;y \leq -4169970779.2587366 \lor \neg \left(y \leq 1.0230567903020182\right):\\ \;\;\;\;y - y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array}\]
Alternative 2
Error6.2
Cost1229
\[\begin{array}{l} \mathbf{if}\;y \leq -3.760100212790515 \cdot 10^{+129}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -4169970779.2587366 \lor \neg \left(y \leq 1.0230567903020182\right) \land y \leq 7.314508261839512 \cdot 10^{+131}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array}\]
Alternative 3
Error8.9
Cost320
\[y + \frac{x}{z}\]
Alternative 4
Error20.2
Cost834
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3623527802025365 \cdot 10^{-107}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 5.164047881899096 \cdot 10^{-05}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array}\]
Alternative 5
Error31.7
Cost64
\[y\]
Alternative 6
Error61.7
Cost64
\[-1\]
Alternative 7
Error61.8
Cost64
\[1\]

Error

Derivation

  1. Initial program 10.1

    \[\frac{x + y \cdot \left(z - x\right)}{z}\]
  2. Taylor expanded around 0 3.4

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

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

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

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

Reproduce

herbie shell --seed 2021044 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
  :precision binary64

  :herbie-target
  (- (+ y (/ x z)) (/ y (/ z x)))

  (/ (+ x (* y (- z x))) z))