Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H

Percentage Accurate: 95.9% → 97.6%
Time: 9.4s
Alternatives: 13
Speedup: 0.9×

Specification

?
\[\begin{array}{l} \\ \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (- x (/ y (* z 3.0))) (/ 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));
}
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
public static double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
def code(x, y, z, t):
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
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 tmp = code(x, y, z, t)
	tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
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]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 95.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (- x (/ y (* z 3.0))) (/ 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));
}
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
public static double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
def code(x, y, z, t):
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
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 tmp = code(x, y, z, t)
	tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
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]
\begin{array}{l}

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

Alternative 1: 97.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -3.45 \cdot 10^{+28}:\\ \;\;\;\;x + \mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, \frac{t}{3 \cdot \left(y \cdot z\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{y} - y}{z \cdot 3}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= t -3.45e+28)
   (+ x (fma -0.3333333333333333 (/ y z) (/ t (* 3.0 (* y z)))))
   (+ x (/ (- (/ t y) y) (* z 3.0)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -3.45e+28) {
		tmp = x + fma(-0.3333333333333333, (y / z), (t / (3.0 * (y * z))));
	} else {
		tmp = x + (((t / y) - y) / (z * 3.0));
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -3.45e+28)
		tmp = Float64(x + fma(-0.3333333333333333, Float64(y / z), Float64(t / Float64(3.0 * Float64(y * z)))));
	else
		tmp = Float64(x + Float64(Float64(Float64(t / y) - y) / Float64(z * 3.0)));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[t, -3.45e+28], N[(x + N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + N[(t / N[(3.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.45 \cdot 10^{+28}:\\
\;\;\;\;x + \mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, \frac{t}{3 \cdot \left(y \cdot z\right)}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.45e28

    1. Initial program 99.8%

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
    2. Step-by-step derivation
      1. sub-neg99.8%

        \[\leadsto \color{blue}{\left(x + \left(-\frac{y}{z \cdot 3}\right)\right)} + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
      2. associate-+l+99.8%

        \[\leadsto \color{blue}{x + \left(\left(-\frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\right)} \]
      3. remove-double-neg99.8%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} + \left(\left(-\frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\right) \]
      4. neg-mul-199.8%

        \[\leadsto \color{blue}{-1 \cdot \left(-x\right)} + \left(\left(-\frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\right) \]
      5. *-lft-identity99.8%

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

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

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

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

        \[\leadsto -1 \cdot \left(-x\right) + \left(\left(-\frac{y}{z \cdot 3}\right) + \frac{-t}{\color{blue}{-\left(z \cdot 3\right) \cdot y}}\right) \]
      10. distribute-rgt-neg-out99.8%

        \[\leadsto -1 \cdot \left(-x\right) + \left(\left(-\frac{y}{z \cdot 3}\right) + \frac{-t}{\color{blue}{\left(z \cdot 3\right) \cdot \left(-y\right)}}\right) \]
      11. distribute-neg-frac99.8%

        \[\leadsto -1 \cdot \left(-x\right) + \left(\left(-\frac{y}{z \cdot 3}\right) + \color{blue}{\left(-\frac{t}{\left(z \cdot 3\right) \cdot \left(-y\right)}\right)}\right) \]
      12. distribute-neg-out99.8%

        \[\leadsto -1 \cdot \left(-x\right) + \color{blue}{\left(-\left(\frac{y}{z \cdot 3} + \frac{t}{\left(z \cdot 3\right) \cdot \left(-y\right)}\right)\right)} \]
      13. neg-mul-199.8%

        \[\leadsto -1 \cdot \left(-x\right) + \color{blue}{-1 \cdot \left(\frac{y}{z \cdot 3} + \frac{t}{\left(z \cdot 3\right) \cdot \left(-y\right)}\right)} \]
      14. distribute-lft-out99.8%

        \[\leadsto \color{blue}{-1 \cdot \left(\left(-x\right) + \left(\frac{y}{z \cdot 3} + \frac{t}{\left(z \cdot 3\right) \cdot \left(-y\right)}\right)\right)} \]
      15. neg-mul-199.8%

        \[\leadsto \color{blue}{-\left(\left(-x\right) + \left(\frac{y}{z \cdot 3} + \frac{t}{\left(z \cdot 3\right) \cdot \left(-y\right)}\right)\right)} \]
      16. distribute-neg-out99.8%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right) + \left(-\left(\frac{y}{z \cdot 3} + \frac{t}{\left(z \cdot 3\right) \cdot \left(-y\right)}\right)\right)} \]
      17. remove-double-neg99.8%

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, \frac{t}{y \cdot \left(z \cdot 3\right)}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 99.9%

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

    if -3.45e28 < t

    1. Initial program 93.1%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-2neg99.2%

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

        \[\leadsto x + \frac{\color{blue}{-0.3333333333333333}}{-z} \cdot \left(\frac{t}{y} - y\right) \]
      3. clear-num99.2%

        \[\leadsto x + \color{blue}{\frac{1}{\frac{-z}{-0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
      4. metadata-eval99.2%

        \[\leadsto x + \frac{1}{\frac{-z}{\color{blue}{-0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
      5. frac-2neg99.2%

        \[\leadsto x + \frac{1}{\color{blue}{\frac{z}{0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
      6. div-inv99.2%

        \[\leadsto x + \frac{1}{\color{blue}{z \cdot \frac{1}{0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
      7. metadata-eval99.2%

        \[\leadsto x + \frac{1}{z \cdot \color{blue}{3}} \cdot \left(\frac{t}{y} - y\right) \]
      8. associate-*l/99.3%

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

        \[\leadsto x + \frac{\color{blue}{\frac{t}{y} - y}}{z \cdot 3} \]
    5. Applied egg-rr99.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -3.45 \cdot 10^{+28}:\\ \;\;\;\;x + \mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, \frac{t}{3 \cdot \left(y \cdot z\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{y} - y}{z \cdot 3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 97.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1 \cdot 10^{-22}:\\
\;\;\;\;\frac{t}{z \cdot \left(y \cdot 3\right)} + \left(x - \frac{y}{z \cdot 3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1e-22

    1. Initial program 99.8%

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
    2. Step-by-step derivation
      1. associate-*l*99.8%

        \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\color{blue}{z \cdot \left(3 \cdot y\right)}} \]
      2. *-commutative99.8%

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

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

    if -1e-22 < t

    1. Initial program 92.8%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-2neg99.2%

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

        \[\leadsto x + \frac{\color{blue}{-0.3333333333333333}}{-z} \cdot \left(\frac{t}{y} - y\right) \]
      3. clear-num99.2%

        \[\leadsto x + \color{blue}{\frac{1}{\frac{-z}{-0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
      4. metadata-eval99.2%

        \[\leadsto x + \frac{1}{\frac{-z}{\color{blue}{-0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
      5. frac-2neg99.2%

        \[\leadsto x + \frac{1}{\color{blue}{\frac{z}{0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
      6. div-inv99.2%

        \[\leadsto x + \frac{1}{\color{blue}{z \cdot \frac{1}{0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
      7. metadata-eval99.2%

        \[\leadsto x + \frac{1}{z \cdot \color{blue}{3}} \cdot \left(\frac{t}{y} - y\right) \]
      8. associate-*l/99.3%

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

        \[\leadsto x + \frac{\color{blue}{\frac{t}{y} - y}}{z \cdot 3} \]
    5. Applied egg-rr99.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{t}{z \cdot \left(y \cdot 3\right)} + \left(x - \frac{y}{z \cdot 3}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{t}{y} - y}{z \cdot 3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 89.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+40}:\\
\;\;\;\;x + \frac{\frac{y}{-3}}{z}\\

\mathbf{elif}\;y \leq 2.2 \cdot 10^{+31}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y}{z \cdot 3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.8000000000000002e40

    1. Initial program 97.5%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in z around 0 99.7%

      \[\leadsto x + \color{blue}{0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z}} \]
    5. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto x + \color{blue}{\frac{\frac{t}{y} - y}{z} \cdot 0.3333333333333333} \]
      2. metadata-eval99.7%

        \[\leadsto x + \frac{\frac{t}{y} - y}{z} \cdot \color{blue}{\frac{1}{3}} \]
      3. div-inv99.8%

        \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}} \]
    6. Applied egg-rr99.8%

      \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}} \]
    7. Taylor expanded in t around 0 95.3%

      \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
    8. Step-by-step derivation
      1. *-commutative95.3%

        \[\leadsto x + \color{blue}{\frac{y}{z} \cdot -0.3333333333333333} \]
      2. metadata-eval95.3%

        \[\leadsto x + \frac{y}{z} \cdot \color{blue}{\frac{1}{-3}} \]
      3. times-frac95.3%

        \[\leadsto x + \color{blue}{\frac{y \cdot 1}{z \cdot -3}} \]
      4. *-rgt-identity95.3%

        \[\leadsto x + \frac{\color{blue}{y}}{z \cdot -3} \]
      5. *-commutative95.3%

        \[\leadsto x + \frac{y}{\color{blue}{-3 \cdot z}} \]
      6. associate-/r*95.4%

        \[\leadsto x + \color{blue}{\frac{\frac{y}{-3}}{z}} \]
    9. Simplified95.4%

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

    if -7.8000000000000002e40 < y < 2.2000000000000001e31

    1. Initial program 91.7%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around inf 85.2%

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

    if 2.2000000000000001e31 < y

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 98.2%

      \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
    5. Step-by-step derivation
      1. *-commutative98.2%

        \[\leadsto x + \color{blue}{\frac{y}{z} \cdot -0.3333333333333333} \]
      2. associate-*l/98.2%

        \[\leadsto x + \color{blue}{\frac{y \cdot -0.3333333333333333}{z}} \]
      3. associate-*r/98.2%

        \[\leadsto x + \color{blue}{y \cdot \frac{-0.3333333333333333}{z}} \]
    6. Simplified98.2%

      \[\leadsto x + \color{blue}{y \cdot \frac{-0.3333333333333333}{z}} \]
    7. Step-by-step derivation
      1. associate-*r/98.2%

        \[\leadsto x + \color{blue}{\frac{y \cdot -0.3333333333333333}{z}} \]
      2. associate-/l*98.3%

        \[\leadsto x + \color{blue}{\frac{y}{\frac{z}{-0.3333333333333333}}} \]
      3. clear-num98.2%

        \[\leadsto x + \frac{y}{\color{blue}{\frac{1}{\frac{-0.3333333333333333}{z}}}} \]
      4. add-sqr-sqrt59.4%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z}} \cdot \sqrt{\frac{-0.3333333333333333}{z}}}}} \]
      5. sqrt-unprod60.2%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z} \cdot \frac{-0.3333333333333333}{z}}}}} \]
      6. frac-times60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\color{blue}{\frac{-0.3333333333333333 \cdot -0.3333333333333333}{z \cdot z}}}}} \]
      7. metadata-eval60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\frac{\color{blue}{0.1111111111111111}}{z \cdot z}}}} \]
      8. metadata-eval60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\frac{\color{blue}{0.3333333333333333 \cdot 0.3333333333333333}}{z \cdot z}}}} \]
      9. frac-times60.2%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\color{blue}{\frac{0.3333333333333333}{z} \cdot \frac{0.3333333333333333}{z}}}}} \]
      10. sqrt-unprod6.7%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{0.3333333333333333}{z}} \cdot \sqrt{\frac{0.3333333333333333}{z}}}}} \]
      11. add-sqr-sqrt22.2%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\frac{0.3333333333333333}{z}}}} \]
      12. clear-num22.2%

        \[\leadsto x + \frac{y}{\color{blue}{\frac{z}{0.3333333333333333}}} \]
      13. div-inv22.2%

        \[\leadsto x + \frac{y}{\color{blue}{z \cdot \frac{1}{0.3333333333333333}}} \]
      14. metadata-eval22.2%

        \[\leadsto x + \frac{y}{z \cdot \color{blue}{3}} \]
      15. frac-2neg22.2%

        \[\leadsto x + \color{blue}{\frac{-y}{-z \cdot 3}} \]
      16. distribute-rgt-neg-in22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{z \cdot \left(-3\right)}} \]
      17. metadata-eval22.2%

        \[\leadsto x + \frac{-y}{z \cdot \color{blue}{-3}} \]
      18. metadata-eval22.2%

        \[\leadsto x + \frac{-y}{z \cdot \color{blue}{\frac{1}{-0.3333333333333333}}} \]
      19. div-inv22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{\frac{z}{-0.3333333333333333}}} \]
      20. clear-num22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{\frac{1}{\frac{-0.3333333333333333}{z}}}} \]
      21. add-sqr-sqrt15.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z}} \cdot \sqrt{\frac{-0.3333333333333333}{z}}}}} \]
      22. sqrt-unprod49.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z} \cdot \frac{-0.3333333333333333}{z}}}}} \]
      23. frac-times49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\color{blue}{\frac{-0.3333333333333333 \cdot -0.3333333333333333}{z \cdot z}}}}} \]
      24. metadata-eval49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\frac{\color{blue}{0.1111111111111111}}{z \cdot z}}}} \]
      25. metadata-eval49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\frac{\color{blue}{0.3333333333333333 \cdot 0.3333333333333333}}{z \cdot z}}}} \]
      26. frac-times49.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\color{blue}{\frac{0.3333333333333333}{z} \cdot \frac{0.3333333333333333}{z}}}}} \]
      27. sqrt-unprod38.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{0.3333333333333333}{z}} \cdot \sqrt{\frac{0.3333333333333333}{z}}}}} \]
      28. add-sqr-sqrt98.2%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\frac{0.3333333333333333}{z}}}} \]
    8. Applied egg-rr98.4%

      \[\leadsto x + \color{blue}{\frac{-y}{z \cdot 3}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.8 \cdot 10^{+40}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+31}:\\ \;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{z \cdot 3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 88.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+46}:\\
\;\;\;\;x + \frac{\frac{y}{-3}}{z}\\

\mathbf{elif}\;y \leq 1.02 \cdot 10^{+32}:\\
\;\;\;\;x + \frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y}{z \cdot 3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.9999999999999997e46

    1. Initial program 97.5%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in z around 0 99.7%

      \[\leadsto x + \color{blue}{0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z}} \]
    5. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto x + \color{blue}{\frac{\frac{t}{y} - y}{z} \cdot 0.3333333333333333} \]
      2. metadata-eval99.7%

        \[\leadsto x + \frac{\frac{t}{y} - y}{z} \cdot \color{blue}{\frac{1}{3}} \]
      3. div-inv99.8%

        \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}} \]
    6. Applied egg-rr99.8%

      \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}} \]
    7. Taylor expanded in t around 0 95.3%

      \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
    8. Step-by-step derivation
      1. *-commutative95.3%

        \[\leadsto x + \color{blue}{\frac{y}{z} \cdot -0.3333333333333333} \]
      2. metadata-eval95.3%

        \[\leadsto x + \frac{y}{z} \cdot \color{blue}{\frac{1}{-3}} \]
      3. times-frac95.3%

        \[\leadsto x + \color{blue}{\frac{y \cdot 1}{z \cdot -3}} \]
      4. *-rgt-identity95.3%

        \[\leadsto x + \frac{\color{blue}{y}}{z \cdot -3} \]
      5. *-commutative95.3%

        \[\leadsto x + \frac{y}{\color{blue}{-3 \cdot z}} \]
      6. associate-/r*95.4%

        \[\leadsto x + \color{blue}{\frac{\frac{y}{-3}}{z}} \]
    9. Simplified95.4%

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

    if -6.9999999999999997e46 < y < 1.0199999999999999e32

    1. Initial program 91.7%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around inf 86.5%

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

    if 1.0199999999999999e32 < y

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 98.2%

      \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
    5. Step-by-step derivation
      1. *-commutative98.2%

        \[\leadsto x + \color{blue}{\frac{y}{z} \cdot -0.3333333333333333} \]
      2. associate-*l/98.2%

        \[\leadsto x + \color{blue}{\frac{y \cdot -0.3333333333333333}{z}} \]
      3. associate-*r/98.2%

        \[\leadsto x + \color{blue}{y \cdot \frac{-0.3333333333333333}{z}} \]
    6. Simplified98.2%

      \[\leadsto x + \color{blue}{y \cdot \frac{-0.3333333333333333}{z}} \]
    7. Step-by-step derivation
      1. associate-*r/98.2%

        \[\leadsto x + \color{blue}{\frac{y \cdot -0.3333333333333333}{z}} \]
      2. associate-/l*98.3%

        \[\leadsto x + \color{blue}{\frac{y}{\frac{z}{-0.3333333333333333}}} \]
      3. clear-num98.2%

        \[\leadsto x + \frac{y}{\color{blue}{\frac{1}{\frac{-0.3333333333333333}{z}}}} \]
      4. add-sqr-sqrt59.4%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z}} \cdot \sqrt{\frac{-0.3333333333333333}{z}}}}} \]
      5. sqrt-unprod60.2%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z} \cdot \frac{-0.3333333333333333}{z}}}}} \]
      6. frac-times60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\color{blue}{\frac{-0.3333333333333333 \cdot -0.3333333333333333}{z \cdot z}}}}} \]
      7. metadata-eval60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\frac{\color{blue}{0.1111111111111111}}{z \cdot z}}}} \]
      8. metadata-eval60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\frac{\color{blue}{0.3333333333333333 \cdot 0.3333333333333333}}{z \cdot z}}}} \]
      9. frac-times60.2%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\color{blue}{\frac{0.3333333333333333}{z} \cdot \frac{0.3333333333333333}{z}}}}} \]
      10. sqrt-unprod6.7%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{0.3333333333333333}{z}} \cdot \sqrt{\frac{0.3333333333333333}{z}}}}} \]
      11. add-sqr-sqrt22.2%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\frac{0.3333333333333333}{z}}}} \]
      12. clear-num22.2%

        \[\leadsto x + \frac{y}{\color{blue}{\frac{z}{0.3333333333333333}}} \]
      13. div-inv22.2%

        \[\leadsto x + \frac{y}{\color{blue}{z \cdot \frac{1}{0.3333333333333333}}} \]
      14. metadata-eval22.2%

        \[\leadsto x + \frac{y}{z \cdot \color{blue}{3}} \]
      15. frac-2neg22.2%

        \[\leadsto x + \color{blue}{\frac{-y}{-z \cdot 3}} \]
      16. distribute-rgt-neg-in22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{z \cdot \left(-3\right)}} \]
      17. metadata-eval22.2%

        \[\leadsto x + \frac{-y}{z \cdot \color{blue}{-3}} \]
      18. metadata-eval22.2%

        \[\leadsto x + \frac{-y}{z \cdot \color{blue}{\frac{1}{-0.3333333333333333}}} \]
      19. div-inv22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{\frac{z}{-0.3333333333333333}}} \]
      20. clear-num22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{\frac{1}{\frac{-0.3333333333333333}{z}}}} \]
      21. add-sqr-sqrt15.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z}} \cdot \sqrt{\frac{-0.3333333333333333}{z}}}}} \]
      22. sqrt-unprod49.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z} \cdot \frac{-0.3333333333333333}{z}}}}} \]
      23. frac-times49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\color{blue}{\frac{-0.3333333333333333 \cdot -0.3333333333333333}{z \cdot z}}}}} \]
      24. metadata-eval49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\frac{\color{blue}{0.1111111111111111}}{z \cdot z}}}} \]
      25. metadata-eval49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\frac{\color{blue}{0.3333333333333333 \cdot 0.3333333333333333}}{z \cdot z}}}} \]
      26. frac-times49.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\color{blue}{\frac{0.3333333333333333}{z} \cdot \frac{0.3333333333333333}{z}}}}} \]
      27. sqrt-unprod38.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{0.3333333333333333}{z}} \cdot \sqrt{\frac{0.3333333333333333}{z}}}}} \]
      28. add-sqr-sqrt98.2%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\frac{0.3333333333333333}{z}}}} \]
    8. Applied egg-rr98.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+46}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{+32}:\\ \;\;\;\;x + \frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{z \cdot 3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+43}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{+32}:\\ \;\;\;\;x + \frac{\frac{t}{y}}{z \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{z \cdot 3}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y -6e+43)
   (+ x (/ (/ y -3.0) z))
   (if (<= y 1.22e+32) (+ x (/ (/ t y) (* z 3.0))) (- x (/ y (* z 3.0))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -6e+43) {
		tmp = x + ((y / -3.0) / z);
	} else if (y <= 1.22e+32) {
		tmp = x + ((t / y) / (z * 3.0));
	} else {
		tmp = x - (y / (z * 3.0));
	}
	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
    real(8) :: tmp
    if (y <= (-6d+43)) then
        tmp = x + ((y / (-3.0d0)) / z)
    else if (y <= 1.22d+32) then
        tmp = x + ((t / y) / (z * 3.0d0))
    else
        tmp = x - (y / (z * 3.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -6e+43) {
		tmp = x + ((y / -3.0) / z);
	} else if (y <= 1.22e+32) {
		tmp = x + ((t / y) / (z * 3.0));
	} else {
		tmp = x - (y / (z * 3.0));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= -6e+43:
		tmp = x + ((y / -3.0) / z)
	elif y <= 1.22e+32:
		tmp = x + ((t / y) / (z * 3.0))
	else:
		tmp = x - (y / (z * 3.0))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -6e+43)
		tmp = Float64(x + Float64(Float64(y / -3.0) / z));
	elseif (y <= 1.22e+32)
		tmp = Float64(x + Float64(Float64(t / y) / Float64(z * 3.0)));
	else
		tmp = Float64(x - Float64(y / Float64(z * 3.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= -6e+43)
		tmp = x + ((y / -3.0) / z);
	elseif (y <= 1.22e+32)
		tmp = x + ((t / y) / (z * 3.0));
	else
		tmp = x - (y / (z * 3.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, -6e+43], N[(x + N[(N[(y / -3.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.22e+32], N[(x + N[(N[(t / y), $MachinePrecision] / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+43}:\\
\;\;\;\;x + \frac{\frac{y}{-3}}{z}\\

\mathbf{elif}\;y \leq 1.22 \cdot 10^{+32}:\\
\;\;\;\;x + \frac{\frac{t}{y}}{z \cdot 3}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y}{z \cdot 3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.00000000000000033e43

    1. Initial program 97.5%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in z around 0 99.7%

      \[\leadsto x + \color{blue}{0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z}} \]
    5. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto x + \color{blue}{\frac{\frac{t}{y} - y}{z} \cdot 0.3333333333333333} \]
      2. metadata-eval99.7%

        \[\leadsto x + \frac{\frac{t}{y} - y}{z} \cdot \color{blue}{\frac{1}{3}} \]
      3. div-inv99.8%

        \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}} \]
    6. Applied egg-rr99.8%

      \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}} \]
    7. Taylor expanded in t around 0 95.3%

      \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
    8. Step-by-step derivation
      1. *-commutative95.3%

        \[\leadsto x + \color{blue}{\frac{y}{z} \cdot -0.3333333333333333} \]
      2. metadata-eval95.3%

        \[\leadsto x + \frac{y}{z} \cdot \color{blue}{\frac{1}{-3}} \]
      3. times-frac95.3%

        \[\leadsto x + \color{blue}{\frac{y \cdot 1}{z \cdot -3}} \]
      4. *-rgt-identity95.3%

        \[\leadsto x + \frac{\color{blue}{y}}{z \cdot -3} \]
      5. *-commutative95.3%

        \[\leadsto x + \frac{y}{\color{blue}{-3 \cdot z}} \]
      6. associate-/r*95.4%

        \[\leadsto x + \color{blue}{\frac{\frac{y}{-3}}{z}} \]
    9. Simplified95.4%

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

    if -6.00000000000000033e43 < y < 1.22000000000000002e32

    1. Initial program 91.7%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around inf 85.2%

      \[\leadsto x + \color{blue}{0.3333333333333333 \cdot \frac{t}{y \cdot z}} \]
    5. Step-by-step derivation
      1. associate-/r*86.5%

        \[\leadsto x + 0.3333333333333333 \cdot \color{blue}{\frac{\frac{t}{y}}{z}} \]
      2. associate-*r/86.5%

        \[\leadsto x + \color{blue}{\frac{0.3333333333333333 \cdot \frac{t}{y}}{z}} \]
      3. associate-*l/86.5%

        \[\leadsto x + \color{blue}{\frac{0.3333333333333333}{z} \cdot \frac{t}{y}} \]
      4. associate-*r/91.4%

        \[\leadsto x + \color{blue}{\frac{\frac{0.3333333333333333}{z} \cdot t}{y}} \]
      5. associate-*l/83.7%

        \[\leadsto x + \color{blue}{\frac{\frac{0.3333333333333333}{z}}{y} \cdot t} \]
      6. *-commutative83.7%

        \[\leadsto x + \color{blue}{t \cdot \frac{\frac{0.3333333333333333}{z}}{y}} \]
    6. Simplified83.7%

      \[\leadsto x + \color{blue}{t \cdot \frac{\frac{0.3333333333333333}{z}}{y}} \]
    7. Step-by-step derivation
      1. associate-*r/91.4%

        \[\leadsto x + \color{blue}{\frac{t \cdot \frac{0.3333333333333333}{z}}{y}} \]
      2. *-un-lft-identity91.4%

        \[\leadsto x + \frac{t \cdot \frac{0.3333333333333333}{z}}{\color{blue}{1 \cdot y}} \]
      3. times-frac83.7%

        \[\leadsto x + \color{blue}{\frac{t}{1} \cdot \frac{\frac{0.3333333333333333}{z}}{y}} \]
      4. div-inv83.7%

        \[\leadsto x + \frac{t}{1} \cdot \color{blue}{\left(\frac{0.3333333333333333}{z} \cdot \frac{1}{y}\right)} \]
      5. metadata-eval83.7%

        \[\leadsto x + \frac{t}{1} \cdot \left(\frac{\color{blue}{\frac{1}{3}}}{z} \cdot \frac{1}{y}\right) \]
      6. associate-/r*83.6%

        \[\leadsto x + \frac{t}{1} \cdot \left(\color{blue}{\frac{1}{3 \cdot z}} \cdot \frac{1}{y}\right) \]
      7. *-commutative83.6%

        \[\leadsto x + \frac{t}{1} \cdot \left(\frac{1}{\color{blue}{z \cdot 3}} \cdot \frac{1}{y}\right) \]
      8. associate-*l/83.7%

        \[\leadsto x + \frac{t}{1} \cdot \color{blue}{\frac{1 \cdot \frac{1}{y}}{z \cdot 3}} \]
      9. *-un-lft-identity83.7%

        \[\leadsto x + \frac{t}{1} \cdot \frac{\color{blue}{\frac{1}{y}}}{z \cdot 3} \]
      10. times-frac86.5%

        \[\leadsto x + \color{blue}{\frac{t \cdot \frac{1}{y}}{1 \cdot \left(z \cdot 3\right)}} \]
      11. div-inv86.5%

        \[\leadsto x + \frac{\color{blue}{\frac{t}{y}}}{1 \cdot \left(z \cdot 3\right)} \]
      12. *-un-lft-identity86.5%

        \[\leadsto x + \frac{\frac{t}{y}}{\color{blue}{z \cdot 3}} \]
    8. Applied egg-rr86.5%

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

    if 1.22000000000000002e32 < y

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in t around 0 98.2%

      \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
    5. Step-by-step derivation
      1. *-commutative98.2%

        \[\leadsto x + \color{blue}{\frac{y}{z} \cdot -0.3333333333333333} \]
      2. associate-*l/98.2%

        \[\leadsto x + \color{blue}{\frac{y \cdot -0.3333333333333333}{z}} \]
      3. associate-*r/98.2%

        \[\leadsto x + \color{blue}{y \cdot \frac{-0.3333333333333333}{z}} \]
    6. Simplified98.2%

      \[\leadsto x + \color{blue}{y \cdot \frac{-0.3333333333333333}{z}} \]
    7. Step-by-step derivation
      1. associate-*r/98.2%

        \[\leadsto x + \color{blue}{\frac{y \cdot -0.3333333333333333}{z}} \]
      2. associate-/l*98.3%

        \[\leadsto x + \color{blue}{\frac{y}{\frac{z}{-0.3333333333333333}}} \]
      3. clear-num98.2%

        \[\leadsto x + \frac{y}{\color{blue}{\frac{1}{\frac{-0.3333333333333333}{z}}}} \]
      4. add-sqr-sqrt59.4%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z}} \cdot \sqrt{\frac{-0.3333333333333333}{z}}}}} \]
      5. sqrt-unprod60.2%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z} \cdot \frac{-0.3333333333333333}{z}}}}} \]
      6. frac-times60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\color{blue}{\frac{-0.3333333333333333 \cdot -0.3333333333333333}{z \cdot z}}}}} \]
      7. metadata-eval60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\frac{\color{blue}{0.1111111111111111}}{z \cdot z}}}} \]
      8. metadata-eval60.3%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\frac{\color{blue}{0.3333333333333333 \cdot 0.3333333333333333}}{z \cdot z}}}} \]
      9. frac-times60.2%

        \[\leadsto x + \frac{y}{\frac{1}{\sqrt{\color{blue}{\frac{0.3333333333333333}{z} \cdot \frac{0.3333333333333333}{z}}}}} \]
      10. sqrt-unprod6.7%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\sqrt{\frac{0.3333333333333333}{z}} \cdot \sqrt{\frac{0.3333333333333333}{z}}}}} \]
      11. add-sqr-sqrt22.2%

        \[\leadsto x + \frac{y}{\frac{1}{\color{blue}{\frac{0.3333333333333333}{z}}}} \]
      12. clear-num22.2%

        \[\leadsto x + \frac{y}{\color{blue}{\frac{z}{0.3333333333333333}}} \]
      13. div-inv22.2%

        \[\leadsto x + \frac{y}{\color{blue}{z \cdot \frac{1}{0.3333333333333333}}} \]
      14. metadata-eval22.2%

        \[\leadsto x + \frac{y}{z \cdot \color{blue}{3}} \]
      15. frac-2neg22.2%

        \[\leadsto x + \color{blue}{\frac{-y}{-z \cdot 3}} \]
      16. distribute-rgt-neg-in22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{z \cdot \left(-3\right)}} \]
      17. metadata-eval22.2%

        \[\leadsto x + \frac{-y}{z \cdot \color{blue}{-3}} \]
      18. metadata-eval22.2%

        \[\leadsto x + \frac{-y}{z \cdot \color{blue}{\frac{1}{-0.3333333333333333}}} \]
      19. div-inv22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{\frac{z}{-0.3333333333333333}}} \]
      20. clear-num22.2%

        \[\leadsto x + \frac{-y}{\color{blue}{\frac{1}{\frac{-0.3333333333333333}{z}}}} \]
      21. add-sqr-sqrt15.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z}} \cdot \sqrt{\frac{-0.3333333333333333}{z}}}}} \]
      22. sqrt-unprod49.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{-0.3333333333333333}{z} \cdot \frac{-0.3333333333333333}{z}}}}} \]
      23. frac-times49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\color{blue}{\frac{-0.3333333333333333 \cdot -0.3333333333333333}{z \cdot z}}}}} \]
      24. metadata-eval49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\frac{\color{blue}{0.1111111111111111}}{z \cdot z}}}} \]
      25. metadata-eval49.5%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\frac{\color{blue}{0.3333333333333333 \cdot 0.3333333333333333}}{z \cdot z}}}} \]
      26. frac-times49.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\sqrt{\color{blue}{\frac{0.3333333333333333}{z} \cdot \frac{0.3333333333333333}{z}}}}} \]
      27. sqrt-unprod38.6%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\sqrt{\frac{0.3333333333333333}{z}} \cdot \sqrt{\frac{0.3333333333333333}{z}}}}} \]
      28. add-sqr-sqrt98.2%

        \[\leadsto x + \frac{-y}{\frac{1}{\color{blue}{\frac{0.3333333333333333}{z}}}} \]
    8. Applied egg-rr98.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+43}:\\ \;\;\;\;x + \frac{\frac{y}{-3}}{z}\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{+32}:\\ \;\;\;\;x + \frac{\frac{t}{y}}{z \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{z \cdot 3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 95.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ x + 0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ x (* 0.3333333333333333 (/ (- (/ t y) y) z))))
