Average Error: 2.1 → 5.0
Time: 6.0s
Precision: binary64
Cost: 840
\[\frac{x}{y} \cdot \left(z - t\right) + t \]
\[\begin{array}{l} t_1 := t + \frac{x}{\frac{y}{z - t}}\\ \mathbf{if}\;y \leq -1 \cdot 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-240}:\\ \;\;\;\;\frac{x \cdot \left(z - t\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ t (/ x (/ y (- z t))))))
   (if (<= y -1e-100) t_1 (if (<= y 1e-240) (/ (* x (- z t)) y) t_1))))
double code(double x, double y, double z, double t) {
	return ((x / y) * (z - t)) + t;
}
double code(double x, double y, double z, double t) {
	double t_1 = t + (x / (y / (z - t)));
	double tmp;
	if (y <= -1e-100) {
		tmp = t_1;
	} else if (y <= 1e-240) {
		tmp = (x * (z - t)) / y;
	} else {
		tmp = t_1;
	}
	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 - t)) + 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) :: t_1
    real(8) :: tmp
    t_1 = t + (x / (y / (z - t)))
    if (y <= (-1d-100)) then
        tmp = t_1
    else if (y <= 1d-240) then
        tmp = (x * (z - t)) / y
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return ((x / y) * (z - t)) + t;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = t + (x / (y / (z - t)));
	double tmp;
	if (y <= -1e-100) {
		tmp = t_1;
	} else if (y <= 1e-240) {
		tmp = (x * (z - t)) / y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x / y) * (z - t)) + t
def code(x, y, z, t):
	t_1 = t + (x / (y / (z - t)))
	tmp = 0
	if y <= -1e-100:
		tmp = t_1
	elif y <= 1e-240:
		tmp = (x * (z - t)) / y
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	return Float64(Float64(Float64(x / y) * Float64(z - t)) + t)
end
function code(x, y, z, t)
	t_1 = Float64(t + Float64(x / Float64(y / Float64(z - t))))
	tmp = 0.0
	if (y <= -1e-100)
		tmp = t_1;
	elseif (y <= 1e-240)
		tmp = Float64(Float64(x * Float64(z - t)) / y);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = ((x / y) * (z - t)) + t;
end
function tmp_2 = code(x, y, z, t)
	t_1 = t + (x / (y / (z - t)));
	tmp = 0.0;
	if (y <= -1e-100)
		tmp = t_1;
	elseif (y <= 1e-240)
		tmp = (x * (z - t)) / y;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t + N[(x / N[(y / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1e-100], t$95$1, If[LessEqual[y, 1e-240], N[(N[(x * N[(z - t), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], t$95$1]]]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
t_1 := t + \frac{x}{\frac{y}{z - t}}\\
\mathbf{if}\;y \leq -1 \cdot 10^{-100}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 10^{-240}:\\
\;\;\;\;\frac{x \cdot \left(z - t\right)}{y}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.1
Target2.3
Herbie5.0
\[\begin{array}{l} \mathbf{if}\;z < 2.759456554562692 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z < 2.326994450874436 \cdot 10^{-110}:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if y < -1e-100 or 9.9999999999999997e-241 < y

    1. Initial program 1.6

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

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

    if -1e-100 < y < 9.9999999999999997e-241

    1. Initial program 4.9

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z - t}{y}, t\right)} \]
    3. Taylor expanded in x around inf 29.7

      \[\leadsto \color{blue}{\left(\frac{z}{y} - \frac{t}{y}\right) \cdot x} \]
    4. Simplified17.2

      \[\leadsto \color{blue}{\left(z - t\right) \cdot \frac{x}{y}} \]
    5. Taylor expanded in x around 0 15.3

      \[\leadsto \color{blue}{\frac{\left(z - t\right) \cdot x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-100}:\\ \;\;\;\;t + \frac{x}{\frac{y}{z - t}}\\ \mathbf{elif}\;y \leq 10^{-240}:\\ \;\;\;\;\frac{x \cdot \left(z - t\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;t + \frac{x}{\frac{y}{z - t}}\\ \end{array} \]

Alternatives

Alternative 1
Error22.5
Cost1100
\[\begin{array}{l} t_1 := \frac{z}{\frac{y}{x}}\\ \mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{+235}:\\ \;\;\;\;x \cdot \frac{-t}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -2 \cdot 10^{-30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 10^{-72}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error13.1
Cost968
\[\begin{array}{l} t_1 := \left(z - t\right) \cdot \frac{x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{-30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 10^{-72}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error4.3
Cost968
\[\begin{array}{l} t_1 := \left(z - t\right) \cdot \frac{x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -0.04:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-8}:\\ \;\;\;\;t + \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error3.4
Cost968
\[\begin{array}{l} t_1 := \left(z - t\right) \cdot \frac{x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -20000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-8}:\\ \;\;\;\;t + \frac{z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error29.1
Cost848
\[\begin{array}{l} t_1 := x \cdot \frac{z}{y}\\ \mathbf{if}\;x \leq -8.8 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.14:\\ \;\;\;\;t\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+176}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error22.7
Cost840
\[\begin{array}{l} t_1 := \frac{z}{\frac{y}{x}}\\ \mathbf{if}\;\frac{x}{y} \leq -2 \cdot 10^{-30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 10^{-72}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error31.6
Cost716
\[\begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+140}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq -112778467106.61862:\\ \;\;\;\;\frac{x \cdot z}{y}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+100}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{z}{y}\\ \end{array} \]
Alternative 8
Error32.0
Cost64
\[t \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))

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