?

Average Error: 3.3 → 1.1
Time: 14.0s
Precision: binary64
Cost: 1224

?

\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;t \leq -4.05 \cdot 10^{+37}:\\ \;\;\;\;t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 4.3 \cdot 10^{-225}:\\ \;\;\;\;x + \frac{-0.3333333333333333 \cdot \left(y - \frac{t}{y}\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{t}{z \cdot 3}}{y}\\ \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- x (/ y (* z 3.0)))))
   (if (<= t -4.05e+37)
     (+ t_1 (/ t (* y (* z 3.0))))
     (if (<= t 4.3e-225)
       (+ x (/ (* -0.3333333333333333 (- y (/ t y))) z))
       (+ t_1 (/ (/ t (* z 3.0)) y))))))
double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
	double t_1 = x - (y / (z * 3.0));
	double tmp;
	if (t <= -4.05e+37) {
		tmp = t_1 + (t / (y * (z * 3.0)));
	} else if (t <= 4.3e-225) {
		tmp = x + ((-0.3333333333333333 * (y - (t / y))) / z);
	} else {
		tmp = t_1 + ((t / (z * 3.0)) / y);
	}
	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 * 3.0d0))) + (t / ((z * 3.0d0) * y))
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 * 3.0d0))
    if (t <= (-4.05d+37)) then
        tmp = t_1 + (t / (y * (z * 3.0d0)))
    else if (t <= 4.3d-225) then
        tmp = x + (((-0.3333333333333333d0) * (y - (t / y))) / z)
    else
        tmp = t_1 + ((t / (z * 3.0d0)) / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x - (y / (z * 3.0));
	double tmp;
	if (t <= -4.05e+37) {
		tmp = t_1 + (t / (y * (z * 3.0)));
	} else if (t <= 4.3e-225) {
		tmp = x + ((-0.3333333333333333 * (y - (t / y))) / z);
	} else {
		tmp = t_1 + ((t / (z * 3.0)) / y);
	}
	return tmp;
}
def code(x, y, z, t):
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
def code(x, y, z, t):
	t_1 = x - (y / (z * 3.0))
	tmp = 0
	if t <= -4.05e+37:
		tmp = t_1 + (t / (y * (z * 3.0)))
	elif t <= 4.3e-225:
		tmp = x + ((-0.3333333333333333 * (y - (t / y))) / z)
	else:
		tmp = t_1 + ((t / (z * 3.0)) / y)
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y)))
end
function code(x, y, z, t)
	t_1 = Float64(x - Float64(y / Float64(z * 3.0)))
	tmp = 0.0
	if (t <= -4.05e+37)
		tmp = Float64(t_1 + Float64(t / Float64(y * Float64(z * 3.0))));
	elseif (t <= 4.3e-225)
		tmp = Float64(x + Float64(Float64(-0.3333333333333333 * Float64(y - Float64(t / y))) / z));
	else
		tmp = Float64(t_1 + Float64(Float64(t / Float64(z * 3.0)) / y));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