double code(double x, double y, double z, double t) {
	return x + (0.3333333333333333 * (((t / y) - y) / z));
}
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 + (0.3333333333333333d0 * (((t / y) - y) / z))
end function
public static double code(double x, double y, double z, double t) {
	return x + (0.3333333333333333 * (((t / y) - y) / z));
}
def code(x, y, z, t):
	return x + (0.3333333333333333 * (((t / y) - y) / z))
function code(x, y, z, t)
	return Float64(x + Float64(0.3333333333333333 * Float64(Float64(Float64(t / y) - y) / z)))
end
function tmp = code(x, y, z, t)
	tmp = x + (0.3333333333333333 * (((t / y) - y) / z));
end
code[x_, y_, z_, t_] := N[(x + N[(0.3333333333333333 * N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + 0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z}
\end{array}
Derivation
  1. Initial program 94.7%

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

    \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in z around 0 96.1%

    \[\leadsto x + \color{blue}{0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z}} \]
  5. Final simplification96.1%

    \[\leadsto x + 0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z} \]
  6. Add Preprocessing

Alternative 7: 95.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ x + \left(\frac{t}{y} - y\right) \cdot \frac{0.3333333333333333}{z} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ x (* (- (/ t y) y) (/ 0.3333333333333333 z))))
double code(double x, double y, double z, double t) {
	return x + (((t / y) - y) * (0.3333333333333333 / z));
}
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 + (((t / y) - y) * (0.3333333333333333d0 / z))
end function
public static double code(double x, double y, double z, double t) {
	return x + (((t / y) - y) * (0.3333333333333333 / z));
}
def code(x, y, z, t):
	return x + (((t / y) - y) * (0.3333333333333333 / z))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(Float64(t / y) - y) * Float64(0.3333333333333333 / z)))
