Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A

Percentage Accurate: 99.9% → 99.9%
Time: 2.1s
Alternatives: 11
Speedup: 1.0×

Specification

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

\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\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 11 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: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 89.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ t_2 := t\_1 - y\\ \mathbf{if}\;t\_2 \leq -1 \cdot 10^{+193}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_2 \leq -5000000000000:\\ \;\;\;\;\left(\log y - y\right) - z\\ \mathbf{elif}\;t\_2 \leq 10^{-7}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;t\_1 - z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))) (t_2 (- t_1 y)))
   (if (<= t_2 -1e+193)
     t_2
     (if (<= t_2 -5000000000000.0)
       (- (- (log y) y) z)
       (if (<= t_2 1e-7) (- (log t) z) (- t_1 z))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double t_2 = t_1 - y;
	double tmp;
	if (t_2 <= -1e+193) {
		tmp = t_2;
	} else if (t_2 <= -5000000000000.0) {
		tmp = (log(y) - y) - z;
	} else if (t_2 <= 1e-7) {
		tmp = log(t) - z;
	} else {
		tmp = t_1 - z;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * log(y)
    t_2 = t_1 - y
    if (t_2 <= (-1d+193)) then
        tmp = t_2
    else if (t_2 <= (-5000000000000.0d0)) then
        tmp = (log(y) - y) - z
    else if (t_2 <= 1d-7) then
        tmp = log(t) - z
    else
        tmp = t_1 - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double t_2 = t_1 - y;
	double tmp;
	if (t_2 <= -1e+193) {
		tmp = t_2;
	} else if (t_2 <= -5000000000000.0) {
		tmp = (Math.log(y) - y) - z;
	} else if (t_2 <= 1e-7) {
		tmp = Math.log(t) - z;
	} else {
		tmp = t_1 - z;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	t_2 = t_1 - y
	tmp = 0
	if t_2 <= -1e+193:
		tmp = t_2
	elif t_2 <= -5000000000000.0:
		tmp = (math.log(y) - y) - z
	elif t_2 <= 1e-7:
		tmp = math.log(t) - z
	else:
		tmp = t_1 - z
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	t_2 = Float64(t_1 - y)
	tmp = 0.0
	if (t_2 <= -1e+193)
		tmp = t_2;
	elseif (t_2 <= -5000000000000.0)
		tmp = Float64(Float64(log(y) - y) - z);
	elseif (t_2 <= 1e-7)
		tmp = Float64(log(t) - z);
	else
		tmp = Float64(t_1 - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	t_2 = t_1 - y;
	tmp = 0.0;
	if (t_2 <= -1e+193)
		tmp = t_2;
	elseif (t_2 <= -5000000000000.0)
		tmp = (log(y) - y) - z;
	elseif (t_2 <= 1e-7)
		tmp = log(t) - z;
	else
		tmp = t_1 - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - y), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+193], t$95$2, If[LessEqual[t$95$2, -5000000000000.0], N[(N[(N[Log[y], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$2, 1e-7], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(t$95$1 - z), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := t\_1 - y\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+193}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_2 \leq -5000000000000:\\
\;\;\;\;\left(\log y - y\right) - z\\

\mathbf{elif}\;t\_2 \leq 10^{-7}:\\
\;\;\;\;\log t - z\\

\mathbf{else}:\\
\;\;\;\;t\_1 - z\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -1.00000000000000007e193

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.9%

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

      \[\leadsto -1 \cdot \color{blue}{\left(y + z\right)} \]
    6. Applied rewrites89.1%

      \[\leadsto x \cdot \log y - \color{blue}{y} \]

    if -1.00000000000000007e193 < (-.f64 (*.f64 x (log.f64 y)) y) < -5e12

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.2%

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

      \[\leadsto \left(x \cdot \log y - y\right) - z \]
    6. Applied rewrites76.3%

      \[\leadsto \left(\log y - y\right) - z \]

    if -5e12 < (-.f64 (*.f64 x (log.f64 y)) y) < 9.9999999999999995e-8

    1. Initial program 100.0%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites56.6%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]
    5. Taylor expanded in x around inf

      \[\leadsto x \cdot \left(\log y + -1 \cdot \frac{y}{x}\right) - z \]
    6. Applied rewrites98.6%

      \[\leadsto \log t - z \]

    if 9.9999999999999995e-8 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.6%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites98.0%

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

      \[\leadsto \left(x \cdot \log y - y\right) - z \]
    6. Applied rewrites97.5%

      \[\leadsto x \cdot \log y - z \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 85.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y - y\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+193}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq -5000000000000:\\ \;\;\;\;\left(\log y - y\right) - z\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+20}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x (log y)) y)))
   (if (<= t_1 -1e+193)
     t_1
     (if (<= t_1 -5000000000000.0)
       (- (- (log y) y) z)
       (if (<= t_1 2e+20) (- (log t) z) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = (x * log(y)) - y;
	double tmp;
	if (t_1 <= -1e+193) {
		tmp = t_1;
	} else if (t_1 <= -5000000000000.0) {
		tmp = (log(y) - y) - z;
	} else if (t_1 <= 2e+20) {
		tmp = log(t) - z;
	} 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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x * log(y)) - y
    if (t_1 <= (-1d+193)) then
        tmp = t_1
    else if (t_1 <= (-5000000000000.0d0)) then
        tmp = (log(y) - y) - z
    else if (t_1 <= 2d+20) then
        tmp = log(t) - z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (x * Math.log(y)) - y;
	double tmp;
	if (t_1 <= -1e+193) {
		tmp = t_1;
	} else if (t_1 <= -5000000000000.0) {
		tmp = (Math.log(y) - y) - z;
	} else if (t_1 <= 2e+20) {
		tmp = Math.log(t) - z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (x * math.log(y)) - y
	tmp = 0
	if t_1 <= -1e+193:
		tmp = t_1
	elif t_1 <= -5000000000000.0:
		tmp = (math.log(y) - y) - z
	elif t_1 <= 2e+20:
		tmp = math.log(t) - z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(x * log(y)) - y)
	tmp = 0.0
	if (t_1 <= -1e+193)
		tmp = t_1;
	elseif (t_1 <= -5000000000000.0)
		tmp = Float64(Float64(log(y) - y) - z);
	elseif (t_1 <= 2e+20)
		tmp = Float64(log(t) - z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * log(y)) - y;
	tmp = 0.0;
	if (t_1 <= -1e+193)
		tmp = t_1;
	elseif (t_1 <= -5000000000000.0)
		tmp = (log(y) - y) - z;
	elseif (t_1 <= 2e+20)
		tmp = log(t) - z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+193], t$95$1, If[LessEqual[t$95$1, -5000000000000.0], N[(N[(N[Log[y], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$1, 2e+20], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+193}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq -5000000000000:\\
\;\;\;\;\left(\log y - y\right) - z\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+20}:\\
\;\;\;\;\log t - z\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -1.00000000000000007e193 or 2e20 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.8%

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

      \[\leadsto -1 \cdot \color{blue}{\left(y + z\right)} \]
    6. Applied rewrites88.2%

      \[\leadsto x \cdot \log y - \color{blue}{y} \]

    if -1.00000000000000007e193 < (-.f64 (*.f64 x (log.f64 y)) y) < -5e12

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.2%

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

      \[\leadsto \left(x \cdot \log y - y\right) - z \]
    6. Applied rewrites76.3%

      \[\leadsto \left(\log y - y\right) - z \]

    if -5e12 < (-.f64 (*.f64 x (log.f64 y)) y) < 2e20

    1. Initial program 100.0%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites58.1%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]
    5. Taylor expanded in x around inf

      \[\leadsto x \cdot \left(\log y + -1 \cdot \frac{y}{x}\right) - z \]
    6. Applied rewrites97.2%

      \[\leadsto \log t - z \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 99.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y - y\\ t_2 := t\_1 - z\\ \mathbf{if}\;t\_2 \leq -2 \cdot 10^{+24}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_2 \leq 4000:\\ \;\;\;\;t\_1 + \log t\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x (log y)) y)) (t_2 (- t_1 z)))
   (if (<= t_2 -2e+24) t_2 (if (<= t_2 4000.0) (+ t_1 (log t)) t_2))))
