?

Average Error: 0.0 → 0.0
Time: 19.3s
Precision: binary64
Cost: 576

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.0

    \[x + \frac{y - x}{z} \]
  2. Taylor expanded in y around 0 0.0

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

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

Alternatives

Alternative 1
Error12.0
Cost1112
\[\begin{array}{l} t_0 := x + \frac{y}{z}\\ t_1 := \frac{x}{-z}\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-113}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-175}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{-240}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-107}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error12.0
Cost1112
\[\begin{array}{l} t_0 := \frac{x}{-z}\\ t_1 := x + \frac{y}{z}\\ \mathbf{if}\;z \leq -16500:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-117}:\\ \;\;\;\;x - \frac{x}{z}\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{-175}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-234}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-107}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-64}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error28.7
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{+159}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;y \leq -1.46 \cdot 10^{+116}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.85 \cdot 10^{+46}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{+31}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z}\\ \end{array} \]
Alternative 4
Error0.8
Cost584
\[\begin{array}{l} t_0 := x + \frac{y}{z}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{y - x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[x + \frac{y - x}{z} \]
Alternative 6
Error35.1
Cost64
\[x \]

Error

Reproduce?

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