end
function tmp = code(x, y, z, t)
	tmp = x + (((t / y) - y) * (0.3333333333333333 / z));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] * N[(0.3333333333333333 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\frac{t}{y} - y\right) \cdot \frac{0.3333333333333333}{z}
\end{array}
Derivation
  1. Initial program 94.7%

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

    \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
  3. Add Preprocessing
  4. Final simplification96.2%

    \[\leadsto x + \left(\frac{t}{y} - y\right) \cdot \frac{0.3333333333333333}{z} \]
  5. Add Preprocessing

Alternative 8: 95.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ x + \frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ x (/ 0.3333333333333333 (/ z (- (/ t y) y)))))
double code(double x, double y, double z, double t) {
	return x + (0.3333333333333333 / (z / ((t / y) - y)));
}
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 + (0.3333333333333333d0 / (z / ((t / y) - y)))
end function
public static double code(double x, double y, double z, double t) {
	return x + (0.3333333333333333 / (z / ((t / y) - y)));
}
def code(x, y, z, t):
	return x + (0.3333333333333333 / (z / ((t / y) - y)))
function code(x, y, z, t)
	return Float64(x + Float64(0.3333333333333333 / Float64(z / Float64(Float64(t / y) - y))))
end
function tmp = code(x, y, z, t)
	tmp = x + (0.3333333333333333 / (z / ((t / y) - y)));
