Data.Number.Erf:$cinvnormcdf from erf-2.0.0.0, A

Percentage Accurate: 99.5% → 99.8%
Time: 11.2s
Alternatives: 15
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))
double code(double x, double y, double z, double t) {
	return (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0));
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * exp(((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
	return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.exp(((t * t) / 2.0));
}
def code(x, y, z, t):
	return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.exp(((t * t) / 2.0))
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * exp(Float64(Float64(t * t) / 2.0)))
end
function tmp = code(x, y, z, t)
	tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0));
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\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 15 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.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))
double code(double x, double y, double z, double t) {
	return (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0));
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * exp(((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
	return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.exp(((t * t) / 2.0));
}
def code(x, y, z, t):
	return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.exp(((t * t) / 2.0))
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * exp(Float64(Float64(t * t) / 2.0)))
end
function tmp = code(x, y, z, t)
	tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0));
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\end{array}

Alternative 1: 99.8% accurate, 0.7× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot {\left(\sqrt{e^{t\_m}}\right)}^{t\_m} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (pow (sqrt (exp t_m)) t_m)))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	return (((x * 0.5) - y) * sqrt((z * 2.0))) * pow(sqrt(exp(t_m)), t_m);
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * (sqrt(exp(t_m)) ** t_m)
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.pow(Math.sqrt(Math.exp(t_m)), t_m);
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.pow(math.sqrt(math.exp(t_m)), t_m)
t_m = abs(t)
function code(x, y, z, t_m)
	return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * (sqrt(exp(t_m)) ^ t_m))
end
t_m = abs(t);
function tmp = code(x, y, z, t_m)
	tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * (sqrt(exp(t_m)) ^ t_m);
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[Sqrt[N[Exp[t$95$m], $MachinePrecision]], $MachinePrecision], t$95$m], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot {\left(\sqrt{e^{t\_m}}\right)}^{t\_m}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
  2. Applied rewrites99.5%

    \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{{\left(\sqrt{e^{t}}\right)}^{t}} \]
  3. Add Preprocessing

Alternative 2: 99.8% accurate, 0.8× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{{\left(e^{t\_m}\right)}^{t\_m}}\right) \cdot \sqrt{z + z} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (* (* (- (* x 0.5) y) (sqrt (pow (exp t_m) t_m))) (sqrt (+ z z))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	return (((x * 0.5) - y) * sqrt(pow(exp(t_m), t_m))) * sqrt((z + z));
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    code = (((x * 0.5d0) - y) * sqrt((exp(t_m) ** t_m))) * sqrt((z + z))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	return (((x * 0.5) - y) * Math.sqrt(Math.pow(Math.exp(t_m), t_m))) * Math.sqrt((z + z));
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	return (((x * 0.5) - y) * math.sqrt(math.pow(math.exp(t_m), t_m))) * math.sqrt((z + z))
t_m = abs(t)
function code(x, y, z, t_m)
	return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt((exp(t_m) ^ t_m))) * sqrt(Float64(z + z)))
end
t_m = abs(t);
function tmp = code(x, y, z, t_m)
	tmp = (((x * 0.5) - y) * sqrt((exp(t_m) ^ t_m))) * sqrt((z + z));
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[Power[N[Exp[t$95$m], $MachinePrecision], t$95$m], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{{\left(e^{t\_m}\right)}^{t\_m}}\right) \cdot \sqrt{z + z}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
  2. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t \cdot t}}\right) \cdot \sqrt{z + z}} \]
  3. Applied rewrites99.8%

    \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{\color{blue}{{\left(e^{t}\right)}^{t}}}\right) \cdot \sqrt{z + z} \]
  4. Add Preprocessing

Alternative 3: 99.8% accurate, 1.1× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t\_m \cdot t\_m}}\right) \cdot \sqrt{z + z} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (* (* (- (* x 0.5) y) (sqrt (exp (* t_m t_m)))) (sqrt (+ z z))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	return (((x * 0.5) - y) * sqrt(exp((t_m * t_m)))) * sqrt((z + z));
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    code = (((x * 0.5d0) - y) * sqrt(exp((t_m * t_m)))) * sqrt((z + z))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	return (((x * 0.5) - y) * Math.sqrt(Math.exp((t_m * t_m)))) * Math.sqrt((z + z));
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	return (((x * 0.5) - y) * math.sqrt(math.exp((t_m * t_m)))) * math.sqrt((z + z))
t_m = abs(t)
function code(x, y, z, t_m)
	return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(exp(Float64(t_m * t_m)))) * sqrt(Float64(z + z)))
end
t_m = abs(t);
function tmp = code(x, y, z, t_m)
	tmp = (((x * 0.5) - y) * sqrt(exp((t_m * t_m)))) * sqrt((z + z));
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[Exp[N[(t$95$m * t$95$m), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t\_m \cdot t\_m}}\right) \cdot \sqrt{z + z}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
  2. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t \cdot t}}\right) \cdot \sqrt{z + z}} \]
  3. Add Preprocessing

Alternative 4: 99.5% accurate, 1.1× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t\_m \cdot t\_m} \cdot \left(z + z\right)} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (* (- (* x 0.5) y) (sqrt (* (exp (* t_m t_m)) (+ z z)))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	return ((x * 0.5) - y) * sqrt((exp((t_m * t_m)) * (z + z)));
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    code = ((x * 0.5d0) - y) * sqrt((exp((t_m * t_m)) * (z + z)))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	return ((x * 0.5) - y) * Math.sqrt((Math.exp((t_m * t_m)) * (z + z)));
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	return ((x * 0.5) - y) * math.sqrt((math.exp((t_m * t_m)) * (z + z)))
t_m = abs(t)
function code(x, y, z, t_m)
	return Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(exp(Float64(t_m * t_m)) * Float64(z + z))))
