Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3

Percentage Accurate: 67.6% → 94.7%
Time: 22.0s
Alternatives: 14
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - x) * (z - t)) / (a - t));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x + (((y - x) * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
	return x + (((y - x) * (z - t)) / (a - t));
}
def code(x, y, z, t, a):
	return x + (((y - x) * (z - t)) / (a - t))
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t)))
end
function tmp = code(x, y, z, t, a)
	tmp = x + (((y - x) * (z - t)) / (a - t));
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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 14 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: 67.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - x) * (z - t)) / (a - t));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x + (((y - x) * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
	return x + (((y - x) * (z - t)) / (a - t));
}
def code(x, y, z, t, a):
	return x + (((y - x) * (z - t)) / (a - t))
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t)))
end
function tmp = code(x, y, z, t, a)
	tmp = x + (((y - x) * (z - t)) / (a - t));
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 94.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)\\ \mathbf{if}\;y \leq -1.35 \cdot 10^{+26}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 4000:\\ \;\;\;\;x \cdot \left(\frac{a}{a - t} + \frac{z}{t - a}\right) - -1 \cdot \frac{y \cdot \left(t - z\right)}{t - a}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (fma (/ (- t z) (- t a)) (- y x) x)))
   (if (<= y -1.35e+26)
     t_1
     (if (<= y 4000.0)
       (-
        (* x (+ (/ a (- a t)) (/ z (- t a))))
        (* -1.0 (/ (* y (- t z)) (- t a))))
       t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fma(((t - z) / (t - a)), (y - x), x);
	double tmp;
	if (y <= -1.35e+26) {
		tmp = t_1;
	} else if (y <= 4000.0) {
		tmp = (x * ((a / (a - t)) + (z / (t - a)))) - (-1.0 * ((y * (t - z)) / (t - a)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = fma(Float64(Float64(t - z) / Float64(t - a)), Float64(y - x), x)
	tmp = 0.0
	if (y <= -1.35e+26)
		tmp = t_1;
	elseif (y <= 4000.0)
		tmp = Float64(Float64(x * Float64(Float64(a / Float64(a - t)) + Float64(z / Float64(t - a)))) - Float64(-1.0 * Float64(Float64(y * Float64(t - z)) / Float64(t - a))));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -1.35e+26], t$95$1, If[LessEqual[y, 4000.0], N[(N[(x * N[(N[(a / N[(a - t), $MachinePrecision]), $MachinePrecision] + N[(z / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[(N[(y * N[(t - z), $MachinePrecision]), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)\\
\mathbf{if}\;y \leq -1.35 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 4000:\\
\;\;\;\;x \cdot \left(\frac{a}{a - t} + \frac{z}{t - a}\right) - -1 \cdot \frac{y \cdot \left(t - z\right)}{t - a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.35e26 or 4e3 < y

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

    if -1.35e26 < y < 4e3

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)} \]
    3. Applied rewrites76.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{a - t}, a \cdot x, \frac{t}{t - a} \cdot x - \frac{t - z}{t - a} \cdot \left(x - y\right)\right)} \]
    4. Taylor expanded in x around 0

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

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

Alternative 2: 90.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)\\ t_2 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-253}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 0:\\ \;\;\;\;y + -1 \cdot \frac{z \cdot \left(y - x\right) - a \cdot \left(y - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (fma (/ (- t z) (- t a)) (- y x) x))
        (t_2 (+ x (/ (* (- y x) (- z t)) (- a t)))))
   (if (<= t_2 -5e-253)
     t_1
     (if (<= t_2 0.0)
       (+ y (* -1.0 (/ (- (* z (- y x)) (* a (- y x))) t)))
       t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fma(((t - z) / (t - a)), (y - x), x);
	double t_2 = x + (((y - x) * (z - t)) / (a - t));
	double tmp;
	if (t_2 <= -5e-253) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = y + (-1.0 * (((z * (y - x)) - (a * (y - x))) / t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = fma(Float64(Float64(t - z) / Float64(t - a)), Float64(y - x), x)
	t_2 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t)))
	tmp = 0.0
	if (t_2 <= -5e-253)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = Float64(y + Float64(-1.0 * Float64(Float64(Float64(z * Float64(y - x)) - Float64(a * Float64(y - x))) / t)));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-253], t$95$1, If[LessEqual[t$95$2, 0.0], N[(y + N[(-1.0 * N[(N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] - N[(a * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)\\
t_2 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-253}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;y + -1 \cdot \frac{z \cdot \left(y - x\right) - a \cdot \left(y - x\right)}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -4.99999999999999971e-253 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t)))

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

    if -4.99999999999999971e-253 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0

    1. Initial program 67.6%

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

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

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

Alternative 3: 84.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right) \end{array} \]
(FPCore (x y z t a) :precision binary64 (fma (/ (- t z) (- t a)) (- y x) x))
double code(double x, double y, double z, double t, double a) {
	return fma(((t - z) / (t - a)), (y - x), x);
}
function code(x, y, z, t, a)
	return fma(Float64(Float64(t - z) / Float64(t - a)), Float64(y - x), x)
end
code[x_, y_, z_, t_, a_] := N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)
\end{array}
Derivation
  1. Initial program 67.6%

    \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
  2. Applied rewrites84.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)} \]
  3. Add Preprocessing

Alternative 4: 70.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{t - z}{t - a} \cdot y\\ \mathbf{if}\;t \leq -3.35:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 2.9 \cdot 10^{+20}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\ \mathbf{elif}\;t \leq 3.9 \cdot 10^{+122}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - z}{t}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (/ (- t z) (- t a)) y)))
   (if (<= t -3.35)
     t_1
     (if (<= t 2.9e+20)
       (fma (/ z a) (- y x) x)
       (if (<= t 3.9e+122) (fma (/ (- t z) t) (- y x) x) t_1)))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = ((t - z) / (t - a)) * y;
	double tmp;
	if (t <= -3.35) {
		tmp = t_1;
	} else if (t <= 2.9e+20) {
		tmp = fma((z / a), (y - x), x);
	} else if (t <= 3.9e+122) {
		tmp = fma(((t - z) / t), (y - x), x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = Float64(Float64(Float64(t - z) / Float64(t - a)) * y)
	tmp = 0.0
	if (t <= -3.35)
		tmp = t_1;
	elseif (t <= 2.9e+20)
		tmp = fma(Float64(z / a), Float64(y - x), x);
	elseif (t <= 3.9e+122)
		tmp = fma(Float64(Float64(t - z) / t), Float64(y - x), x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t, -3.35], t$95$1, If[LessEqual[t, 2.9e+20], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 3.9e+122], N[(N[(N[(t - z), $MachinePrecision] / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{t - z}{t - a} \cdot y\\
\mathbf{if}\;t \leq -3.35:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 2.9 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\

\mathbf{elif}\;t \leq 3.9 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{t}, y - x, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -3.35000000000000009 or 3.8999999999999999e122 < t

    1. Initial program 67.6%

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    3. Applied rewrites39.9%

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    4. Applied rewrites52.3%

      \[\leadsto \frac{t - z}{t - a} \cdot \color{blue}{y} \]

    if -3.35000000000000009 < t < 2.9e20

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
    4. Applied rewrites48.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]

    if 2.9e20 < t < 3.8999999999999999e122

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{t - z}{t}}, y - x, x\right) \]
    4. Applied rewrites38.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{t - z}{t}}, y - x, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 67.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{t - z}{t - a} \cdot y\\ \mathbf{if}\;t \leq -4.2 \cdot 10^{+45}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{+107}:\\ \;\;\;\;x + \frac{z \cdot \left(y - x\right)}{a - t}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (/ (- t z) (- t a)) y)))
   (if (<= t -4.2e+45)
     t_1
     (if (<= t 1.15e+107) (+ x (/ (* z (- y x)) (- a t))) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = ((t - z) / (t - a)) * y;
	double tmp;
	if (t <= -4.2e+45) {
		tmp = t_1;
	} else if (t <= 1.15e+107) {
		tmp = x + ((z * (y - x)) / (a - t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((t - z) / (t - a)) * y
    if (t <= (-4.2d+45)) then
        tmp = t_1
    else if (t <= 1.15d+107) then
        tmp = x + ((z * (y - x)) / (a - t))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = ((t - z) / (t - a)) * y;
	double tmp;
	if (t <= -4.2e+45) {
		tmp = t_1;
	} else if (t <= 1.15e+107) {
		tmp = x + ((z * (y - x)) / (a - t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	t_1 = ((t - z) / (t - a)) * y
	tmp = 0
	if t <= -4.2e+45:
		tmp = t_1
	elif t <= 1.15e+107:
		tmp = x + ((z * (y - x)) / (a - t))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a)
	t_1 = Float64(Float64(Float64(t - z) / Float64(t - a)) * y)
	tmp = 0.0
	if (t <= -4.2e+45)
		tmp = t_1;
	elseif (t <= 1.15e+107)
		tmp = Float64(x + Float64(Float64(z * Float64(y - x)) / Float64(a - t)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = ((t - z) / (t - a)) * y;
	tmp = 0.0;
	if (t <= -4.2e+45)
		tmp = t_1;
	elseif (t <= 1.15e+107)
		tmp = x + ((z * (y - x)) / (a - t));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t, -4.2e+45], t$95$1, If[LessEqual[t, 1.15e+107], N[(x + N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{t - z}{t - a} \cdot y\\
\mathbf{if}\;t \leq -4.2 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -4.1999999999999999e45 or 1.15e107 < t

    1. Initial program 67.6%

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    3. Applied rewrites39.9%

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    4. Applied rewrites52.3%

      \[\leadsto \frac{t - z}{t - a} \cdot \color{blue}{y} \]

    if -4.1999999999999999e45 < t < 1.15e107

    1. Initial program 67.6%

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

      \[\leadsto x + \frac{\color{blue}{z \cdot \left(y - x\right)}}{a - t} \]
    3. Applied rewrites54.6%

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

Alternative 6: 66.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{t - z}{t - a} \cdot y\\ \mathbf{if}\;t \leq -3.35:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 1.58 \cdot 10^{-49}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (/ (- t z) (- t a)) y)))
   (if (<= t -3.35) t_1 (if (<= t 1.58e-49) (fma (/ z a) (- y x) x) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = ((t - z) / (t - a)) * y;
	double tmp;
	if (t <= -3.35) {
		tmp = t_1;
	} else if (t <= 1.58e-49) {
		tmp = fma((z / a), (y - x), x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = Float64(Float64(Float64(t - z) / Float64(t - a)) * y)
	tmp = 0.0
	if (t <= -3.35)
		tmp = t_1;
	elseif (t <= 1.58e-49)
		tmp = fma(Float64(z / a), Float64(y - x), x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t, -3.35], t$95$1, If[LessEqual[t, 1.58e-49], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{t - z}{t - a} \cdot y\\
\mathbf{if}\;t \leq -3.35:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 1.58 \cdot 10^{-49}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.35000000000000009 or 1.58e-49 < t

    1. Initial program 67.6%

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    3. Applied rewrites39.9%

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    4. Applied rewrites52.3%

      \[\leadsto \frac{t - z}{t - a} \cdot \color{blue}{y} \]

    if -3.35000000000000009 < t < 1.58e-49

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
    4. Applied rewrites48.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 63.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{y}{t - a} \cdot \left(t - z\right)\\ \mathbf{if}\;t \leq -3.35:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 1.58 \cdot 10^{-49}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (* (/ y (- t a)) (- t z))))
   (if (<= t -3.35) t_1 (if (<= t 1.58e-49) (fma (/ z a) (- y x) x) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = (y / (t - a)) * (t - z);
	double tmp;
	if (t <= -3.35) {
		tmp = t_1;
	} else if (t <= 1.58e-49) {
		tmp = fma((z / a), (y - x), x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = Float64(Float64(y / Float64(t - a)) * Float64(t - z))
	tmp = 0.0
	if (t <= -3.35)
		tmp = t_1;
	elseif (t <= 1.58e-49)
		tmp = fma(Float64(z / a), Float64(y - x), x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -3.35], t$95$1, If[LessEqual[t, 1.58e-49], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{y}{t - a} \cdot \left(t - z\right)\\
\mathbf{if}\;t \leq -3.35:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 1.58 \cdot 10^{-49}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.35000000000000009 or 1.58e-49 < t

    1. Initial program 67.6%

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    3. Applied rewrites39.9%

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    4. Applied rewrites46.6%

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

    if -3.35000000000000009 < t < 1.58e-49

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
    4. Applied rewrites48.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 59.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\frac{y}{t - a}, t, x\right)\\ \mathbf{if}\;t \leq -5.8 \cdot 10^{+46}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 6.8 \cdot 10^{-58}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (fma (/ y (- t a)) t x)))
   (if (<= t -5.8e+46) t_1 (if (<= t 6.8e-58) (fma (/ z a) (- y x) x) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fma((y / (t - a)), t, x);
	double tmp;
	if (t <= -5.8e+46) {
		tmp = t_1;
	} else if (t <= 6.8e-58) {
		tmp = fma((z / a), (y - x), x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = fma(Float64(y / Float64(t - a)), t, x)
	tmp = 0.0
	if (t <= -5.8e+46)
		tmp = t_1;
	elseif (t <= 6.8e-58)
		tmp = fma(Float64(z / a), Float64(y - x), x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[t, -5.8e+46], t$95$1, If[LessEqual[t, 6.8e-58], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{y}{t - a}, t, x\right)\\
\mathbf{if}\;t \leq -5.8 \cdot 10^{+46}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 6.8 \cdot 10^{-58}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -5.8000000000000004e46 or 6.79999999999999947e-58 < t

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites80.1%

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

      \[\leadsto \mathsf{fma}\left(\frac{y - x}{t - a}, \color{blue}{t}, x\right) \]
    4. Applied rewrites46.3%

      \[\leadsto \mathsf{fma}\left(\frac{y - x}{t - a}, \color{blue}{t}, x\right) \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{t - a}, t, x\right) \]
    6. Applied rewrites44.6%

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{t - a}, t, x\right) \]

    if -5.8000000000000004e46 < t < 6.79999999999999947e-58

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
    4. Applied rewrites48.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 56.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1.42 \cdot 10^{+119}:\\ \;\;\;\;\mathsf{fma}\left(1, y - x, x\right)\\ \mathbf{elif}\;t \leq 2 \cdot 10^{+196}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, t, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (if (<= t -1.42e+119)
   (fma 1.0 (- y x) x)
   (if (<= t 2e+196) (fma (/ z a) (- y x) x) (fma (/ (- y x) t) t x))))
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (t <= -1.42e+119) {
		tmp = fma(1.0, (y - x), x);
	} else if (t <= 2e+196) {
		tmp = fma((z / a), (y - x), x);
	} else {
		tmp = fma(((y - x) / t), t, x);
	}
	return tmp;
}
function code(x, y, z, t, a)
	tmp = 0.0
	if (t <= -1.42e+119)
		tmp = fma(1.0, Float64(y - x), x);
	elseif (t <= 2e+196)
		tmp = fma(Float64(z / a), Float64(y - x), x);
	else
		tmp = fma(Float64(Float64(y - x) / t), t, x);
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.42e+119], N[(1.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 2e+196], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * t + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.42 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(1, y - x, x\right)\\

\mathbf{elif}\;t \leq 2 \cdot 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, t, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -1.4199999999999999e119

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, y - x, x\right) \]
    4. Applied rewrites19.4%

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, y - x, x\right) \]

    if -1.4199999999999999e119 < t < 1.9999999999999999e196

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
    4. Applied rewrites48.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]

    if 1.9999999999999999e196 < t

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites80.1%

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

      \[\leadsto \mathsf{fma}\left(\frac{y - x}{t - a}, \color{blue}{t}, x\right) \]
    4. Applied rewrites46.3%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y - x}{t}}, t, x\right) \]
    6. Applied rewrites21.3%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{y - x}{t}}, t, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 55.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(1, y - x, x\right)\\ \mathbf{if}\;t \leq -1.42 \cdot 10^{+119}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 2 \cdot 10^{+196}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (fma 1.0 (- y x) x)))
   (if (<= t -1.42e+119) t_1 (if (<= t 2e+196) (fma (/ z a) (- y x) x) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fma(1.0, (y - x), x);
	double tmp;
	if (t <= -1.42e+119) {
		tmp = t_1;
	} else if (t <= 2e+196) {
		tmp = fma((z / a), (y - x), x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = fma(1.0, Float64(y - x), x)
	tmp = 0.0
	if (t <= -1.42e+119)
		tmp = t_1;
	elseif (t <= 2e+196)
		tmp = fma(Float64(z / a), Float64(y - x), x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(1.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -1.42e+119], t$95$1, If[LessEqual[t, 2e+196], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1, y - x, x\right)\\
\mathbf{if}\;t \leq -1.42 \cdot 10^{+119}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 2 \cdot 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.4199999999999999e119 or 1.9999999999999999e196 < t

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, y - x, x\right) \]
    4. Applied rewrites19.4%

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, y - x, x\right) \]

    if -1.4199999999999999e119 < t < 1.9999999999999999e196

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
    4. Applied rewrites48.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{a}}, y - x, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 32.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(1, y - x, x\right)\\ \mathbf{if}\;t \leq -1.22 \cdot 10^{+39}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 8 \cdot 10^{+49}:\\ \;\;\;\;\frac{y \cdot z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (fma 1.0 (- y x) x)))
   (if (<= t -1.22e+39) t_1 (if (<= t 8e+49) (/ (* y z) (- a t)) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fma(1.0, (y - x), x);
	double tmp;
	if (t <= -1.22e+39) {
		tmp = t_1;
	} else if (t <= 8e+49) {
		tmp = (y * z) / (a - t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = fma(1.0, Float64(y - x), x)
	tmp = 0.0
	if (t <= -1.22e+39)
		tmp = t_1;
	elseif (t <= 8e+49)
		tmp = Float64(Float64(y * z) / Float64(a - t));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(1.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -1.22e+39], t$95$1, If[LessEqual[t, 8e+49], N[(N[(y * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1, y - x, x\right)\\
\mathbf{if}\;t \leq -1.22 \cdot 10^{+39}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 8 \cdot 10^{+49}:\\
\;\;\;\;\frac{y \cdot z}{a - t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.22e39 or 7.99999999999999957e49 < t

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, y - x, x\right) \]
    4. Applied rewrites19.4%

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, y - x, x\right) \]

    if -1.22e39 < t < 7.99999999999999957e49

    1. Initial program 67.6%

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    3. Applied rewrites39.9%

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    4. Taylor expanded in z around inf

      \[\leadsto \frac{y \cdot z}{\color{blue}{a} - t} \]
    5. Applied rewrites21.8%

      \[\leadsto \frac{y \cdot z}{\color{blue}{a} - t} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 31.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(1, y - x, x\right)\\ \mathbf{if}\;t \leq -470:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 3 \cdot 10^{+43}:\\ \;\;\;\;\frac{z}{a} \cdot y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (fma 1.0 (- y x) x)))
   (if (<= t -470.0) t_1 (if (<= t 3e+43) (* (/ z a) y) t_1))))
double code(double x, double y, double z, double t, double a) {
	double t_1 = fma(1.0, (y - x), x);
	double tmp;
	if (t <= -470.0) {
		tmp = t_1;
	} else if (t <= 3e+43) {
		tmp = (z / a) * y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a)
	t_1 = fma(1.0, Float64(y - x), x)
	tmp = 0.0
	if (t <= -470.0)
		tmp = t_1;
	elseif (t <= 3e+43)
		tmp = Float64(Float64(z / a) * y);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(1.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -470.0], t$95$1, If[LessEqual[t, 3e+43], N[(N[(z / a), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1, y - x, x\right)\\
\mathbf{if}\;t \leq -470:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 3 \cdot 10^{+43}:\\
\;\;\;\;\frac{z}{a} \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -470 or 3.00000000000000017e43 < t

    1. Initial program 67.6%

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
    2. Applied rewrites84.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, y - x, x\right) \]
    4. Applied rewrites19.4%

      \[\leadsto \mathsf{fma}\left(\color{blue}{1}, y - x, x\right) \]

    if -470 < t < 3.00000000000000017e43

    1. Initial program 67.6%

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
    3. Applied rewrites39.9%

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

      \[\leadsto \frac{y \cdot z}{\color{blue}{a}} \]
    5. Applied rewrites16.9%

      \[\leadsto \frac{y \cdot z}{\color{blue}{a}} \]
    6. Applied rewrites19.4%

      \[\leadsto \frac{z}{a} \cdot y \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 19.4% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \frac{z}{a} \cdot y \end{array} \]
(FPCore (x y z t a) :precision binary64 (* (/ z a) y))
double code(double x, double y, double z, double t, double a) {
	return (z / a) * y;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = (z / a) * y
end function
public static double code(double x, double y, double z, double t, double a) {
	return (z / a) * y;
}
def code(x, y, z, t, a):
	return (z / a) * y
function code(x, y, z, t, a)
	return Float64(Float64(z / a) * y)
end
function tmp = code(x, y, z, t, a)
	tmp = (z / a) * y;
end
code[x_, y_, z_, t_, a_] := N[(N[(z / a), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}

\\
\frac{z}{a} \cdot y
\end{array}
Derivation
  1. Initial program 67.6%

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

    \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
  3. Applied rewrites39.9%

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

    \[\leadsto \frac{y \cdot z}{\color{blue}{a}} \]
  5. Applied rewrites16.9%

    \[\leadsto \frac{y \cdot z}{\color{blue}{a}} \]
  6. Applied rewrites19.4%

    \[\leadsto \frac{z}{a} \cdot y \]
  7. Add Preprocessing

Alternative 14: 18.2% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \frac{y}{a} \cdot z \end{array} \]
(FPCore (x y z t a) :precision binary64 (* (/ y a) z))
double code(double x, double y, double z, double t, double a) {
	return (y / a) * z;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = (y / a) * z
end function
public static double code(double x, double y, double z, double t, double a) {
	return (y / a) * z;
}
def code(x, y, z, t, a):
	return (y / a) * z
function code(x, y, z, t, a)
	return Float64(Float64(y / a) * z)
end
function tmp = code(x, y, z, t, a)
	tmp = (y / a) * z;
end
code[x_, y_, z_, t_, a_] := N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision]
\begin{array}{l}

\\
\frac{y}{a} \cdot z
\end{array}
Derivation
  1. Initial program 67.6%

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

    \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{a - t}} \]
  3. Applied rewrites39.9%

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

    \[\leadsto \frac{y \cdot z}{\color{blue}{a}} \]
  5. Applied rewrites16.9%

    \[\leadsto \frac{y \cdot z}{\color{blue}{a}} \]
  6. Applied rewrites18.2%

    \[\leadsto \frac{y}{a} \cdot z \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2025153 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
  :precision binary64
  (+ x (/ (* (- y x) (- z t)) (- a t))))