end
function tmp_2 = code(x, y, z, t)
	t_1 = x - (y / (z * 3.0));
	tmp = 0.0;
	if (t <= -4.05e+37)
		tmp = t_1 + (t / (y * (z * 3.0)));
	elseif (t <= 4.3e-225)
		tmp = x + ((-0.3333333333333333 * (y - (t / y))) / z);
	else
		tmp = t_1 + ((t / (z * 3.0)) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -4.05e+37], N[(t$95$1 + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 4.3e-225], N[(x + N[(N[(-0.3333333333333333 * N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(t / N[(z * 3.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;t \leq -4.05 \cdot 10^{+37}:\\
\;\;\;\;t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\

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

\mathbf{else}:\\
\;\;\;\;t_1 + \frac{\frac{t}{z \cdot 3}}{y}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.3
Target1.8
Herbie1.1
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y} \]

Derivation?

  1. Split input into 3 regimes
  2. if t < -4.05000000000000003e37

    1. Initial program 0.8

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

    if -4.05000000000000003e37 < t < 4.29999999999999979e-225

    1. Initial program 5.5

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

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

      [Start]5.5

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

      associate-+l- [=>]5.5

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

      sub-neg [=>]5.5

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

      neg-mul-1 [=>]5.5

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

      distribute-lft-out-- [<=]5.5

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

      associate-*r/ [=>]5.5

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

      associate-*l/ [<=]5.5

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

      associate-*r/ [=>]5.5

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

      times-frac [=>]0.4

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

      distribute-lft-out-- [=>]0.4

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

      *-commutative [=>]0.4

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

      associate-/r* [=>]0.4

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

      metadata-eval [=>]0.4

      \[ x + \frac{\color{blue}{-0.3333333333333333}}{z} \cdot \left(y - \frac{t}{y}\right) \]
    3. Applied egg-rr0.4

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

    if 4.29999999999999979e-225 < t

    1. Initial program 2.3

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

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

      [Start]2.3

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

      associate-/r* [=>]1.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -4.05 \cdot 10^{+37}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 4.3 \cdot 10^{-225}:\\ \;\;\;\;x + \frac{-0.3333333333333333 \cdot \left(y - \frac{t}{y}\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error1.7
Cost1224
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;t \leq -5 \cdot 10^{-105}:\\ \;\;\;\;t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 2.25 \cdot 10^{+157}:\\ \;\;\;\;x + \frac{\frac{y - \frac{t}{y}}{z}}{-3}\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{\frac{t}{z} \cdot 0.3333333333333333}{y}\\ \end{array} \]
Alternative 2
Error17.0
Cost976
\[\begin{array}{l} t_1 := \frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ t_2 := x + y \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{if}\;y \leq -5 \cdot 10^{-78}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -9.2 \cdot 10^{-209}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-303}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error16.9
Cost976
\[\begin{array}{l} t_1 := \frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ t_2 := x + \frac{y}{\frac{z}{-0.3333333333333333}}\\ \mathbf{if}\;y \leq -3.1 \cdot 10^{-77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-221}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{-300}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error17.1
Cost976
\[\begin{array}{l} t_1 := \frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{if}\;y \leq -2.4 \cdot 10^{-76}:\\ \;\;\;\;x + \frac{y}{\frac{z}{-0.3333333333333333}}\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{-193}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{-300}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \end{array} \]
Alternative 5
Error16.9
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-78}:\\ \;\;\;\;x + \frac{y}{\frac{z}{-0.3333333333333333}}\\ \mathbf{elif}\;y \leq -9.6 \cdot 10^{-222}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{\frac{z}{t}}}{y}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-302}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{-119}:\\ \;\;\;\;\frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \end{array} \]
Alternative 6
Error3.0
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq 8.2 \cdot 10^{-303} \lor \neg \left(y \leq 4.5 \cdot 10^{-76}\right):\\ \;\;\;\;x + \left(y - \frac{t}{y}\right) \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{z}}{y \cdot 3}\\ \end{array} \]
Alternative 7
Error3.0
Cost968
\[\begin{array}{l} t_1 := y - \frac{t}{y}\\ \mathbf{if}\;y \leq 3.5 \cdot 10^{-302}:\\ \;\;\;\;x + t_1 \cdot \frac{-0.3333333333333333}{z}\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{-67}:\\ \;\;\;\;x + \frac{\frac{t}{z}}{y \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-0.3333333333333333 \cdot t_1}{z}\\ \end{array} \]
Alternative 8
Error2.9
Cost968
\[\begin{array}{l} t_1 := y - \frac{t}{y}\\ \mathbf{if}\;y \leq 5.5 \cdot 10^{-303}:\\ \;\;\;\;x + \frac{\frac{t_1}{z}}{-3}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-67}:\\ \;\;\;\;x + \frac{\frac{t}{z}}{y \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-0.3333333333333333 \cdot t_1}{z}\\ \end{array} \]
Alternative 9
Error6.5
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{-8} \lor \neg \left(y \leq 1.3 \cdot 10^{+70}\right):\\ \;\;\;\;x + \frac{y}{\frac{z}{-0.3333333333333333}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \end{array} \]
Alternative 10
Error31.6
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.05 \cdot 10^{-149}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-75}:\\ \;\;\;\;0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error31.8
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{-144}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-75}:\\ \;\;\;\;\frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error31.3
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{-142}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.4 \cdot 10^{-75}:\\ \;\;\;\;\frac{t}{z} \cdot \frac{0.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error37.6
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023031 
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, H"
  :precision binary64

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

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