?

Average Error: 0.03% → 0.03%
Time: 5.1s
Precision: binary64
Cost: 576

?

\[x + \frac{y - x}{z} \]
\[\frac{y}{z} - \left(\frac{x}{z} - x\right) \]
(FPCore (x y z) :precision binary64 (+ x (/ (- y x) z)))
(FPCore (x y z) :precision binary64 (- (/ y z) (- (/ x z) x)))
double code(double x, double y, double z) {
	return x + ((y - x) / z);
}
double code(double x, double y, double z) {
	return (y / z) - ((x / z) - x);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + ((y - x) / z)
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 = (y / z) - ((x / z) - x)
end function
public static double code(double x, double y, double z) {
	return x + ((y - x) / z);
}
public static double code(double x, double y, double z) {
	return (y / z) - ((x / z) - x);
}
def code(x, y, z):
	return x + ((y - x) / z)
def code(x, y, z):
	return (y / z) - ((x / z) - x)
function code(x, y, z)
	return Float64(x + Float64(Float64(y - x) / z))
end
function code(x, y, z)
	return Float64(Float64(y / z) - Float64(Float64(x / z) - x))
end
function tmp = code(x, y, z)
	tmp = x + ((y - x) / z);
end
function tmp = code(x, y, z)
	tmp = (y / z) - ((x / z) - x);
end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(y / z), $MachinePrecision] - N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]
x + \frac{y - x}{z}
\frac{y}{z} - \left(\frac{x}{z} - x\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.03

    \[x + \frac{y - x}{z} \]
  2. Applied egg-rr0.03

    \[\leadsto \color{blue}{\frac{y}{z} - \left(\frac{x}{z} - x\right)} \]
  3. Final simplification0.03

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

Alternatives

Alternative 1
Error36.69%
Cost916
\[\begin{array}{l} t_0 := \frac{-x}{z}\\ \mathbf{if}\;z \leq -0.39:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-265}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-92}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-46}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error17.07%
Cost850
\[\begin{array}{l} \mathbf{if}\;x \leq -2.35 \cdot 10^{+50} \lor \neg \left(x \leq 3.6 \cdot 10^{-183} \lor \neg \left(x \leq 1.5 \cdot 10^{-91}\right) \land x \leq 1.5 \cdot 10^{-69}\right):\\ \;\;\;\;x - \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} + x\\ \end{array} \]
Alternative 3
Error1.67%
Cost716
\[\begin{array}{l} t_0 := \frac{y}{z} + x\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-6}:\\ \;\;\;\;\frac{y - x}{z}\\ \mathbf{elif}\;z \leq 18000:\\ \;\;\;\;x - \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error17.64%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq 4.1 \cdot 10^{-265} \lor \neg \left(z \leq 1.36 \cdot 10^{-93}\right):\\ \;\;\;\;\frac{y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{z}\\ \end{array} \]
Alternative 5
Error40.05%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-29}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-194}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error0.03%
Cost448
\[x + \frac{y - x}{z} \]
Alternative 7
Error53.75%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023121 
(FPCore (x y z)
  :name "Statistics.Sample:$swelfordMean from math-functions-0.1.5.2"
  :precision binary64
  (+ x (/ (- y x) z)))