end
code[x_, y_, z_, t_] := N[(x + N[(0.3333333333333333 / N[(z / N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}}
\end{array}
Derivation
  1. Initial program 94.7%

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

    \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-*l/96.1%

      \[\leadsto x + \color{blue}{\frac{0.3333333333333333 \cdot \left(\frac{t}{y} - y\right)}{z}} \]
    2. associate-/l*96.2%

      \[\leadsto x + \color{blue}{\frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}}} \]
  5. Applied egg-rr96.2%

    \[\leadsto x + \color{blue}{\frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}}} \]
  6. Final simplification96.2%

    \[\leadsto x + \frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}} \]
  7. Add Preprocessing

Alternative 9: 95.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ x + \frac{\frac{t}{y} - y}{z \cdot 3} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (- (/ t y) y) (* z 3.0))))
double code(double x, double y, double z, double t) {
	return x + (((t / y) - y) / (z * 3.0));
}
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 + (((t / y) - y) / (z * 3.0d0))
end function
public static double code(double x, double y, double z, double t) {
	return x + (((t / y) - y) / (z * 3.0));
}
def code(x, y, z, t):
	return x + (((t / y) - y) / (z * 3.0))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(Float64(t / y) - y) / Float64(z * 3.0)))
end
function tmp = code(x, y, z, t)
	tmp = x + (((t / y) - y) / (z * 3.0));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{\frac{t}{y} - y}{z \cdot 3}