end
t_m = abs(t);
function tmp = code(x, y, z, t_m)
	tmp = ((x * 0.5) - y) * sqrt((exp((t_m * t_m)) * (z + z)));
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(N[Exp[N[(t$95$m * t$95$m), $MachinePrecision]], $MachinePrecision] * N[(z + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t\_m \cdot t\_m} \cdot \left(z + z\right)}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
  2. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t \cdot t} \cdot \left(z + z\right)}} \]
  3. Add Preprocessing

Alternative 5: 87.2% accurate, 1.0× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} t_1 := \sqrt{z + z}\\ \mathbf{if}\;t\_m \leq 0.00014:\\ \;\;\;\;\left(\left(x \cdot 0.5 - y\right) \cdot t\_1\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-1 \cdot y\right) \cdot \sqrt{e^{t\_m \cdot t\_m}}\right) \cdot t\_1\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (let* ((t_1 (sqrt (+ z z))))
   (if (<= t_m 0.00014)
     (* (* (- (* x 0.5) y) t_1) 1.0)
     (* (* (* -1.0 y) (sqrt (exp (* t_m t_m)))) t_1))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double t_1 = sqrt((z + z));
	double tmp;
	if (t_m <= 0.00014) {
		tmp = (((x * 0.5) - y) * t_1) * 1.0;
	} else {
		tmp = ((-1.0 * y) * sqrt(exp((t_m * t_m)))) * t_1;
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: t_1
    real(8) :: tmp
    t_1 = sqrt((z + z))
    if (t_m <= 0.00014d0) then
        tmp = (((x * 0.5d0) - y) * t_1) * 1.0d0
    else
        tmp = (((-1.0d0) * y) * sqrt(exp((t_m * t_m)))) * t_1
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double t_1 = Math.sqrt((z + z));
	double tmp;
	if (t_m <= 0.00014) {
		tmp = (((x * 0.5) - y) * t_1) * 1.0;
	} else {
		tmp = ((-1.0 * y) * Math.sqrt(Math.exp((t_m * t_m)))) * t_1;
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	t_1 = math.sqrt((z + z))
	tmp = 0
	if t_m <= 0.00014:
		tmp = (((x * 0.5) - y) * t_1) * 1.0
	else:
		tmp = ((-1.0 * y) * math.sqrt(math.exp((t_m * t_m)))) * t_1
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	t_1 = sqrt(Float64(z + z))
	tmp = 0.0
	if (t_m <= 0.00014)
		tmp = Float64(Float64(Float64(Float64(x * 0.5) - y) * t_1) * 1.0);
	else
		tmp = Float64(Float64(Float64(-1.0 * y) * sqrt(exp(Float64(t_m * t_m)))) * t_1);
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	t_1 = sqrt((z + z));
	tmp = 0.0;
	if (t_m <= 0.00014)
		tmp = (((x * 0.5) - y) * t_1) * 1.0;
	else
		tmp = ((-1.0 * y) * sqrt(exp((t_m * t_m)))) * t_1;
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := Block[{t$95$1 = N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$m, 0.00014], N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * t$95$1), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(-1.0 * y), $MachinePrecision] * N[Sqrt[N[Exp[N[(t$95$m * t$95$m), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
t_1 := \sqrt{z + z}\\
\mathbf{if}\;t\_m \leq 0.00014:\\
\;\;\;\;\left(\left(x \cdot 0.5 - y\right) \cdot t\_1\right) \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\left(\left(-1 \cdot y\right) \cdot \sqrt{e^{t\_m \cdot t\_m}}\right) \cdot t\_1\\


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

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites57.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]

    if 1.3999999999999999e-4 < t

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Applied rewrites99.8%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t \cdot t}}\right) \cdot \sqrt{z + z}} \]
    3. Taylor expanded in x around 0

      \[\leadsto \left(\color{blue}{\left(-1 \cdot y\right)} \cdot \sqrt{e^{t \cdot t}}\right) \cdot \sqrt{z + z} \]
    4. Applied rewrites63.1%

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

Alternative 6: 87.2% accurate, 1.1× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} \mathbf{if}\;t\_m \leq 0.00014:\\ \;\;\;\;\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\left(-1 \cdot y\right) \cdot \sqrt{e^{t\_m \cdot t\_m} \cdot \left(z + z\right)}\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (if (<= t_m 0.00014)
   (* (* (- (* x 0.5) y) (sqrt (+ z z))) 1.0)
   (* (* -1.0 y) (sqrt (* (exp (* t_m t_m)) (+ z z))))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double tmp;
	if (t_m <= 0.00014) {
		tmp = (((x * 0.5) - y) * sqrt((z + z))) * 1.0;
	} else {
		tmp = (-1.0 * y) * sqrt((exp((t_m * t_m)) * (z + z)));
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: tmp
    if (t_m <= 0.00014d0) then
        tmp = (((x * 0.5d0) - y) * sqrt((z + z))) * 1.0d0
    else
        tmp = ((-1.0d0) * y) * sqrt((exp((t_m * t_m)) * (z + z)))
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double tmp;
	if (t_m <= 0.00014) {
		tmp = (((x * 0.5) - y) * Math.sqrt((z + z))) * 1.0;
	} else {
		tmp = (-1.0 * y) * Math.sqrt((Math.exp((t_m * t_m)) * (z + z)));
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	tmp = 0
	if t_m <= 0.00014:
		tmp = (((x * 0.5) - y) * math.sqrt((z + z))) * 1.0
	else:
		tmp = (-1.0 * y) * math.sqrt((math.exp((t_m * t_m)) * (z + z)))
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	tmp = 0.0
	if (t_m <= 0.00014)
		tmp = Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z + z))) * 1.0);
	else
		tmp = Float64(Float64(-1.0 * y) * sqrt(Float64(exp(Float64(t_m * t_m)) * Float64(z + z))));
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	tmp = 0.0;
	if (t_m <= 0.00014)
		tmp = (((x * 0.5) - y) * sqrt((z + z))) * 1.0;
	else
		tmp = (-1.0 * y) * sqrt((exp((t_m * t_m)) * (z + z)));
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := If[LessEqual[t$95$m, 0.00014], N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(-1.0 * y), $MachinePrecision] * N[Sqrt[N[(N[Exp[N[(t$95$m * t$95$m), $MachinePrecision]], $MachinePrecision] * N[(z + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
\mathbf{if}\;t\_m \leq 0.00014:\\
\;\;\;\;\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \sqrt{e^{t\_m \cdot t\_m} \cdot \left(z + z\right)}\\


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

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites57.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]

    if 1.3999999999999999e-4 < t

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Applied rewrites99.8%

      \[\leadsto \color{blue}{\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{t \cdot t} \cdot \left(z + z\right)}} \]
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(-1 \cdot y\right)} \cdot \sqrt{e^{t \cdot t} \cdot \left(z + z\right)} \]
    4. Applied rewrites63.1%

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

Alternative 7: 65.6% accurate, 0.9× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} t_1 := x \cdot 0.5 - y\\ t_2 := \left(t\_1 \cdot \sqrt{\sqrt{\left(z + z\right) \cdot \left(z + z\right)}}\right) \cdot 1\\ \mathbf{if}\;t\_m \leq 0.28:\\ \;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\ \mathbf{elif}\;t\_m \leq 4.8 \cdot 10^{+56}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_m \leq 2 \cdot 10^{+118}:\\ \;\;\;\;\left(t\_1 \cdot \left(z \cdot \sqrt{\frac{z + z}{z \cdot z}}\right)\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (let* ((t_1 (- (* x 0.5) y))
        (t_2 (* (* t_1 (sqrt (sqrt (* (+ z z) (+ z z))))) 1.0)))
   (if (<= t_m 0.28)
     (* (* t_1 (sqrt (+ z z))) 1.0)
     (if (<= t_m 4.8e+56)
       t_2
       (if (<= t_m 2e+118)
         (* (* t_1 (* z (sqrt (/ (+ z z) (* z z))))) 1.0)
         t_2)))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double t_2 = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0;
	double tmp;
	if (t_m <= 0.28) {
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	} else if (t_m <= 4.8e+56) {
		tmp = t_2;
	} else if (t_m <= 2e+118) {
		tmp = (t_1 * (z * sqrt(((z + z) / (z * z))))) * 1.0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (x * 0.5d0) - y
    t_2 = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0d0
    if (t_m <= 0.28d0) then
        tmp = (t_1 * sqrt((z + z))) * 1.0d0
    else if (t_m <= 4.8d+56) then
        tmp = t_2
    else if (t_m <= 2d+118) then
        tmp = (t_1 * (z * sqrt(((z + z) / (z * z))))) * 1.0d0
    else
        tmp = t_2
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double t_2 = (t_1 * Math.sqrt(Math.sqrt(((z + z) * (z + z))))) * 1.0;
	double tmp;
	if (t_m <= 0.28) {
		tmp = (t_1 * Math.sqrt((z + z))) * 1.0;
	} else if (t_m <= 4.8e+56) {
		tmp = t_2;
	} else if (t_m <= 2e+118) {
		tmp = (t_1 * (z * Math.sqrt(((z + z) / (z * z))))) * 1.0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	t_1 = (x * 0.5) - y
	t_2 = (t_1 * math.sqrt(math.sqrt(((z + z) * (z + z))))) * 1.0
	tmp = 0
	if t_m <= 0.28:
		tmp = (t_1 * math.sqrt((z + z))) * 1.0
	elif t_m <= 4.8e+56:
		tmp = t_2
	elif t_m <= 2e+118:
		tmp = (t_1 * (z * math.sqrt(((z + z) / (z * z))))) * 1.0
	else:
		tmp = t_2
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	t_1 = Float64(Float64(x * 0.5) - y)
	t_2 = Float64(Float64(t_1 * sqrt(sqrt(Float64(Float64(z + z) * Float64(z + z))))) * 1.0)
	tmp = 0.0
	if (t_m <= 0.28)
		tmp = Float64(Float64(t_1 * sqrt(Float64(z + z))) * 1.0);
	elseif (t_m <= 4.8e+56)
		tmp = t_2;
	elseif (t_m <= 2e+118)
		tmp = Float64(Float64(t_1 * Float64(z * sqrt(Float64(Float64(z + z) / Float64(z * z))))) * 1.0);
	else
		tmp = t_2;
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	t_1 = (x * 0.5) - y;
	t_2 = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0;
	tmp = 0.0;
	if (t_m <= 0.28)
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	elseif (t_m <= 4.8e+56)
		tmp = t_2;
	elseif (t_m <= 2e+118)
		tmp = (t_1 * (z * sqrt(((z + z) / (z * z))))) * 1.0;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[Sqrt[N[Sqrt[N[(N[(z + z), $MachinePrecision] * N[(z + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[t$95$m, 0.28], N[(N[(t$95$1 * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$m, 4.8e+56], t$95$2, If[LessEqual[t$95$m, 2e+118], N[(N[(t$95$1 * N[(z * N[Sqrt[N[(N[(z + z), $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
t_1 := x \cdot 0.5 - y\\
t_2 := \left(t\_1 \cdot \sqrt{\sqrt{\left(z + z\right) \cdot \left(z + z\right)}}\right) \cdot 1\\
\mathbf{if}\;t\_m \leq 0.28:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\

\mathbf{elif}\;t\_m \leq 4.8 \cdot 10^{+56}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_m \leq 2 \cdot 10^{+118}:\\
\;\;\;\;\left(t\_1 \cdot \left(z \cdot \sqrt{\frac{z + z}{z \cdot z}}\right)\right) \cdot 1\\

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


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

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites57.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]

    if 0.28000000000000003 < t < 4.80000000000000027e56 or 1.99999999999999993e118 < t

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites46.7%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{\color{blue}{\sqrt{\left(z + z\right) \cdot \left(z + z\right)}}}\right) \cdot 1 \]

    if 4.80000000000000027e56 < t < 1.99999999999999993e118

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Taylor expanded in z around inf

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \color{blue}{\left(z \cdot \sqrt{\frac{2}{z}}\right)}\right) \cdot 1 \]
    5. Applied rewrites57.5%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \color{blue}{\left(z \cdot \sqrt{\frac{2}{z}}\right)}\right) \cdot 1 \]
    6. Applied rewrites40.6%

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

Alternative 8: 65.3% accurate, 0.9× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} t_1 := x \cdot 0.5 - y\\ t_2 := \left(t\_1 \cdot \sqrt{\sqrt{\left(z + z\right) \cdot \left(z + z\right)}}\right) \cdot 1\\ \mathbf{if}\;t\_m \leq 0.28:\\ \;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\ \mathbf{elif}\;t\_m \leq 3.25 \cdot 10^{+56}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_m \leq 3.5 \cdot 10^{+129}:\\ \;\;\;\;\left(z \cdot \left(\sqrt{\frac{2}{z \cdot z} \cdot z} \cdot \left(0.5 \cdot x - y\right)\right)\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (let* ((t_1 (- (* x 0.5) y))
        (t_2 (* (* t_1 (sqrt (sqrt (* (+ z z) (+ z z))))) 1.0)))
   (if (<= t_m 0.28)
     (* (* t_1 (sqrt (+ z z))) 1.0)
     (if (<= t_m 3.25e+56)
       t_2
       (if (<= t_m 3.5e+129)
         (* (* z (* (sqrt (* (/ 2.0 (* z z)) z)) (- (* 0.5 x) y))) 1.0)
         t_2)))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double t_2 = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0;
	double tmp;
	if (t_m <= 0.28) {
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	} else if (t_m <= 3.25e+56) {
		tmp = t_2;
	} else if (t_m <= 3.5e+129) {
		tmp = (z * (sqrt(((2.0 / (z * z)) * z)) * ((0.5 * x) - y))) * 1.0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (x * 0.5d0) - y
    t_2 = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0d0
    if (t_m <= 0.28d0) then
        tmp = (t_1 * sqrt((z + z))) * 1.0d0
    else if (t_m <= 3.25d+56) then
        tmp = t_2
    else if (t_m <= 3.5d+129) then
        tmp = (z * (sqrt(((2.0d0 / (z * z)) * z)) * ((0.5d0 * x) - y))) * 1.0d0
    else
        tmp = t_2
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double t_2 = (t_1 * Math.sqrt(Math.sqrt(((z + z) * (z + z))))) * 1.0;
	double tmp;
	if (t_m <= 0.28) {
		tmp = (t_1 * Math.sqrt((z + z))) * 1.0;
	} else if (t_m <= 3.25e+56) {
		tmp = t_2;
	} else if (t_m <= 3.5e+129) {
		tmp = (z * (Math.sqrt(((2.0 / (z * z)) * z)) * ((0.5 * x) - y))) * 1.0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	t_1 = (x * 0.5) - y
	t_2 = (t_1 * math.sqrt(math.sqrt(((z + z) * (z + z))))) * 1.0
	tmp = 0
	if t_m <= 0.28:
		tmp = (t_1 * math.sqrt((z + z))) * 1.0
	elif t_m <= 3.25e+56:
		tmp = t_2
	elif t_m <= 3.5e+129:
		tmp = (z * (math.sqrt(((2.0 / (z * z)) * z)) * ((0.5 * x) - y))) * 1.0
	else:
		tmp = t_2
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	t_1 = Float64(Float64(x * 0.5) - y)
	t_2 = Float64(Float64(t_1 * sqrt(sqrt(Float64(Float64(z + z) * Float64(z + z))))) * 1.0)
	tmp = 0.0
	if (t_m <= 0.28)
		tmp = Float64(Float64(t_1 * sqrt(Float64(z + z))) * 1.0);
	elseif (t_m <= 3.25e+56)
		tmp = t_2;
	elseif (t_m <= 3.5e+129)
		tmp = Float64(Float64(z * Float64(sqrt(Float64(Float64(2.0 / Float64(z * z)) * z)) * Float64(Float64(0.5 * x) - y))) * 1.0);
	else
		tmp = t_2;
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	t_1 = (x * 0.5) - y;
	t_2 = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0;
	tmp = 0.0;
	if (t_m <= 0.28)
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	elseif (t_m <= 3.25e+56)
		tmp = t_2;
	elseif (t_m <= 3.5e+129)
		tmp = (z * (sqrt(((2.0 / (z * z)) * z)) * ((0.5 * x) - y))) * 1.0;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[Sqrt[N[Sqrt[N[(N[(z + z), $MachinePrecision] * N[(z + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[t$95$m, 0.28], N[(N[(t$95$1 * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$m, 3.25e+56], t$95$2, If[LessEqual[t$95$m, 3.5e+129], N[(N[(z * N[(N[Sqrt[N[(N[(2.0 / N[(z * z), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision] * N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
t_1 := x \cdot 0.5 - y\\
t_2 := \left(t\_1 \cdot \sqrt{\sqrt{\left(z + z\right) \cdot \left(z + z\right)}}\right) \cdot 1\\
\mathbf{if}\;t\_m \leq 0.28:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\

\mathbf{elif}\;t\_m \leq 3.25 \cdot 10^{+56}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_m \leq 3.5 \cdot 10^{+129}:\\
\;\;\;\;\left(z \cdot \left(\sqrt{\frac{2}{z \cdot z} \cdot z} \cdot \left(0.5 \cdot x - y\right)\right)\right) \cdot 1\\

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


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

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites57.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]

    if 0.28000000000000003 < t < 3.25e56 or 3.4999999999999998e129 < t

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites46.7%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{\color{blue}{\sqrt{\left(z + z\right) \cdot \left(z + z\right)}}}\right) \cdot 1 \]

    if 3.25e56 < t < 3.4999999999999998e129

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Taylor expanded in z around inf

      \[\leadsto \color{blue}{\left(z \cdot \left(\sqrt{\frac{2}{z}} \cdot \left(\frac{1}{2} \cdot x - y\right)\right)\right)} \cdot 1 \]
    5. Applied rewrites57.0%

      \[\leadsto \color{blue}{\left(z \cdot \left(\sqrt{\frac{2}{z}} \cdot \left(0.5 \cdot x - y\right)\right)\right)} \cdot 1 \]
    6. Applied rewrites40.8%

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

Alternative 9: 65.3% accurate, 1.2× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} t_1 := x \cdot 0.5 - y\\ \mathbf{if}\;t\_m \leq 1.14 \cdot 10^{-7}:\\ \;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\left(t\_1 \cdot \sqrt{\sqrt{\left(z + z\right) \cdot \left(z + z\right)}}\right) \cdot 1\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (let* ((t_1 (- (* x 0.5) y)))
   (if (<= t_m 1.14e-7)
     (* (* t_1 (sqrt (+ z z))) 1.0)
     (* (* t_1 (sqrt (sqrt (* (+ z z) (+ z z))))) 1.0))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double tmp;
	if (t_m <= 1.14e-7) {
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	} else {
		tmp = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0;
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x * 0.5d0) - y
    if (t_m <= 1.14d-7) then
        tmp = (t_1 * sqrt((z + z))) * 1.0d0
    else
        tmp = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0d0
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double tmp;
	if (t_m <= 1.14e-7) {
		tmp = (t_1 * Math.sqrt((z + z))) * 1.0;
	} else {
		tmp = (t_1 * Math.sqrt(Math.sqrt(((z + z) * (z + z))))) * 1.0;
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	t_1 = (x * 0.5) - y
	tmp = 0
	if t_m <= 1.14e-7:
		tmp = (t_1 * math.sqrt((z + z))) * 1.0
	else:
		tmp = (t_1 * math.sqrt(math.sqrt(((z + z) * (z + z))))) * 1.0
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	t_1 = Float64(Float64(x * 0.5) - y)
	tmp = 0.0
	if (t_m <= 1.14e-7)
		tmp = Float64(Float64(t_1 * sqrt(Float64(z + z))) * 1.0);
	else
		tmp = Float64(Float64(t_1 * sqrt(sqrt(Float64(Float64(z + z) * Float64(z + z))))) * 1.0);
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	t_1 = (x * 0.5) - y;
	tmp = 0.0;
	if (t_m <= 1.14e-7)
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	else
		tmp = (t_1 * sqrt(sqrt(((z + z) * (z + z))))) * 1.0;
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t$95$m, 1.14e-7], N[(N[(t$95$1 * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(t$95$1 * N[Sqrt[N[Sqrt[N[(N[(z + z), $MachinePrecision] * N[(z + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
t_1 := x \cdot 0.5 - y\\
\mathbf{if}\;t\_m \leq 1.14 \cdot 10^{-7}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{\sqrt{\left(z + z\right) \cdot \left(z + z\right)}}\right) \cdot 1\\


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

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites57.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]

    if 1.14000000000000002e-7 < t

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites46.7%

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

Alternative 10: 62.8% accurate, 0.8× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} t_1 := x \cdot 0.5 - y\\ \mathbf{if}\;e^{\frac{t\_m \cdot t\_m}{2}} \leq 1.02:\\ \;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(t\_1 \cdot z\right) \cdot \sqrt{\frac{2}{z}}\right) \cdot 1\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (let* ((t_1 (- (* x 0.5) y)))
   (if (<= (exp (/ (* t_m t_m) 2.0)) 1.02)
     (* (* t_1 (sqrt (+ z z))) 1.0)
     (* (* (* t_1 z) (sqrt (/ 2.0 z))) 1.0))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double tmp;
	if (exp(((t_m * t_m) / 2.0)) <= 1.02) {
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	} else {
		tmp = ((t_1 * z) * sqrt((2.0 / z))) * 1.0;
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x * 0.5d0) - y
    if (exp(((t_m * t_m) / 2.0d0)) <= 1.02d0) then
        tmp = (t_1 * sqrt((z + z))) * 1.0d0
    else
        tmp = ((t_1 * z) * sqrt((2.0d0 / z))) * 1.0d0
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double tmp;
	if (Math.exp(((t_m * t_m) / 2.0)) <= 1.02) {
		tmp = (t_1 * Math.sqrt((z + z))) * 1.0;
	} else {
		tmp = ((t_1 * z) * Math.sqrt((2.0 / z))) * 1.0;
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	t_1 = (x * 0.5) - y
	tmp = 0
	if math.exp(((t_m * t_m) / 2.0)) <= 1.02:
		tmp = (t_1 * math.sqrt((z + z))) * 1.0
	else:
		tmp = ((t_1 * z) * math.sqrt((2.0 / z))) * 1.0
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	t_1 = Float64(Float64(x * 0.5) - y)
	tmp = 0.0
	if (exp(Float64(Float64(t_m * t_m) / 2.0)) <= 1.02)
		tmp = Float64(Float64(t_1 * sqrt(Float64(z + z))) * 1.0);
	else
		tmp = Float64(Float64(Float64(t_1 * z) * sqrt(Float64(2.0 / z))) * 1.0);
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	t_1 = (x * 0.5) - y;
	tmp = 0.0;
	if (exp(((t_m * t_m) / 2.0)) <= 1.02)
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	else
		tmp = ((t_1 * z) * sqrt((2.0 / z))) * 1.0;
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[N[Exp[N[(N[(t$95$m * t$95$m), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 1.02], N[(N[(t$95$1 * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(t$95$1 * z), $MachinePrecision] * N[Sqrt[N[(2.0 / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
t_1 := x \cdot 0.5 - y\\
\mathbf{if}\;e^{\frac{t\_m \cdot t\_m}{2}} \leq 1.02:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\left(\left(t\_1 \cdot z\right) \cdot \sqrt{\frac{2}{z}}\right) \cdot 1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 (/.f64 (*.f64 t t) #s(literal 2 binary64))) < 1.02

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites57.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]

    if 1.02 < (exp.f64 (/.f64 (*.f64 t t) #s(literal 2 binary64)))

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Taylor expanded in z around inf

      \[\leadsto \color{blue}{\left(z \cdot \left(\sqrt{\frac{2}{z}} \cdot \left(\frac{1}{2} \cdot x - y\right)\right)\right)} \cdot 1 \]
    5. Applied rewrites57.0%

      \[\leadsto \color{blue}{\left(z \cdot \left(\sqrt{\frac{2}{z}} \cdot \left(0.5 \cdot x - y\right)\right)\right)} \cdot 1 \]
    6. Applied rewrites56.0%

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

Alternative 11: 62.1% accurate, 0.8× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} t_1 := x \cdot 0.5 - y\\ \mathbf{if}\;e^{\frac{t\_m \cdot t\_m}{2}} \leq 1.02:\\ \;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\sqrt{\frac{2}{z}} \cdot t\_1\right) \cdot z\right) \cdot 1\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (let* ((t_1 (- (* x 0.5) y)))
   (if (<= (exp (/ (* t_m t_m) 2.0)) 1.02)
     (* (* t_1 (sqrt (+ z z))) 1.0)
     (* (* (* (sqrt (/ 2.0 z)) t_1) z) 1.0))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double tmp;
	if (exp(((t_m * t_m) / 2.0)) <= 1.02) {
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	} else {
		tmp = ((sqrt((2.0 / z)) * t_1) * z) * 1.0;
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x * 0.5d0) - y
    if (exp(((t_m * t_m) / 2.0d0)) <= 1.02d0) then
        tmp = (t_1 * sqrt((z + z))) * 1.0d0
    else
        tmp = ((sqrt((2.0d0 / z)) * t_1) * z) * 1.0d0
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double t_1 = (x * 0.5) - y;
	double tmp;
	if (Math.exp(((t_m * t_m) / 2.0)) <= 1.02) {
		tmp = (t_1 * Math.sqrt((z + z))) * 1.0;
	} else {
		tmp = ((Math.sqrt((2.0 / z)) * t_1) * z) * 1.0;
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	t_1 = (x * 0.5) - y
	tmp = 0
	if math.exp(((t_m * t_m) / 2.0)) <= 1.02:
		tmp = (t_1 * math.sqrt((z + z))) * 1.0
	else:
		tmp = ((math.sqrt((2.0 / z)) * t_1) * z) * 1.0
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	t_1 = Float64(Float64(x * 0.5) - y)
	tmp = 0.0
	if (exp(Float64(Float64(t_m * t_m) / 2.0)) <= 1.02)
		tmp = Float64(Float64(t_1 * sqrt(Float64(z + z))) * 1.0);
	else
		tmp = Float64(Float64(Float64(sqrt(Float64(2.0 / z)) * t_1) * z) * 1.0);
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	t_1 = (x * 0.5) - y;
	tmp = 0.0;
	if (exp(((t_m * t_m) / 2.0)) <= 1.02)
		tmp = (t_1 * sqrt((z + z))) * 1.0;
	else
		tmp = ((sqrt((2.0 / z)) * t_1) * z) * 1.0;
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[N[Exp[N[(N[(t$95$m * t$95$m), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 1.02], N[(N[(t$95$1 * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(N[Sqrt[N[(2.0 / z), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] * z), $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
t_1 := x \cdot 0.5 - y\\
\mathbf{if}\;e^{\frac{t\_m \cdot t\_m}{2}} \leq 1.02:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{z + z}\right) \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\sqrt{\frac{2}{z}} \cdot t\_1\right) \cdot z\right) \cdot 1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 (/.f64 (*.f64 t t) #s(literal 2 binary64))) < 1.02

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites57.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]

    if 1.02 < (exp.f64 (/.f64 (*.f64 t t) #s(literal 2 binary64)))

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Taylor expanded in z around inf

      \[\leadsto \color{blue}{\left(z \cdot \left(\sqrt{\frac{2}{z}} \cdot \left(\frac{1}{2} \cdot x - y\right)\right)\right)} \cdot 1 \]
    5. Applied rewrites57.0%

      \[\leadsto \color{blue}{\left(z \cdot \left(\sqrt{\frac{2}{z}} \cdot \left(0.5 \cdot x - y\right)\right)\right)} \cdot 1 \]
    6. Applied rewrites57.0%

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

Alternative 12: 57.6% accurate, 1.5× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} \mathbf{if}\;t\_m \leq 1.85 \cdot 10^{+20}:\\ \;\;\;\;\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot \left(0.5 \cdot \left(x \cdot \sqrt{\frac{2}{z}}\right)\right)\right) \cdot 1\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (if (<= t_m 1.85e+20)
   (* (* (- (* x 0.5) y) (sqrt (+ z z))) 1.0)
   (* (* z (* 0.5 (* x (sqrt (/ 2.0 z))))) 1.0)))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double tmp;
	if (t_m <= 1.85e+20) {
		tmp = (((x * 0.5) - y) * sqrt((z + z))) * 1.0;
	} else {
		tmp = (z * (0.5 * (x * sqrt((2.0 / z))))) * 1.0;
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: tmp
    if (t_m <= 1.85d+20) then
        tmp = (((x * 0.5d0) - y) * sqrt((z + z))) * 1.0d0
    else
        tmp = (z * (0.5d0 * (x * sqrt((2.0d0 / z))))) * 1.0d0
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double tmp;
	if (t_m <= 1.85e+20) {
		tmp = (((x * 0.5) - y) * Math.sqrt((z + z))) * 1.0;
	} else {
		tmp = (z * (0.5 * (x * Math.sqrt((2.0 / z))))) * 1.0;
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	tmp = 0
	if t_m <= 1.85e+20:
		tmp = (((x * 0.5) - y) * math.sqrt((z + z))) * 1.0
	else:
		tmp = (z * (0.5 * (x * math.sqrt((2.0 / z))))) * 1.0
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	tmp = 0.0
	if (t_m <= 1.85e+20)
		tmp = Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z + z))) * 1.0);
	else
		tmp = Float64(Float64(z * Float64(0.5 * Float64(x * sqrt(Float64(2.0 / z))))) * 1.0);
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	tmp = 0.0;
	if (t_m <= 1.85e+20)
		tmp = (((x * 0.5) - y) * sqrt((z + z))) * 1.0;
	else
		tmp = (z * (0.5 * (x * sqrt((2.0 / z))))) * 1.0;
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := If[LessEqual[t$95$m, 1.85e+20], N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(z * N[(0.5 * N[(x * N[Sqrt[N[(2.0 / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
\mathbf{if}\;t\_m \leq 1.85 \cdot 10^{+20}:\\
\;\;\;\;\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(0.5 \cdot \left(x \cdot \sqrt{\frac{2}{z}}\right)\right)\right) \cdot 1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 1.85e20

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Applied rewrites57.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]

    if 1.85e20 < t

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Taylor expanded in z around inf

      \[\leadsto \color{blue}{\left(z \cdot \left(\sqrt{\frac{2}{z}} \cdot \left(\frac{1}{2} \cdot x - y\right)\right)\right)} \cdot 1 \]
    5. Applied rewrites57.0%

      \[\leadsto \color{blue}{\left(z \cdot \left(\sqrt{\frac{2}{z}} \cdot \left(0.5 \cdot x - y\right)\right)\right)} \cdot 1 \]
    6. Taylor expanded in x around inf

      \[\leadsto \left(z \cdot \left(\frac{1}{2} \cdot \color{blue}{\left(x \cdot \sqrt{\frac{2}{z}}\right)}\right)\right) \cdot 1 \]
    7. Applied rewrites30.1%

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

Alternative 13: 57.2% accurate, 2.0× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1 \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (* (* (- (* x 0.5) y) (sqrt (+ z z))) 1.0))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	return (((x * 0.5) - y) * sqrt((z + z))) * 1.0;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    code = (((x * 0.5d0) - y) * sqrt((z + z))) * 1.0d0
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	return (((x * 0.5) - y) * Math.sqrt((z + z))) * 1.0;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	return (((x * 0.5) - y) * math.sqrt((z + z))) * 1.0
t_m = abs(t)
function code(x, y, z, t_m)
	return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z + z))) * 1.0)
end
t_m = abs(t);
function tmp = code(x, y, z, t_m)
	tmp = (((x * 0.5) - y) * sqrt((z + z))) * 1.0;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1
\end{array}
Derivation
  1. Initial program 99.5%

    \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
  2. Taylor expanded in t around 0

    \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
  3. Applied rewrites57.6%

    \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
  4. Applied rewrites57.6%

    \[\leadsto \color{blue}{\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z + z}\right) \cdot 1} \]
  5. Add Preprocessing

Alternative 14: 43.4% accurate, 1.5× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \begin{array}{l} t_1 := \left(\left(\sqrt{z + z} \cdot 0.5\right) \cdot x\right) \cdot 1\\ \mathbf{if}\;x \leq -3.1 \cdot 10^{+129}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-21}:\\ \;\;\;\;\left(\left(-1 \cdot y\right) \cdot \sqrt{z \cdot 2}\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m)
 :precision binary64
 (let* ((t_1 (* (* (* (sqrt (+ z z)) 0.5) x) 1.0)))
   (if (<= x -3.1e+129)
     t_1
     (if (<= x 1.4e-21) (* (* (* -1.0 y) (sqrt (* z 2.0))) 1.0) t_1))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	double t_1 = ((sqrt((z + z)) * 0.5) * x) * 1.0;
	double tmp;
	if (x <= -3.1e+129) {
		tmp = t_1;
	} else if (x <= 1.4e-21) {
		tmp = ((-1.0 * y) * sqrt((z * 2.0))) * 1.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((sqrt((z + z)) * 0.5d0) * x) * 1.0d0
    if (x <= (-3.1d+129)) then
        tmp = t_1
    else if (x <= 1.4d-21) then
        tmp = (((-1.0d0) * y) * sqrt((z * 2.0d0))) * 1.0d0
    else
        tmp = t_1
    end if
    code = tmp
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	double t_1 = ((Math.sqrt((z + z)) * 0.5) * x) * 1.0;
	double tmp;
	if (x <= -3.1e+129) {
		tmp = t_1;
	} else if (x <= 1.4e-21) {
		tmp = ((-1.0 * y) * Math.sqrt((z * 2.0))) * 1.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	t_1 = ((math.sqrt((z + z)) * 0.5) * x) * 1.0
	tmp = 0
	if x <= -3.1e+129:
		tmp = t_1
	elif x <= 1.4e-21:
		tmp = ((-1.0 * y) * math.sqrt((z * 2.0))) * 1.0
	else:
		tmp = t_1
	return tmp
t_m = abs(t)
function code(x, y, z, t_m)
	t_1 = Float64(Float64(Float64(sqrt(Float64(z + z)) * 0.5) * x) * 1.0)
	tmp = 0.0
	if (x <= -3.1e+129)
		tmp = t_1;
	elseif (x <= 1.4e-21)
		tmp = Float64(Float64(Float64(-1.0 * y) * sqrt(Float64(z * 2.0))) * 1.0);
	else
		tmp = t_1;
	end
	return tmp
end
t_m = abs(t);
function tmp_2 = code(x, y, z, t_m)
	t_1 = ((sqrt((z + z)) * 0.5) * x) * 1.0;
	tmp = 0.0;
	if (x <= -3.1e+129)
		tmp = t_1;
	elseif (x <= 1.4e-21)
		tmp = ((-1.0 * y) * sqrt((z * 2.0))) * 1.0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := Block[{t$95$1 = N[(N[(N[(N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] * x), $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[x, -3.1e+129], t$95$1, If[LessEqual[x, 1.4e-21], N[(N[(N[(-1.0 * y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_m = \left|t\right|

\\
\begin{array}{l}
t_1 := \left(\left(\sqrt{z + z} \cdot 0.5\right) \cdot x\right) \cdot 1\\
\mathbf{if}\;x \leq -3.1 \cdot 10^{+129}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-21}:\\
\;\;\;\;\left(\left(-1 \cdot y\right) \cdot \sqrt{z \cdot 2}\right) \cdot 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.1e129 or 1.40000000000000002e-21 < x

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \left(x \cdot \sqrt{2 \cdot z}\right)\right)} \cdot 1 \]
    5. Applied rewrites30.1%

      \[\leadsto \color{blue}{\left(0.5 \cdot \left(x \cdot \sqrt{2 \cdot z}\right)\right)} \cdot 1 \]
    6. Applied rewrites30.1%

      \[\leadsto \left(\left(\sqrt{z + z} \cdot 0.5\right) \cdot \color{blue}{x}\right) \cdot 1 \]

    if -3.1e129 < x < 1.40000000000000002e-21

    1. Initial program 99.5%

      \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
    2. Taylor expanded in t around 0

      \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    3. Applied rewrites57.6%

      \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
    4. Taylor expanded in x around 0

      \[\leadsto \left(\color{blue}{\left(-1 \cdot y\right)} \cdot \sqrt{z \cdot 2}\right) \cdot 1 \]
    5. Applied rewrites30.0%

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

Alternative 15: 30.1% accurate, 2.3× speedup?

\[\begin{array}{l} t_m = \left|t\right| \\ \left(\left(\sqrt{z + z} \cdot 0.5\right) \cdot x\right) \cdot 1 \end{array} \]
t_m = (fabs.f64 t)
(FPCore (x y z t_m) :precision binary64 (* (* (* (sqrt (+ z z)) 0.5) x) 1.0))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
	return ((sqrt((z + z)) * 0.5) * x) * 1.0;
}
t_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t_m
    code = ((sqrt((z + z)) * 0.5d0) * x) * 1.0d0
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
	return ((Math.sqrt((z + z)) * 0.5) * x) * 1.0;
}
t_m = math.fabs(t)
def code(x, y, z, t_m):
	return ((math.sqrt((z + z)) * 0.5) * x) * 1.0
t_m = abs(t)
function code(x, y, z, t_m)
	return Float64(Float64(Float64(sqrt(Float64(z + z)) * 0.5) * x) * 1.0)
end
t_m = abs(t);
function tmp = code(x, y, z, t_m)
	tmp = ((sqrt((z + z)) * 0.5) * x) * 1.0;
end
t_m = N[Abs[t], $MachinePrecision]
code[x_, y_, z_, t$95$m_] := N[(N[(N[(N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] * x), $MachinePrecision] * 1.0), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|

\\
\left(\left(\sqrt{z + z} \cdot 0.5\right) \cdot x\right) \cdot 1
\end{array}
Derivation
  1. Initial program 99.5%

    \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
  2. Taylor expanded in t around 0

    \[\leadsto \left(\left(x \cdot \frac{1}{2} - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
  3. Applied rewrites57.6%

    \[\leadsto \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot \color{blue}{1} \]
  4. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \left(x \cdot \sqrt{2 \cdot z}\right)\right)} \cdot 1 \]
  5. Applied rewrites30.1%

    \[\leadsto \color{blue}{\left(0.5 \cdot \left(x \cdot \sqrt{2 \cdot z}\right)\right)} \cdot 1 \]
  6. Applied rewrites30.1%

    \[\leadsto \left(\left(\sqrt{z + z} \cdot 0.5\right) \cdot \color{blue}{x}\right) \cdot 1 \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2025153 
(FPCore (x y z t)
  :name "Data.Number.Erf:$cinvnormcdf from erf-2.0.0.0, A"
  :precision binary64
  (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))