Average Error: 10.4 → 0.4
Time: 13.9s
Precision: binary64
Cost: 1993
\[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+247} \lor \neg \left(t_1 \leq 2 \cdot 10^{+292}\right):\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\ \mathbf{else}:\\ \;\;\;\;t_1 + x\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (* y (- z t)) (- a t))))
   (if (or (<= t_1 -2e+247) (not (<= t_1 2e+292)))
     (+ x (* (- z t) (/ y (- a t))))
     (+ t_1 x))))
double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (y * (z - t)) / (a - t);
	double tmp;
	if ((t_1 <= -2e+247) || !(t_1 <= 2e+292)) {
		tmp = x + ((z - t) * (y / (a - t)));
	} else {
		tmp = t_1 + x;
	}
	return tmp;
}
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)) / (a - t))
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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (y * (z - t)) / (a - t)
    if ((t_1 <= (-2d+247)) .or. (.not. (t_1 <= 2d+292))) then
        tmp = x + ((z - t) * (y / (a - t)))
    else
        tmp = t_1 + x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (y * (z - t)) / (a - t);
	double tmp;
	if ((t_1 <= -2e+247) || !(t_1 <= 2e+292)) {
		tmp = x + ((z - t) * (y / (a - t)));
	} else {
		tmp = t_1 + x;
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x + ((y * (z - t)) / (a - t))
def code(x, y, z, t, a):
	t_1 = (y * (z - t)) / (a - t)
	tmp = 0
	if (t_1 <= -2e+247) or not (t_1 <= 2e+292):
		tmp = x + ((z - t) * (y / (a - t)))
	else:
		tmp = t_1 + x
	return tmp
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t)))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(y * Float64(z - t)) / Float64(a - t))
	tmp = 0.0
	if ((t_1 <= -2e+247) || !(t_1 <= 2e+292))
		tmp = Float64(x + Float64(Float64(z - t) * Float64(y / Float64(a - t))));
	else
		tmp = Float64(t_1 + x);
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((y * (z - t)) / (a - t));
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (y * (z - t)) / (a - t);
	tmp = 0.0;
	if ((t_1 <= -2e+247) || ~((t_1 <= 2e+292)))
		tmp = x + ((z - t) * (y / (a - t)));
	else
		tmp = t_1 + x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+247], N[Not[LessEqual[t$95$1, 2e+292]], $MachinePrecision]], N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + x), $MachinePrecision]]]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+247} \lor \neg \left(t_1 \leq 2 \cdot 10^{+292}\right):\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\

\mathbf{else}:\\
\;\;\;\;t_1 + x\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.4
Target1.3
Herbie0.4
\[x + \frac{y}{\frac{a - t}{z - t}} \]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < -1.9999999999999999e247 or 2e292 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))

    1. Initial program 57.9

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

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

      [Start]57.9

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

      associate-*l/ [<=]1.8

      \[ x + \color{blue}{\frac{y}{a - t} \cdot \left(z - t\right)} \]

    if -1.9999999999999999e247 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 2e292

    1. Initial program 0.2

      \[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y \cdot \left(z - t\right)}{a - t} \leq -2 \cdot 10^{+247} \lor \neg \left(\frac{y \cdot \left(z - t\right)}{a - t} \leq 2 \cdot 10^{+292}\right):\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(z - t\right)}{a - t} + x\\ \end{array} \]

Alternatives

Alternative 1
Error17.3
Cost1500
\[\begin{array}{l} t_1 := y \cdot \frac{z - t}{a - t}\\ t_2 := x + \frac{z - t}{\frac{a}{y}}\\ \mathbf{if}\;a \leq -1.7 \cdot 10^{-33}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.36 \cdot 10^{-148}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq -5.5 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.2 \cdot 10^{-223}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \mathbf{elif}\;a \leq -4.8 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5 \cdot 10^{-143}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq 155:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error23.4
Cost1110
\[\begin{array}{l} \mathbf{if}\;z \leq -1.22 \cdot 10^{+244} \lor \neg \left(z \leq -5 \cdot 10^{+163}\right) \land \left(z \leq -2.2 \cdot 10^{+118} \lor \neg \left(z \leq 6 \cdot 10^{+150}\right) \land z \leq 1.85 \cdot 10^{+224}\right):\\ \;\;\;\;y \cdot \frac{z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 3
Error17.3
Cost1104
\[\begin{array}{l} \mathbf{if}\;x \leq -1.22 \cdot 10^{+175}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-63}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \mathbf{elif}\;x \leq -8.8 \cdot 10^{-128}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-71}:\\ \;\;\;\;y \cdot \frac{z - t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 4
Error1.3
Cost969
\[\begin{array}{l} \mathbf{if}\;t \leq 10^{-291} \lor \neg \left(t \leq 2.3 \cdot 10^{-42}\right):\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\ \end{array} \]
Alternative 5
Error10.8
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -240000000 \lor \neg \left(t \leq 2 \cdot 10^{-51}\right):\\ \;\;\;\;x + y \cdot \frac{t - z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - t}{\frac{a}{y}}\\ \end{array} \]
Alternative 6
Error10.2
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -2000000000:\\ \;\;\;\;x + y \cdot \frac{t - z}{t}\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{-84}:\\ \;\;\;\;x + \frac{z - t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{t} + -1}\\ \end{array} \]
Alternative 7
Error15.0
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -140000000 \lor \neg \left(t \leq 3.6 \cdot 10^{-81}\right):\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \end{array} \]
Alternative 8
Error3.1
Cost704
\[x + \left(z - t\right) \cdot \frac{y}{a - t} \]
Alternative 9
Error23.4
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.15 \cdot 10^{-299}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{-182}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 10
Error23.4
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -3.8 \cdot 10^{-294}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{-180}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 11
Error23.4
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -8.8 \cdot 10^{-296}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 2.45 \cdot 10^{-177}:\\ \;\;\;\;\frac{z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 12
Error23.4
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -2.6 \cdot 10^{-297}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 6.8 \cdot 10^{-182}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 13
Error20.1
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -190000000:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{-118}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 14
Error27.4
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -3.3 \cdot 10^{-187}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-70}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 15
Error28.6
Cost64
\[x \]

Error

Reproduce

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

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

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