\end{array}
Derivation
  1. Initial program 94.7%

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

    \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. frac-2neg96.2%

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

      \[\leadsto x + \frac{\color{blue}{-0.3333333333333333}}{-z} \cdot \left(\frac{t}{y} - y\right) \]
    3. clear-num96.1%

      \[\leadsto x + \color{blue}{\frac{1}{\frac{-z}{-0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
    4. metadata-eval96.1%

      \[\leadsto x + \frac{1}{\frac{-z}{\color{blue}{-0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
    5. frac-2neg96.1%

      \[\leadsto x + \frac{1}{\color{blue}{\frac{z}{0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
    6. div-inv96.2%

      \[\leadsto x + \frac{1}{\color{blue}{z \cdot \frac{1}{0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
    7. metadata-eval96.2%

      \[\leadsto x + \frac{1}{z \cdot \color{blue}{3}} \cdot \left(\frac{t}{y} - y\right) \]
    8. associate-*l/96.2%

      \[\leadsto x + \color{blue}{\frac{1 \cdot \left(\frac{t}{y} - y\right)}{z \cdot 3}} \]
    9. *-un-lft-identity96.2%

      \[\leadsto x + \frac{\color{blue}{\frac{t}{y} - y}}{z \cdot 3} \]
  5. Applied egg-rr96.2%

    \[\leadsto x + \color{blue}{\frac{\frac{t}{y} - y}{z \cdot 3}} \]
  6. Final simplification96.2%

    \[\leadsto x + \frac{\frac{t}{y} - y}{z \cdot 3} \]
  7. Add Preprocessing

Alternative 10: 64.7% accurate, 2.1× speedup?

\[\begin{array}{l} \\ x + y \cdot \frac{-0.3333333333333333}{z} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (* y (/ -0.3333333333333333 z))))
double code(double x, double y, double z, double t) {
	return x + (y * (-0.3333333333333333 / z));
}
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 * ((-0.3333333333333333d0) / z))
end function
public static double code(double x, double y, double z, double t) {
	return x + (y * (-0.3333333333333333 / z));
}
def code(x, y, z, t):
	return x + (y * (-0.3333333333333333 / z))
function code(x, y, z, t)
	return Float64(x + Float64(y * Float64(-0.3333333333333333 / z)))
end
function tmp = code(x, y, z, t)
	tmp = x + (y * (-0.3333333333333333 / z));
end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(-0.3333333333333333 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + y \cdot \frac{-0.3333333333333333}{z}
\end{array}
Derivation
  1. Initial program 94.7%

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

    \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in t around 0 64.9%

    \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
  5. Step-by-step derivation
    1. *-commutative64.9%

      \[\leadsto x + \color{blue}{\frac{y}{z} \cdot -0.3333333333333333} \]
    2. associate-*l/64.9%

      \[\leadsto x + \color{blue}{\frac{y \cdot -0.3333333333333333}{z}} \]
    3. associate-*r/64.9%

      \[\leadsto x + \color{blue}{y \cdot \frac{-0.3333333333333333}{z}} \]
  6. Simplified64.9%

    \[\leadsto x + \color{blue}{y \cdot \frac{-0.3333333333333333}{z}} \]
  7. Final simplification64.9%

    \[\leadsto x + y \cdot \frac{-0.3333333333333333}{z} \]
  8. Add Preprocessing

Alternative 11: 64.7% accurate, 2.1× speedup?

\[\begin{array}{l} \\ x + \frac{-0.3333333333333333}{\frac{z}{y}} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ -0.3333333333333333 (/ z y))))
double code(double x, double y, double z, double t) {
	return x + (-0.3333333333333333 / (z / y));
}
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 + ((-0.3333333333333333d0) / (z / y))
end function
public static double code(double x, double y, double z, double t) {
	return x + (-0.3333333333333333 / (z / y));
}
def code(x, y, z, t):
	return x + (-0.3333333333333333 / (z / y))
function code(x, y, z, t)
	return Float64(x + Float64(-0.3333333333333333 / Float64(z / y)))
end
function tmp = code(x, y, z, t)
	tmp = x + (-0.3333333333333333 / (z / y));
end
code[x_, y_, z_, t_] := N[(x + N[(-0.3333333333333333 / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{-0.3333333333333333}{\frac{z}{y}}
\end{array}
Derivation
  1. Initial program 94.7%

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

    \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. frac-2neg96.2%

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

      \[\leadsto x + \frac{\color{blue}{-0.3333333333333333}}{-z} \cdot \left(\frac{t}{y} - y\right) \]
    3. clear-num96.1%

      \[\leadsto x + \color{blue}{\frac{1}{\frac{-z}{-0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
    4. metadata-eval96.1%

      \[\leadsto x + \frac{1}{\frac{-z}{\color{blue}{-0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
    5. frac-2neg96.1%

      \[\leadsto x + \frac{1}{\color{blue}{\frac{z}{0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
    6. div-inv96.2%

      \[\leadsto x + \frac{1}{\color{blue}{z \cdot \frac{1}{0.3333333333333333}}} \cdot \left(\frac{t}{y} - y\right) \]
    7. metadata-eval96.2%

      \[\leadsto x + \frac{1}{z \cdot \color{blue}{3}} \cdot \left(\frac{t}{y} - y\right) \]
    8. associate-*l/96.2%

      \[\leadsto x + \color{blue}{\frac{1 \cdot \left(\frac{t}{y} - y\right)}{z \cdot 3}} \]
    9. *-un-lft-identity96.2%

      \[\leadsto x + \frac{\color{blue}{\frac{t}{y} - y}}{z \cdot 3} \]
  5. Applied egg-rr96.2%

    \[\leadsto x + \color{blue}{\frac{\frac{t}{y} - y}{z \cdot 3}} \]
  6. Taylor expanded in t around 0 64.9%

    \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
  7. Step-by-step derivation
    1. associate-*r/64.9%

      \[\leadsto x + \color{blue}{\frac{-0.3333333333333333 \cdot y}{z}} \]
    2. associate-/l*65.0%

      \[\leadsto x + \color{blue}{\frac{-0.3333333333333333}{\frac{z}{y}}} \]
  8. Simplified65.0%

    \[\leadsto x + \color{blue}{\frac{-0.3333333333333333}{\frac{z}{y}}} \]
  9. Final simplification65.0%

    \[\leadsto x + \frac{-0.3333333333333333}{\frac{z}{y}} \]
  10. Add Preprocessing

Alternative 12: 64.7% accurate, 2.1× speedup?

\[\begin{array}{l} \\ x + \frac{\frac{y}{-3}}{z} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (/ y -3.0) z)))
double code(double x, double y, double z, double t) {
	return x + ((y / -3.0) / z);
}
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 / (-3.0d0)) / z)
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y / -3.0) / z);
}
def code(x, y, z, t):
	return x + ((y / -3.0) / z)
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y / -3.0) / z))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y / -3.0) / z);
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y / -3.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{\frac{y}{-3}}{z}
\end{array}
Derivation
  1. Initial program 94.7%

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

    \[\leadsto \color{blue}{x + \frac{0.3333333333333333}{z} \cdot \left(\frac{t}{y} - y\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in z around 0 96.1%

    \[\leadsto x + \color{blue}{0.3333333333333333 \cdot \frac{\frac{t}{y} - y}{z}} \]
  5. Step-by-step derivation
    1. *-commutative96.1%

      \[\leadsto x + \color{blue}{\frac{\frac{t}{y} - y}{z} \cdot 0.3333333333333333} \]
    2. metadata-eval96.1%

      \[\leadsto x + \frac{\frac{t}{y} - y}{z} \cdot \color{blue}{\frac{1}{3}} \]
    3. div-inv96.2%

      \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}} \]
  6. Applied egg-rr96.2%

    \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}} \]
  7. Taylor expanded in t around 0 64.9%

    \[\leadsto x + \color{blue}{-0.3333333333333333 \cdot \frac{y}{z}} \]
  8. Step-by-step derivation
    1. *-commutative64.9%

      \[\leadsto x + \color{blue}{\frac{y}{z} \cdot -0.3333333333333333} \]
    2. metadata-eval64.9%

      \[\leadsto x + \frac{y}{z} \cdot \color{blue}{\frac{1}{-3}} \]
    3. times-frac65.0%

      \[\leadsto x + \color{blue}{\frac{y \cdot 1}{z \cdot -3}} \]
    4. *-rgt-identity65.0%

      \[\leadsto x + \frac{\color{blue}{y}}{z \cdot -3} \]
    5. *-commutative65.0%

      \[\leadsto x + \frac{y}{\color{blue}{-3 \cdot z}} \]
    6. associate-/r*65.0%

      \[\leadsto x + \color{blue}{\frac{\frac{y}{-3}}{z}} \]
  9. Simplified65.0%

    \[\leadsto x + \color{blue}{\frac{\frac{y}{-3}}{z}} \]
  10. Final simplification65.0%

    \[\leadsto x + \frac{\frac{y}{-3}}{z} \]
  11. Add Preprocessing

Alternative 13: 30.8% accurate, 15.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
	return x;
}
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
end function
public static double code(double x, double y, double z, double t) {
	return x;
}
def code(x, y, z, t):
	return x
function code(x, y, z, t)
	return x
end
function tmp = code(x, y, z, t)
	tmp = x;
end
code[x_, y_, z_, t_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 94.7%

    \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
  2. Step-by-step derivation
    1. associate-*l*94.7%

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\color{blue}{z \cdot \left(3 \cdot y\right)}} \]
    2. *-commutative94.7%

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

    \[\leadsto \color{blue}{\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \left(y \cdot 3\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 31.7%

    \[\leadsto \color{blue}{x} \]
  6. Final simplification31.7%

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 96.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x - \frac{y}{z \cdot 3}\right) + \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)))
double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y);
}
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
public static double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y);
}
def code(x, y, z, t):
	return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y)
function code(x, y, z, t)
	return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(Float64(t / Float64(z * 3.0)) / y))
end
function tmp = code(x, y, z, t)
	tmp = (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y);
end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t / N[(z * 3.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Reproduce

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