?

Average Error: 2.0 → 1.6
Time: 10.7s
Precision: binary64
Cost: 1160

?

\[\frac{x}{y} \cdot \left(z - t\right) + t \]
\[\begin{array}{l} t_1 := \frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{if}\;y \leq -2 \cdot 10^{+36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+81}:\\ \;\;\;\;\left(\left(-\frac{t \cdot x}{y}\right) + \frac{z \cdot x}{y}\right) + t\\ \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 (+ (* (/ x y) (- z t)) t)))
   (if (<= y -2e+36)
     t_1
     (if (<= y 2e+81) (+ (+ (- (/ (* t x) y)) (/ (* z x) y)) t) 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 = ((x / y) * (z - t)) + t;
	double tmp;
	if (y <= -2e+36) {
		tmp = t_1;
	} else if (y <= 2e+81) {
		tmp = (-((t * x) / y) + ((z * x) / y)) + t;
	} 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 = ((x / y) * (z - t)) + t
    if (y <= (-2d+36)) then
        tmp = t_1
    else if (y <= 2d+81) then
        tmp = (-((t * x) / y) + ((z * x) / y)) + t
    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 = ((x / y) * (z - t)) + t;
	double tmp;
	if (y <= -2e+36) {
		tmp = t_1;
	} else if (y <= 2e+81) {
		tmp = (-((t * x) / y) + ((z * x) / y)) + t;
	} 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 = ((x / y) * (z - t)) + t
	tmp = 0
	if y <= -2e+36:
		tmp = t_1
	elif y <= 2e+81:
		tmp = (-((t * x) / y) + ((z * x) / y)) + t
	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(Float64(Float64(x / y) * Float64(z - t)) + t)
	tmp = 0.0
	if (y <= -2e+36)
		tmp = t_1;
	elseif (y <= 2e+81)
		tmp = Float64(Float64(Float64(-Float64(Float64(t * x) / y)) + Float64(Float64(z * x) / y)) + t);
	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 = ((x / y) * (z - t)) + t;
	tmp = 0.0;
	if (y <= -2e+36)
		tmp = t_1;
	elseif (y <= 2e+81)
		tmp = (-((t * x) / y) + ((z * x) / y)) + t;
	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[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[y, -2e+36], t$95$1, If[LessEqual[y, 2e+81], N[(N[((-N[(N[(t * x), $MachinePrecision] / y), $MachinePrecision]) + N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
t_1 := \frac{x}{y} \cdot \left(z - t\right) + t\\
\mathbf{if}\;y \leq -2 \cdot 10^{+36}:\\
\;\;\;\;t_1\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.0
Target2.3
Herbie1.6
\[\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 < -2.00000000000000008e36 or 1.99999999999999984e81 < y

    1. Initial program 1.3

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

    if -2.00000000000000008e36 < y < 1.99999999999999984e81

    1. Initial program 2.8

      \[\frac{x}{y} \cdot \left(z - t\right) + t \]
    2. Taylor expanded in z around 0 1.9

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

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

      [Start]1.9

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

      rational.json-simplify-1 [=>]1.9

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

      rational.json-simplify-2 [=>]1.9

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

      rational.json-simplify-9 [=>]1.9

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

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

Alternatives

Alternative 1
Error23.5
Cost1424
\[\begin{array}{l} t_1 := \frac{z \cdot x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -2000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 4 \cdot 10^{-77}:\\ \;\;\;\;t\\ \mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{+131}:\\ \;\;\;\;t \cdot \left(-\frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error18.3
Cost976
\[\begin{array}{l} t_1 := \frac{z \cdot x}{y}\\ t_2 := t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{if}\;t \leq -1.2 \cdot 10^{-117}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.4 \cdot 10^{-173}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.75 \cdot 10^{-101}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{-80}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error26.7
Cost848
\[\begin{array}{l} t_1 := \frac{z \cdot x}{y}\\ \mathbf{if}\;t \leq -1 \cdot 10^{-83}:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq 1.85 \cdot 10^{-173}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.9 \cdot 10^{-106}:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq 8.8 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 4
Error2.0
Cost840
\[\begin{array}{l} t_1 := \frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{if}\;t \leq -1.95 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.6 \cdot 10^{-263}:\\ \;\;\;\;\frac{z - t}{y} \cdot x + t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error1.6
Cost840
\[\begin{array}{l} t_1 := \frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{if}\;y \leq -1.2 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+81}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot x}{y} + t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error10.2
Cost712
\[\begin{array}{l} t_1 := \frac{z}{y} \cdot x + t\\ \mathbf{if}\;z \leq -1.65 \cdot 10^{-133}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-130}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error10.3
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{-134}:\\ \;\;\;\;\frac{z}{y} \cdot x + t\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-128}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot x}{y} + t\\ \end{array} \]
Alternative 8
Error11.0
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{-132}:\\ \;\;\;\;\frac{z}{y} \cdot x + t\\ \mathbf{elif}\;z \leq 9.6 \cdot 10^{-129}:\\ \;\;\;\;t - \frac{t \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot x}{y} + t\\ \end{array} \]
Alternative 9
Error2.0
Cost576
\[\frac{x}{y} \cdot \left(z - t\right) + t \]
Alternative 10
Error31.6
Cost64
\[t \]

Error

Reproduce?

herbie shell --seed 2023077 
(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))