Average Error: 10.5 → 1.1
Time: 8.7s
Precision: binary64
Cost: 704
\[x + \frac{y \cdot \left(z - t\right)}{z - a} \]
\[\frac{y}{\frac{z - a}{z - t}} + x \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
(FPCore (x y z t a) :precision binary64 (+ (/ y (/ (- z a) (- z t))) x))
double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / (z - a));
}
double code(double x, double y, double z, double t, double a) {
	return (y / ((z - a) / (z - t))) + x;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x + ((y * (z - t)) / (z - a))
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = (y / ((z - a) / (z - t))) + x
end function
public static double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / (z - a));
}
public static double code(double x, double y, double z, double t, double a) {
	return (y / ((z - a) / (z - t))) + x;
}
def code(x, y, z, t, a):
	return x + ((y * (z - t)) / (z - a))
def code(x, y, z, t, a):
	return (y / ((z - a) / (z - t))) + x
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a)))
end
function code(x, y, z, t, a)
	return Float64(Float64(y / Float64(Float64(z - a) / Float64(z - t))) + x)
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((y * (z - t)) / (z - a));
end
function tmp = code(x, y, z, t, a)
	tmp = (y / ((z - a) / (z - t))) + x;
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
x + \frac{y \cdot \left(z - t\right)}{z - a}
\frac{y}{\frac{z - a}{z - t}} + x

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.5
Target1.1
Herbie1.1
\[x + \frac{y}{\frac{z - a}{z - t}} \]

Derivation

  1. Initial program 10.5

    \[x + \frac{y \cdot \left(z - t\right)}{z - a} \]
  2. Simplified1.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)} \]
    Proof
    (fma.f64 y (/.f64 (-.f64 z t) (-.f64 z a)) x): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (/.f64 (-.f64 z t) (-.f64 z a))) x)): 1 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) x): 63 points increase in error, 18 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr1.1

    \[\leadsto \color{blue}{\frac{y}{\frac{z - a}{z - t}} + x} \]
  4. Final simplification1.1

    \[\leadsto \frac{y}{\frac{z - a}{z - t}} + x \]

Alternatives

Alternative 1
Error17.4
Cost1108
\[\begin{array}{l} t_1 := y \cdot \frac{z - t}{z - a}\\ \mathbf{if}\;x \leq -5.433747040893134 \cdot 10^{+24}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.47392914565259 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.92384940682137 \cdot 10^{-5}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq 1.778291586085671 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.6159808810917332 \cdot 10^{+123}:\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 2
Error12.9
Cost1104
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{z - a}\\ \mathbf{if}\;x \leq -1.7149625786014267 \cdot 10^{-172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.3111899730041553 \cdot 10^{-103}:\\ \;\;\;\;y \cdot \frac{z - t}{z - a}\\ \mathbf{elif}\;x \leq 3.692210306277036 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.034814157460453 \cdot 10^{+118}:\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error11.8
Cost840
\[\begin{array}{l} t_1 := \left(y + x\right) - t \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -4.660609814288562 \cdot 10^{-96}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.410193304348883 \cdot 10^{-32}:\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error11.7
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -4.660609814288562 \cdot 10^{-96}:\\ \;\;\;\;x + \frac{y}{\frac{z}{z - t}}\\ \mathbf{elif}\;z \leq 3.410193304348883 \cdot 10^{-32}:\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - t \cdot \frac{y}{z}\\ \end{array} \]
Alternative 5
Error14.3
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8026087384071584 \cdot 10^{-33}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;z \leq 2.7127019747925625 \cdot 10^{+52}:\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 6
Error14.2
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8026087384071584 \cdot 10^{-33}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;z \leq 2.7127019747925625 \cdot 10^{+52}:\\ \;\;\;\;x + \frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 7
Error20.1
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -4.660609814288562 \cdot 10^{-96}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;z \leq 2.7127019747925625 \cdot 10^{+52}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 8
Error28.8
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022308 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
  :precision binary64

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

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