double code(double x, double y, double z, double t) {
	double t_1 = (x * log(y)) - y;
	double t_2 = t_1 - z;
	double tmp;
	if (t_2 <= -2e+24) {
		tmp = t_2;
	} else if (t_2 <= 4000.0) {
		tmp = t_1 + log(t);
	} else {
		tmp = t_2;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (x * log(y)) - y
    t_2 = t_1 - z
    if (t_2 <= (-2d+24)) then
        tmp = t_2
    else if (t_2 <= 4000.0d0) then
        tmp = t_1 + log(t)
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (x * Math.log(y)) - y;
	double t_2 = t_1 - z;
	double tmp;
	if (t_2 <= -2e+24) {
		tmp = t_2;
	} else if (t_2 <= 4000.0) {
		tmp = t_1 + Math.log(t);
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (x * math.log(y)) - y
	t_2 = t_1 - z
	tmp = 0
	if t_2 <= -2e+24:
		tmp = t_2
	elif t_2 <= 4000.0:
		tmp = t_1 + math.log(t)
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(x * log(y)) - y)
	t_2 = Float64(t_1 - z)
	tmp = 0.0
	if (t_2 <= -2e+24)
		tmp = t_2;
	elseif (t_2 <= 4000.0)
		tmp = Float64(t_1 + log(t));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * log(y)) - y;
	t_2 = t_1 - z;
	tmp = 0.0;
	if (t_2 <= -2e+24)
		tmp = t_2;
	elseif (t_2 <= 4000.0)
		tmp = t_1 + log(t);
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - z), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+24], t$95$2, If[LessEqual[t$95$2, 4000.0], N[(t$95$1 + N[Log[t], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
t_2 := t\_1 - z\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+24}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_2 \leq 4000:\\
\;\;\;\;t\_1 + \log t\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) < -2e24 or 4e3 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z)

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]

    if -2e24 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) < 4e3

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-1 \cdot \left(y + z\right)} + \log t \]
    4. Applied rewrites98.3%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right)} + \log t \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 98.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ t_2 := \left(t\_1 - y\right) - z\\ \mathbf{if}\;t\_2 \leq -5000000000000:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_2 \leq 4000:\\ \;\;\;\;t\_1 + \log t\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))) (t_2 (- (- t_1 y) z)))
   (if (<= t_2 -5000000000000.0)
     t_2
     (if (<= t_2 4000.0) (+ t_1 (log t)) t_2))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double t_2 = (t_1 - y) - z;
	double tmp;
	if (t_2 <= -5000000000000.0) {
		tmp = t_2;
	} else if (t_2 <= 4000.0) {
		tmp = t_1 + log(t);
	} else {
		tmp = t_2;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * log(y)
    t_2 = (t_1 - y) - z
    if (t_2 <= (-5000000000000.0d0)) then
        tmp = t_2
    else if (t_2 <= 4000.0d0) then
        tmp = t_1 + log(t)
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double t_2 = (t_1 - y) - z;
	double tmp;
	if (t_2 <= -5000000000000.0) {
		tmp = t_2;
	} else if (t_2 <= 4000.0) {
		tmp = t_1 + Math.log(t);
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	t_2 = (t_1 - y) - z
	tmp = 0
	if t_2 <= -5000000000000.0:
		tmp = t_2
	elif t_2 <= 4000.0:
		tmp = t_1 + math.log(t)
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	t_2 = Float64(Float64(t_1 - y) - z)
	tmp = 0.0
	if (t_2 <= -5000000000000.0)
		tmp = t_2;
	elseif (t_2 <= 4000.0)
		tmp = Float64(t_1 + log(t));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	t_2 = (t_1 - y) - z;
	tmp = 0.0;
	if (t_2 <= -5000000000000.0)
		tmp = t_2;
	elseif (t_2 <= 4000.0)
		tmp = t_1 + log(t);
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 - y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$2, -5000000000000.0], t$95$2, If[LessEqual[t$95$2, 4000.0], N[(t$95$1 + N[Log[t], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := \left(t\_1 - y\right) - z\\
\mathbf{if}\;t\_2 \leq -5000000000000:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_2 \leq 4000:\\
\;\;\;\;t\_1 + \log t\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) < -5e12 or 4e3 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z)

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.6%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]

    if -5e12 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) < 4e3

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(x \cdot \log y - \left(y + z\right)\right)} + \log t \]
    4. Applied rewrites97.4%

      \[\leadsto \color{blue}{x \cdot \log y} + \log t \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 98.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(x \cdot \log y - y\right) - z\\ \mathbf{if}\;t\_1 \leq -5000000000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq 0.002:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (- (* x (log y)) y) z)))
   (if (<= t_1 -5000000000000.0) t_1 (if (<= t_1 0.002) (- (log t) z) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = ((x * log(y)) - y) - z;
	double tmp;
	if (t_1 <= -5000000000000.0) {
		tmp = t_1;
	} else if (t_1 <= 0.002) {
		tmp = log(t) - z;
	} 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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((x * log(y)) - y) - z
    if (t_1 <= (-5000000000000.0d0)) then
        tmp = t_1
    else if (t_1 <= 0.002d0) then
        tmp = log(t) - z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = ((x * Math.log(y)) - y) - z;
	double tmp;
	if (t_1 <= -5000000000000.0) {
		tmp = t_1;
	} else if (t_1 <= 0.002) {
		tmp = Math.log(t) - z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = ((x * math.log(y)) - y) - z
	tmp = 0
	if t_1 <= -5000000000000.0:
		tmp = t_1
	elif t_1 <= 0.002:
		tmp = math.log(t) - z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(Float64(x * log(y)) - y) - z)
	tmp = 0.0
	if (t_1 <= -5000000000000.0)
		tmp = t_1;
	elseif (t_1 <= 0.002)
		tmp = Float64(log(t) - z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = ((x * log(y)) - y) - z;
	tmp = 0.0;
	if (t_1 <= -5000000000000.0)
		tmp = t_1;
	elseif (t_1 <= 0.002)
		tmp = log(t) - z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$1, -5000000000000.0], t$95$1, If[LessEqual[t$95$1, 0.002], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(x \cdot \log y - y\right) - z\\
\mathbf{if}\;t\_1 \leq -5000000000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq 0.002:\\
\;\;\;\;\log t - z\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) < -5e12 or 2e-3 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z)

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]

    if -5e12 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) y) z) < 2e-3

    1. Initial program 100.0%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites4.0%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]
    5. Taylor expanded in x around inf

      \[\leadsto x \cdot \left(\log y + -1 \cdot \frac{y}{x}\right) - z \]
    6. Applied rewrites96.9%

      \[\leadsto \log t - z \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 80.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ t_2 := t\_1 - y\\ \mathbf{if}\;t\_2 \leq -5000000000000:\\ \;\;\;\;\left(\log y - y\right) - z\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+20}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))) (t_2 (- t_1 y)))
   (if (<= t_2 -5000000000000.0)
     (- (- (log y) y) z)
     (if (<= t_2 2e+20) (- (log t) z) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double t_2 = t_1 - y;
	double tmp;
	if (t_2 <= -5000000000000.0) {
		tmp = (log(y) - y) - z;
	} else if (t_2 <= 2e+20) {
		tmp = log(t) - z;
	} 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
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * log(y)
    t_2 = t_1 - y
    if (t_2 <= (-5000000000000.0d0)) then
        tmp = (log(y) - y) - z
    else if (t_2 <= 2d+20) then
        tmp = log(t) - z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double t_2 = t_1 - y;
	double tmp;
	if (t_2 <= -5000000000000.0) {
		tmp = (Math.log(y) - y) - z;
	} else if (t_2 <= 2e+20) {
		tmp = Math.log(t) - z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	t_2 = t_1 - y
	tmp = 0
	if t_2 <= -5000000000000.0:
		tmp = (math.log(y) - y) - z
	elif t_2 <= 2e+20:
		tmp = math.log(t) - z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	t_2 = Float64(t_1 - y)
	tmp = 0.0
	if (t_2 <= -5000000000000.0)
		tmp = Float64(Float64(log(y) - y) - z);
	elseif (t_2 <= 2e+20)
		tmp = Float64(log(t) - z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	t_2 = t_1 - y;
	tmp = 0.0;
	if (t_2 <= -5000000000000.0)
		tmp = (log(y) - y) - z;
	elseif (t_2 <= 2e+20)
		tmp = log(t) - z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - y), $MachinePrecision]}, If[LessEqual[t$95$2, -5000000000000.0], N[(N[(N[Log[y], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$2, 2e+20], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := t\_1 - y\\
\mathbf{if}\;t\_2 \leq -5000000000000:\\
\;\;\;\;\left(\log y - y\right) - z\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+20}:\\
\;\;\;\;\log t - z\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -5e12

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.6%

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

      \[\leadsto \left(x \cdot \log y - y\right) - z \]
    6. Applied rewrites67.6%

      \[\leadsto \left(\log y - y\right) - z \]

    if -5e12 < (-.f64 (*.f64 x (log.f64 y)) y) < 2e20

    1. Initial program 100.0%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites58.1%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]
    5. Taylor expanded in x around inf

      \[\leadsto x \cdot \left(\log y + -1 \cdot \frac{y}{x}\right) - z \]
    6. Applied rewrites97.2%

      \[\leadsto \log t - z \]

    if 2e20 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.6%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.6%

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

      \[\leadsto x \cdot \log y - \color{blue}{\left(y + z\right)} \]
    6. Applied rewrites86.3%

      \[\leadsto x \cdot \color{blue}{\log y} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 60.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{+20}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{+38}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))))
   (if (<= x -1.2e+20) t_1 (if (<= x 9.2e+38) (- (log t) z) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double tmp;
	if (x <= -1.2e+20) {
		tmp = t_1;
	} else if (x <= 9.2e+38) {
		tmp = log(t) - z;
	} 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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x * log(y)
    if (x <= (-1.2d+20)) then
        tmp = t_1
    else if (x <= 9.2d+38) then
        tmp = log(t) - z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double tmp;
	if (x <= -1.2e+20) {
		tmp = t_1;
	} else if (x <= 9.2e+38) {
		tmp = Math.log(t) - z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	tmp = 0
	if x <= -1.2e+20:
		tmp = t_1
	elif x <= 9.2e+38:
		tmp = math.log(t) - z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	tmp = 0.0
	if (x <= -1.2e+20)
		tmp = t_1;
	elseif (x <= 9.2e+38)
		tmp = Float64(log(t) - z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	tmp = 0.0;
	if (x <= -1.2e+20)
		tmp = t_1;
	elseif (x <= 9.2e+38)
		tmp = log(t) - z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.2e+20], t$95$1, If[LessEqual[x, 9.2e+38], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{+20}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 9.2 \cdot 10^{+38}:\\
\;\;\;\;\log t - z\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.2e20 or 9.2000000000000005e38 < x

    1. Initial program 99.7%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites99.7%

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

      \[\leadsto x \cdot \log y - \color{blue}{\left(y + z\right)} \]
    6. Applied rewrites68.2%

      \[\leadsto x \cdot \color{blue}{\log y} \]

    if -1.2e20 < x < 9.2000000000000005e38

    1. Initial program 100.0%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites78.5%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]
    5. Taylor expanded in x around inf

      \[\leadsto x \cdot \left(\log y + -1 \cdot \frac{y}{x}\right) - z \]
    6. Applied rewrites67.1%

      \[\leadsto \log t - z \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 60.7% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log t - z\\ \mathbf{if}\;z \leq -6.2 \cdot 10^{+97}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+20}:\\ \;\;\;\;\log t - y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (log t) z)))
   (if (<= z -6.2e+97) t_1 (if (<= z 1.15e+20) (- (log t) y) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = log(t) - z;
	double tmp;
	if (z <= -6.2e+97) {
		tmp = t_1;
	} else if (z <= 1.15e+20) {
		tmp = log(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
    real(8) :: t_1
    real(8) :: tmp
    t_1 = log(t) - z
    if (z <= (-6.2d+97)) then
        tmp = t_1
    else if (z <= 1.15d+20) then
        tmp = log(t) - y
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.log(t) - z;
	double tmp;
	if (z <= -6.2e+97) {
		tmp = t_1;
	} else if (z <= 1.15e+20) {
		tmp = Math.log(t) - y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = math.log(t) - z
	tmp = 0
	if z <= -6.2e+97:
		tmp = t_1
	elif z <= 1.15e+20:
		tmp = math.log(t) - y
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(log(t) - z)
	tmp = 0.0
	if (z <= -6.2e+97)
		tmp = t_1;
	elseif (z <= 1.15e+20)
		tmp = Float64(log(t) - y);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = log(t) - z;
	tmp = 0.0;
	if (z <= -6.2e+97)
		tmp = t_1;
	elseif (z <= 1.15e+20)
		tmp = log(t) - y;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[z, -6.2e+97], t$95$1, If[LessEqual[z, 1.15e+20], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log t - z\\
\mathbf{if}\;z \leq -6.2 \cdot 10^{+97}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.15 \cdot 10^{+20}:\\
\;\;\;\;\log t - y\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.19999999999999962e97 or 1.15e20 < z

    1. Initial program 100.0%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - z} \]
    5. Taylor expanded in x around inf

      \[\leadsto x \cdot \left(\log y + -1 \cdot \frac{y}{x}\right) - z \]
    6. Applied rewrites70.0%

      \[\leadsto \log t - z \]

    if -6.19999999999999962e97 < z < 1.15e20

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
    4. Applied rewrites80.9%

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

      \[\leadsto -1 \cdot \color{blue}{\left(y + z\right)} \]
    6. Applied rewrites80.3%

      \[\leadsto x \cdot \log y - \color{blue}{y} \]
    7. Taylor expanded in x around 0

      \[\leadsto x \cdot \log y - y \]
    8. Applied rewrites52.1%

      \[\leadsto \log t - y \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 42.1% accurate, 2.1× speedup?

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

\\
\log t - y
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
  4. Applied rewrites88.9%

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

    \[\leadsto -1 \cdot \color{blue}{\left(y + z\right)} \]
  6. Applied rewrites59.0%

    \[\leadsto x \cdot \log y - \color{blue}{y} \]
  7. Taylor expanded in x around 0

    \[\leadsto x \cdot \log y - y \]
  8. Applied rewrites36.2%

    \[\leadsto \log t - y \]
  9. Add Preprocessing

Alternative 11: 14.1% accurate, 2.1× speedup?

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

\\
\log t
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
  4. Applied rewrites88.9%

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

    \[\leadsto \left(x \cdot \log y - y\right) - z \]
  6. Applied rewrites63.9%

    \[\leadsto x \cdot \log y - z \]
  7. Taylor expanded in x around inf

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

    \[\leadsto \color{blue}{\log t} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024313 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (+ (- (- (* x (log y)) y) z) (log t)))