Average Error: 6.3 → 3.0
Time: 4.8s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -9.793361331116636 \cdot 10^{+146}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;t \leq 1.1791014341897874 \cdot 10^{-293}:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\sqrt{t}} \cdot \frac{z - x}{\sqrt{t}}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= t -9.793361331116636e+146)
   (+ x (* y (/ (- z x) t)))
   (if (<= t 1.1791014341897874e-293)
     (+ x (/ (- (* y z) (* y x)) t))
     (+ x (* (/ y (sqrt t)) (/ (- z x) (sqrt t)))))))
double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -9.793361331116636e+146) {
		tmp = x + (y * ((z - x) / t));
	} else if (t <= 1.1791014341897874e-293) {
		tmp = x + (((y * z) - (y * x)) / t);
	} else {
		tmp = x + ((y / sqrt(t)) * ((z - x) / sqrt(t)));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y * (z - x)) / t)
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (t <= (-9.793361331116636d+146)) then
        tmp = x + (y * ((z - x) / t))
    else if (t <= 1.1791014341897874d-293) then
        tmp = x + (((y * z) - (y * x)) / t)
    else
        tmp = x + ((y / sqrt(t)) * ((z - x) / sqrt(t)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -9.793361331116636e+146) {
		tmp = x + (y * ((z - x) / t));
	} else if (t <= 1.1791014341897874e-293) {
		tmp = x + (((y * z) - (y * x)) / t);
	} else {
		tmp = x + ((y / Math.sqrt(t)) * ((z - x) / Math.sqrt(t)));
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y * (z - x)) / t)
def code(x, y, z, t):
	tmp = 0
	if t <= -9.793361331116636e+146:
		tmp = x + (y * ((z - x) / t))
	elif t <= 1.1791014341897874e-293:
		tmp = x + (((y * z) - (y * x)) / t)
	else:
		tmp = x + ((y / math.sqrt(t)) * ((z - x) / math.sqrt(t)))
	return tmp
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * Float64(z - x)) / t))
end
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -9.793361331116636e+146)
		tmp = Float64(x + Float64(y * Float64(Float64(z - x) / t)));
	elseif (t <= 1.1791014341897874e-293)
		tmp = Float64(x + Float64(Float64(Float64(y * z) - Float64(y * x)) / t));
	else
		tmp = Float64(x + Float64(Float64(y / sqrt(t)) * Float64(Float64(z - x) / sqrt(t))));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x + ((y * (z - x)) / t);
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -9.793361331116636e+146)
		tmp = x + (y * ((z - x) / t));
	elseif (t <= 1.1791014341897874e-293)
		tmp = x + (((y * z) - (y * x)) / t);
	else
		tmp = x + ((y / sqrt(t)) * ((z - x) / sqrt(t)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[t, -9.793361331116636e+146], N[(x + N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.1791014341897874e-293], N[(x + N[(N[(N[(y * z), $MachinePrecision] - N[(y * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / N[Sqrt[t], $MachinePrecision]), $MachinePrecision] * N[(N[(z - x), $MachinePrecision] / N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -9.793361331116636 \cdot 10^{+146}:\\
\;\;\;\;x + y \cdot \frac{z - x}{t}\\

\mathbf{elif}\;t \leq 1.1791014341897874 \cdot 10^{-293}:\\
\;\;\;\;x + \frac{y \cdot z - y \cdot x}{t}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\sqrt{t}} \cdot \frac{z - x}{\sqrt{t}}\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target1.9
Herbie3.0
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Split input into 3 regimes
  2. if t < -9.7933613311166362e146

    1. Initial program 11.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - x}{t}, x\right)} \]
    3. Applied fma-udef_binary641.6

      \[\leadsto \color{blue}{y \cdot \frac{z - x}{t} + x} \]

    if -9.7933613311166362e146 < t < 1.1791014341897874e-293

    1. Initial program 3.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - x}{t}, x\right)} \]
    3. Applied fma-udef_binary649.3

      \[\leadsto \color{blue}{y \cdot \frac{z - x}{t} + x} \]
    4. Taylor expanded in t around inf 3.3

      \[\leadsto \color{blue}{\frac{y \cdot z - y \cdot x}{t}} + x \]

    if 1.1791014341897874e-293 < t

    1. Initial program 6.6

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - x}{t}, x\right)} \]
    3. Applied fma-udef_binary646.1

      \[\leadsto \color{blue}{y \cdot \frac{z - x}{t} + x} \]
    4. Applied add-sqr-sqrt_binary646.2

      \[\leadsto y \cdot \frac{z - x}{\color{blue}{\sqrt{t} \cdot \sqrt{t}}} + x \]
    5. Applied *-un-lft-identity_binary646.2

      \[\leadsto y \cdot \frac{\color{blue}{1 \cdot \left(z - x\right)}}{\sqrt{t} \cdot \sqrt{t}} + x \]
    6. Applied times-frac_binary646.2

      \[\leadsto y \cdot \color{blue}{\left(\frac{1}{\sqrt{t}} \cdot \frac{z - x}{\sqrt{t}}\right)} + x \]
    7. Applied associate-*r*_binary643.4

      \[\leadsto \color{blue}{\left(y \cdot \frac{1}{\sqrt{t}}\right) \cdot \frac{z - x}{\sqrt{t}}} + x \]
    8. Simplified3.3

      \[\leadsto \color{blue}{\frac{y}{\sqrt{t}}} \cdot \frac{z - x}{\sqrt{t}} + x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -9.793361331116636 \cdot 10^{+146}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;t \leq 1.1791014341897874 \cdot 10^{-293}:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\sqrt{t}} \cdot \frac{z - x}{\sqrt{t}}\\ \end{array} \]

Reproduce

herbie shell --seed 2022131 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
  :precision binary64

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

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