Example from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 25.2s
Alternatives: 8
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\ \left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right| \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (atan (/ (/ eh ew) (tan t)))))
   (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
	double t_1 = atan(((eh / ew) / tan(t)));
	return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: t_1
    t_1 = atan(((eh / ew) / tan(t)))
    code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
	double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
	return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t):
	t_1 = math.atan(((eh / ew) / math.tan(t)))
	return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t)
	t_1 = atan(Float64(Float64(eh / ew) / tan(t)))
	return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1))))
end
function tmp = code(eh, ew, t)
	t_1 = atan(((eh / ew) / tan(t)));
	tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 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.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\ \left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right| \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (atan (/ (/ eh ew) (tan t)))))
   (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
	double t_1 = atan(((eh / ew) / tan(t)));
	return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: t_1
    t_1 = atan(((eh / ew) / tan(t)))
    code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
	double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
	return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t):
	t_1 = math.atan(((eh / ew) / math.tan(t)))
	return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t)
	t_1 = atan(Float64(Float64(eh / ew) / tan(t)))
	return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1))))
end
function tmp = code(eh, ew, t)
	t_1 = atan(((eh / ew) / tan(t)));
	tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}

Alternative 1: 99.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right| \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (fabs
  (+
   (* (sin t) (/ ew (hypot 1.0 (/ (/ eh ew) (tan t)))))
   (* eh (* (cos t) (sin (atan (/ eh (* ew (tan t))))))))))
double code(double eh, double ew, double t) {
	return fabs(((sin(t) * (ew / hypot(1.0, ((eh / ew) / tan(t))))) + (eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))));
}
public static double code(double eh, double ew, double t) {
	return Math.abs(((Math.sin(t) * (ew / Math.hypot(1.0, ((eh / ew) / Math.tan(t))))) + (eh * (Math.cos(t) * Math.sin(Math.atan((eh / (ew * Math.tan(t)))))))));
}
def code(eh, ew, t):
	return math.fabs(((math.sin(t) * (ew / math.hypot(1.0, ((eh / ew) / math.tan(t))))) + (eh * (math.cos(t) * math.sin(math.atan((eh / (ew * math.tan(t)))))))))
function code(eh, ew, t)
	return abs(Float64(Float64(sin(t) * Float64(ew / hypot(1.0, Float64(Float64(eh / ew) / tan(t))))) + Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))))))
end
function tmp = code(eh, ew, t)
	tmp = abs(((sin(t) * (ew / hypot(1.0, ((eh / ew) / tan(t))))) + (eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))));
end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * N[(ew / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right|
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/r*99.7%

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. cos-atan99.7%

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \color{blue}{\frac{1}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    3. un-div-inv99.7%

      \[\leadsto \left|\color{blue}{\frac{ew \cdot \sin t}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    4. hypot-1-def99.7%

      \[\leadsto \left|\frac{ew \cdot \sin t}{\color{blue}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    5. associate-/r*99.7%

      \[\leadsto \left|\frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, \color{blue}{\frac{\frac{eh}{ew}}{\tan t}}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  4. Applied egg-rr99.7%

    \[\leadsto \left|\color{blue}{\frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  5. Step-by-step derivation
    1. *-commutative99.7%

      \[\leadsto \left|\frac{\color{blue}{\sin t \cdot ew}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. associate-/l*99.8%

      \[\leadsto \left|\color{blue}{\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  6. Simplified99.8%

    \[\leadsto \left|\color{blue}{\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  7. Step-by-step derivation
    1. expm1-log1p-u99.7%

      \[\leadsto \left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + \left(eh \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos t\right)\right)}\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. expm1-undefine99.7%

      \[\leadsto \left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + \left(eh \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\cos t\right)} - 1\right)}\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  8. Applied egg-rr99.7%

    \[\leadsto \left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + \left(eh \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\cos t\right)} - 1\right)}\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  9. Step-by-step derivation
    1. expm1-define99.7%

      \[\leadsto \left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + \left(eh \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos t\right)\right)}\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  10. Simplified99.7%

    \[\leadsto \left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + \left(eh \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos t\right)\right)}\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  11. Taylor expanded in eh around 0 99.8%

    \[\leadsto \left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
  12. Add Preprocessing

Alternative 2: 98.5% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \left|\sin t \cdot ew + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (fabs
  (+ (* (sin t) ew) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
	return fabs(((sin(t) * ew) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))));
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    code = abs(((sin(t) * ew) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
	return Math.abs(((Math.sin(t) * ew) + ((eh * Math.cos(t)) * Math.sin(Math.atan(((eh / ew) / Math.tan(t)))))));
}
def code(eh, ew, t):
	return math.fabs(((math.sin(t) * ew) + ((eh * math.cos(t)) * math.sin(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t)
	return abs(Float64(Float64(sin(t) * ew) + Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))))
end
function tmp = code(eh, ew, t)
	tmp = abs(((sin(t) * ew) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))));
end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|\sin t \cdot ew + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/r*99.7%

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. cos-atan99.7%

      \[\leadsto \left|\left(ew \cdot \sin t\right) \cdot \color{blue}{\frac{1}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    3. un-div-inv99.7%

      \[\leadsto \left|\color{blue}{\frac{ew \cdot \sin t}{\sqrt{1 + \frac{eh}{ew \cdot \tan t} \cdot \frac{eh}{ew \cdot \tan t}}}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    4. hypot-1-def99.7%

      \[\leadsto \left|\frac{ew \cdot \sin t}{\color{blue}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    5. associate-/r*99.7%

      \[\leadsto \left|\frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, \color{blue}{\frac{\frac{eh}{ew}}{\tan t}}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  4. Applied egg-rr99.7%

    \[\leadsto \left|\color{blue}{\frac{ew \cdot \sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  5. Step-by-step derivation
    1. *-commutative99.7%

      \[\leadsto \left|\frac{\color{blue}{\sin t \cdot ew}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. associate-/l*99.8%

      \[\leadsto \left|\color{blue}{\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  6. Simplified99.8%

    \[\leadsto \left|\color{blue}{\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  7. Taylor expanded in ew around inf 97.8%

    \[\leadsto \left|\sin t \cdot \color{blue}{ew} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  8. Add Preprocessing

Alternative 3: 74.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ew \leq -6.7 \cdot 10^{+50} \lor \neg \left(ew \leq 3.7 \cdot 10^{+90}\right):\\ \;\;\;\;\left|\sin t \cdot ew\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right|\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (if (or (<= ew -6.7e+50) (not (<= ew 3.7e+90)))
   (fabs (* (sin t) ew))
   (fabs (* (cos t) (* eh (sin (atan (/ (/ eh ew) (tan t)))))))))
double code(double eh, double ew, double t) {
	double tmp;
	if ((ew <= -6.7e+50) || !(ew <= 3.7e+90)) {
		tmp = fabs((sin(t) * ew));
	} else {
		tmp = fabs((cos(t) * (eh * sin(atan(((eh / ew) / tan(t)))))));
	}
	return tmp;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((ew <= (-6.7d+50)) .or. (.not. (ew <= 3.7d+90))) then
        tmp = abs((sin(t) * ew))
    else
        tmp = abs((cos(t) * (eh * sin(atan(((eh / ew) / tan(t)))))))
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double tmp;
	if ((ew <= -6.7e+50) || !(ew <= 3.7e+90)) {
		tmp = Math.abs((Math.sin(t) * ew));
	} else {
		tmp = Math.abs((Math.cos(t) * (eh * Math.sin(Math.atan(((eh / ew) / Math.tan(t)))))));
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if (ew <= -6.7e+50) or not (ew <= 3.7e+90):
		tmp = math.fabs((math.sin(t) * ew))
	else:
		tmp = math.fabs((math.cos(t) * (eh * math.sin(math.atan(((eh / ew) / math.tan(t)))))))
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if ((ew <= -6.7e+50) || !(ew <= 3.7e+90))
		tmp = abs(Float64(sin(t) * ew));
	else
		tmp = abs(Float64(cos(t) * Float64(eh * sin(atan(Float64(Float64(eh / ew) / tan(t)))))));
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	tmp = 0.0;
	if ((ew <= -6.7e+50) || ~((ew <= 3.7e+90)))
		tmp = abs((sin(t) * ew));
	else
		tmp = abs((cos(t) * (eh * sin(atan(((eh / ew) / tan(t)))))));
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -6.7e+50], N[Not[LessEqual[ew, 3.7e+90]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[t], $MachinePrecision] * N[(eh * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ew \leq -6.7 \cdot 10^{+50} \lor \neg \left(ew \leq 3.7 \cdot 10^{+90}\right):\\
\;\;\;\;\left|\sin t \cdot ew\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -6.6999999999999999e50 or 3.7e90 < ew

    1. Initial program 99.7%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Step-by-step derivation
      1. associate-*l*99.7%

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. fma-define99.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      3. associate-/r*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
      4. associate-*l*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
      5. associate-/r*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt97.8%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right) \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}} \]
      2. pow397.9%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right)}^{3}} \]
    6. Applied egg-rr49.8%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}, \cos t \cdot \left(\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot eh\right)\right)}\right)}^{3}} \]
    7. Taylor expanded in ew around inf 35.2%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{ew \cdot \sin t}\right)}}^{3} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt35.8%

        \[\leadsto \color{blue}{ew \cdot \sin t} \]
      2. add-sqr-sqrt35.2%

        \[\leadsto \color{blue}{\sqrt{ew \cdot \sin t} \cdot \sqrt{ew \cdot \sin t}} \]
      3. sqrt-unprod41.8%

        \[\leadsto \color{blue}{\sqrt{\left(ew \cdot \sin t\right) \cdot \left(ew \cdot \sin t\right)}} \]
      4. pow241.8%

        \[\leadsto \sqrt{\color{blue}{{\left(ew \cdot \sin t\right)}^{2}}} \]
      5. *-commutative41.8%

        \[\leadsto \sqrt{{\color{blue}{\left(\sin t \cdot ew\right)}}^{2}} \]
    9. Applied egg-rr41.8%

      \[\leadsto \color{blue}{\sqrt{{\left(\sin t \cdot ew\right)}^{2}}} \]
    10. Step-by-step derivation
      1. *-commutative41.8%

        \[\leadsto \sqrt{{\color{blue}{\left(ew \cdot \sin t\right)}}^{2}} \]
      2. unpow241.8%

        \[\leadsto \sqrt{\color{blue}{\left(ew \cdot \sin t\right) \cdot \left(ew \cdot \sin t\right)}} \]
      3. rem-sqrt-square75.0%

        \[\leadsto \color{blue}{\left|ew \cdot \sin t\right|} \]
    11. Simplified75.0%

      \[\leadsto \color{blue}{\left|ew \cdot \sin t\right|} \]

    if -6.6999999999999999e50 < ew < 3.7e90

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Step-by-step derivation
      1. associate-*l*99.8%

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. fma-define99.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      3. associate-/r*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
      4. associate-*l*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
      5. associate-/r*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in ew around 0 81.7%

      \[\leadsto \left|\color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
    6. Step-by-step derivation
      1. associate-*r*81.7%

        \[\leadsto \left|\color{blue}{\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
      2. *-commutative81.7%

        \[\leadsto \left|\color{blue}{\left(\cos t \cdot eh\right)} \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right| \]
      3. associate-*r*81.7%

        \[\leadsto \left|\color{blue}{\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)}\right| \]
      4. associate-/r*81.7%

        \[\leadsto \left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{\frac{eh}{ew}}{\tan t}\right)}\right)\right| \]
    7. Simplified81.7%

      \[\leadsto \left|\color{blue}{\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -6.7 \cdot 10^{+50} \lor \neg \left(ew \leq 3.7 \cdot 10^{+90}\right):\\ \;\;\;\;\left|\sin t \cdot ew\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\cos t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 58.3% accurate, 4.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ew \leq -4.4 \cdot 10^{+50} \lor \neg \left(ew \leq 3.9 \cdot 10^{+90}\right):\\ \;\;\;\;\left|\sin t \cdot ew\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh\right|\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (if (or (<= ew -4.4e+50) (not (<= ew 3.9e+90)))
   (fabs (* (sin t) ew))
   (fabs eh)))
double code(double eh, double ew, double t) {
	double tmp;
	if ((ew <= -4.4e+50) || !(ew <= 3.9e+90)) {
		tmp = fabs((sin(t) * ew));
	} else {
		tmp = fabs(eh);
	}
	return tmp;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((ew <= (-4.4d+50)) .or. (.not. (ew <= 3.9d+90))) then
        tmp = abs((sin(t) * ew))
    else
        tmp = abs(eh)
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double tmp;
	if ((ew <= -4.4e+50) || !(ew <= 3.9e+90)) {
		tmp = Math.abs((Math.sin(t) * ew));
	} else {
		tmp = Math.abs(eh);
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if (ew <= -4.4e+50) or not (ew <= 3.9e+90):
		tmp = math.fabs((math.sin(t) * ew))
	else:
		tmp = math.fabs(eh)
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if ((ew <= -4.4e+50) || !(ew <= 3.9e+90))
		tmp = abs(Float64(sin(t) * ew));
	else
		tmp = abs(eh);
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	tmp = 0.0;
	if ((ew <= -4.4e+50) || ~((ew <= 3.9e+90)))
		tmp = abs((sin(t) * ew));
	else
		tmp = abs(eh);
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -4.4e+50], N[Not[LessEqual[ew, 3.9e+90]], $MachinePrecision]], N[Abs[N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ew \leq -4.4 \cdot 10^{+50} \lor \neg \left(ew \leq 3.9 \cdot 10^{+90}\right):\\
\;\;\;\;\left|\sin t \cdot ew\right|\\

\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -4.40000000000000034e50 or 3.9000000000000002e90 < ew

    1. Initial program 99.7%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Step-by-step derivation
      1. associate-*l*99.7%

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. fma-define99.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      3. associate-/r*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
      4. associate-*l*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
      5. associate-/r*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt97.8%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right) \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}} \]
      2. pow397.9%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right)}^{3}} \]
    6. Applied egg-rr49.8%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}, \cos t \cdot \left(\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot eh\right)\right)}\right)}^{3}} \]
    7. Taylor expanded in ew around inf 35.2%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{ew \cdot \sin t}\right)}}^{3} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt35.8%

        \[\leadsto \color{blue}{ew \cdot \sin t} \]
      2. add-sqr-sqrt35.2%

        \[\leadsto \color{blue}{\sqrt{ew \cdot \sin t} \cdot \sqrt{ew \cdot \sin t}} \]
      3. sqrt-unprod41.8%

        \[\leadsto \color{blue}{\sqrt{\left(ew \cdot \sin t\right) \cdot \left(ew \cdot \sin t\right)}} \]
      4. pow241.8%

        \[\leadsto \sqrt{\color{blue}{{\left(ew \cdot \sin t\right)}^{2}}} \]
      5. *-commutative41.8%

        \[\leadsto \sqrt{{\color{blue}{\left(\sin t \cdot ew\right)}}^{2}} \]
    9. Applied egg-rr41.8%

      \[\leadsto \color{blue}{\sqrt{{\left(\sin t \cdot ew\right)}^{2}}} \]
    10. Step-by-step derivation
      1. *-commutative41.8%

        \[\leadsto \sqrt{{\color{blue}{\left(ew \cdot \sin t\right)}}^{2}} \]
      2. unpow241.8%

        \[\leadsto \sqrt{\color{blue}{\left(ew \cdot \sin t\right) \cdot \left(ew \cdot \sin t\right)}} \]
      3. rem-sqrt-square75.0%

        \[\leadsto \color{blue}{\left|ew \cdot \sin t\right|} \]
    11. Simplified75.0%

      \[\leadsto \color{blue}{\left|ew \cdot \sin t\right|} \]

    if -4.40000000000000034e50 < ew < 3.9000000000000002e90

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Step-by-step derivation
      1. associate-*l*99.8%

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. fma-define99.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      3. associate-/r*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
      4. associate-*l*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
      5. associate-/r*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in t around 0 52.8%

      \[\leadsto \left|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
    6. Step-by-step derivation
      1. associate-/r*52.8%

        \[\leadsto \left|eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{\frac{eh}{ew}}{\tan t}\right)}\right| \]
      2. sin-atan13.5%

        \[\leadsto \left|eh \cdot \color{blue}{\frac{\frac{\frac{eh}{ew}}{\tan t}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}}\right| \]
      3. associate-/r*12.3%

        \[\leadsto \left|eh \cdot \frac{\color{blue}{\frac{eh}{ew \cdot \tan t}}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right| \]
      4. div-inv12.0%

        \[\leadsto \left|eh \cdot \frac{\color{blue}{eh \cdot \frac{1}{ew \cdot \tan t}}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right| \]
      5. hypot-1-def23.8%

        \[\leadsto \left|eh \cdot \frac{eh \cdot \frac{1}{ew \cdot \tan t}}{\color{blue}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}}\right| \]
      6. *-un-lft-identity23.8%

        \[\leadsto \left|eh \cdot \frac{eh \cdot \frac{1}{ew \cdot \tan t}}{\color{blue}{1 \cdot \mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}}\right| \]
      7. times-frac24.1%

        \[\leadsto \left|eh \cdot \color{blue}{\left(\frac{eh}{1} \cdot \frac{\frac{1}{ew \cdot \tan t}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)}\right| \]
    7. Applied egg-rr24.1%

      \[\leadsto \left|eh \cdot \color{blue}{\left(\frac{eh}{1} \cdot \frac{\frac{1}{ew \cdot \tan t}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)}\right| \]
    8. Taylor expanded in eh around inf 53.0%

      \[\leadsto \left|\color{blue}{eh}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -4.4 \cdot 10^{+50} \lor \neg \left(ew \leq 3.9 \cdot 10^{+90}\right):\\ \;\;\;\;\left|\sin t \cdot ew\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 48.9% accurate, 8.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{-10} \lor \neg \left(t \leq 5.6 \cdot 10^{-8}\right):\\ \;\;\;\;\sin t \cdot ew\\ \mathbf{else}:\\ \;\;\;\;\left|eh\right|\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (if (or (<= t -5e-10) (not (<= t 5.6e-8))) (* (sin t) ew) (fabs eh)))
double code(double eh, double ew, double t) {
	double tmp;
	if ((t <= -5e-10) || !(t <= 5.6e-8)) {
		tmp = sin(t) * ew;
	} else {
		tmp = fabs(eh);
	}
	return tmp;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((t <= (-5d-10)) .or. (.not. (t <= 5.6d-8))) then
        tmp = sin(t) * ew
    else
        tmp = abs(eh)
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double tmp;
	if ((t <= -5e-10) || !(t <= 5.6e-8)) {
		tmp = Math.sin(t) * ew;
	} else {
		tmp = Math.abs(eh);
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if (t <= -5e-10) or not (t <= 5.6e-8):
		tmp = math.sin(t) * ew
	else:
		tmp = math.fabs(eh)
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if ((t <= -5e-10) || !(t <= 5.6e-8))
		tmp = Float64(sin(t) * ew);
	else
		tmp = abs(eh);
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	tmp = 0.0;
	if ((t <= -5e-10) || ~((t <= 5.6e-8)))
		tmp = sin(t) * ew;
	else
		tmp = abs(eh);
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -5e-10], N[Not[LessEqual[t, 5.6e-8]], $MachinePrecision]], N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision], N[Abs[eh], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -5 \cdot 10^{-10} \lor \neg \left(t \leq 5.6 \cdot 10^{-8}\right):\\
\;\;\;\;\sin t \cdot ew\\

\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -5.00000000000000031e-10 or 5.5999999999999999e-8 < t

    1. Initial program 99.5%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Step-by-step derivation
      1. associate-*l*99.5%

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. fma-define99.5%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      3. associate-/r*99.5%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
      4. associate-*l*99.5%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
      5. associate-/r*99.5%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
    3. Simplified99.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt97.6%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right) \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}} \]
      2. pow397.7%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right)}^{3}} \]
    6. Applied egg-rr52.0%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}, \cos t \cdot \left(\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot eh\right)\right)}\right)}^{3}} \]
    7. Taylor expanded in ew around inf 27.8%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{ew \cdot \sin t}\right)}}^{3} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt28.4%

        \[\leadsto \color{blue}{ew \cdot \sin t} \]
      2. *-commutative28.4%

        \[\leadsto \color{blue}{\sin t \cdot ew} \]
    9. Applied egg-rr28.4%

      \[\leadsto \color{blue}{\sin t \cdot ew} \]

    if -5.00000000000000031e-10 < t < 5.5999999999999999e-8

    1. Initial program 100.0%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Step-by-step derivation
      1. associate-*l*100.0%

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. fma-define100.0%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      3. associate-/r*100.0%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
      4. associate-*l*100.0%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
      5. associate-/r*100.0%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in t around 0 70.4%

      \[\leadsto \left|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
    6. Step-by-step derivation
      1. associate-/r*70.4%

        \[\leadsto \left|eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{\frac{eh}{ew}}{\tan t}\right)}\right| \]
      2. sin-atan19.9%

        \[\leadsto \left|eh \cdot \color{blue}{\frac{\frac{\frac{eh}{ew}}{\tan t}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}}\right| \]
      3. associate-/r*18.3%

        \[\leadsto \left|eh \cdot \frac{\color{blue}{\frac{eh}{ew \cdot \tan t}}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right| \]
      4. div-inv17.9%

        \[\leadsto \left|eh \cdot \frac{\color{blue}{eh \cdot \frac{1}{ew \cdot \tan t}}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right| \]
      5. hypot-1-def34.8%

        \[\leadsto \left|eh \cdot \frac{eh \cdot \frac{1}{ew \cdot \tan t}}{\color{blue}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}}\right| \]
      6. *-un-lft-identity34.8%

        \[\leadsto \left|eh \cdot \frac{eh \cdot \frac{1}{ew \cdot \tan t}}{\color{blue}{1 \cdot \mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}}\right| \]
      7. times-frac34.9%

        \[\leadsto \left|eh \cdot \color{blue}{\left(\frac{eh}{1} \cdot \frac{\frac{1}{ew \cdot \tan t}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)}\right| \]
    7. Applied egg-rr34.9%

      \[\leadsto \left|eh \cdot \color{blue}{\left(\frac{eh}{1} \cdot \frac{\frac{1}{ew \cdot \tan t}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)}\right| \]
    8. Taylor expanded in eh around inf 70.8%

      \[\leadsto \left|\color{blue}{eh}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{-10} \lor \neg \left(t \leq 5.6 \cdot 10^{-8}\right):\\ \;\;\;\;\sin t \cdot ew\\ \mathbf{else}:\\ \;\;\;\;\left|eh\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 45.0% accurate, 8.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;ew \leq -5.4 \cdot 10^{+216} \lor \neg \left(ew \leq 8.5 \cdot 10^{+186}\right):\\ \;\;\;\;\left|t \cdot ew\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh\right|\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (if (or (<= ew -5.4e+216) (not (<= ew 8.5e+186))) (fabs (* t ew)) (fabs eh)))
double code(double eh, double ew, double t) {
	double tmp;
	if ((ew <= -5.4e+216) || !(ew <= 8.5e+186)) {
		tmp = fabs((t * ew));
	} else {
		tmp = fabs(eh);
	}
	return tmp;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((ew <= (-5.4d+216)) .or. (.not. (ew <= 8.5d+186))) then
        tmp = abs((t * ew))
    else
        tmp = abs(eh)
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double tmp;
	if ((ew <= -5.4e+216) || !(ew <= 8.5e+186)) {
		tmp = Math.abs((t * ew));
	} else {
		tmp = Math.abs(eh);
	}
	return tmp;
}
def code(eh, ew, t):
	tmp = 0
	if (ew <= -5.4e+216) or not (ew <= 8.5e+186):
		tmp = math.fabs((t * ew))
	else:
		tmp = math.fabs(eh)
	return tmp
function code(eh, ew, t)
	tmp = 0.0
	if ((ew <= -5.4e+216) || !(ew <= 8.5e+186))
		tmp = abs(Float64(t * ew));
	else
		tmp = abs(eh);
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	tmp = 0.0;
	if ((ew <= -5.4e+216) || ~((ew <= 8.5e+186)))
		tmp = abs((t * ew));
	else
		tmp = abs(eh);
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := If[Or[LessEqual[ew, -5.4e+216], N[Not[LessEqual[ew, 8.5e+186]], $MachinePrecision]], N[Abs[N[(t * ew), $MachinePrecision]], $MachinePrecision], N[Abs[eh], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;ew \leq -5.4 \cdot 10^{+216} \lor \neg \left(ew \leq 8.5 \cdot 10^{+186}\right):\\
\;\;\;\;\left|t \cdot ew\right|\\

\mathbf{else}:\\
\;\;\;\;\left|eh\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -5.4000000000000003e216 or 8.4999999999999999e186 < ew

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Step-by-step derivation
      1. associate-*l*99.8%

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. fma-define99.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      3. associate-/r*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
      4. associate-*l*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
      5. associate-/r*99.8%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt97.7%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right) \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}} \]
      2. pow397.7%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right)}^{3}} \]
    6. Applied egg-rr47.0%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}, \cos t \cdot \left(\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot eh\right)\right)}\right)}^{3}} \]
    7. Taylor expanded in ew around inf 43.0%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{ew \cdot \sin t}\right)}}^{3} \]
    8. Taylor expanded in t around 0 19.2%

      \[\leadsto \color{blue}{ew \cdot t} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt18.7%

        \[\leadsto \color{blue}{\sqrt{ew \cdot t} \cdot \sqrt{ew \cdot t}} \]
      2. sqrt-unprod37.6%

        \[\leadsto \color{blue}{\sqrt{\left(ew \cdot t\right) \cdot \left(ew \cdot t\right)}} \]
      3. pow237.6%

        \[\leadsto \sqrt{\color{blue}{{\left(ew \cdot t\right)}^{2}}} \]
      4. *-commutative37.6%

        \[\leadsto \sqrt{{\color{blue}{\left(t \cdot ew\right)}}^{2}} \]
    10. Applied egg-rr37.6%

      \[\leadsto \color{blue}{\sqrt{{\left(t \cdot ew\right)}^{2}}} \]
    11. Step-by-step derivation
      1. unpow237.6%

        \[\leadsto \sqrt{\color{blue}{\left(t \cdot ew\right) \cdot \left(t \cdot ew\right)}} \]
      2. rem-sqrt-square48.0%

        \[\leadsto \color{blue}{\left|t \cdot ew\right|} \]
    12. Simplified48.0%

      \[\leadsto \color{blue}{\left|t \cdot ew\right|} \]

    if -5.4000000000000003e216 < ew < 8.4999999999999999e186

    1. Initial program 99.7%

      \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. Step-by-step derivation
      1. associate-*l*99.7%

        \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
      2. fma-define99.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
      3. associate-/r*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
      4. associate-*l*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
      5. associate-/r*99.7%

        \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in t around 0 47.1%

      \[\leadsto \left|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
    6. Step-by-step derivation
      1. associate-/r*47.1%

        \[\leadsto \left|eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{\frac{eh}{ew}}{\tan t}\right)}\right| \]
      2. sin-atan14.7%

        \[\leadsto \left|eh \cdot \color{blue}{\frac{\frac{\frac{eh}{ew}}{\tan t}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}}\right| \]
      3. associate-/r*13.8%

        \[\leadsto \left|eh \cdot \frac{\color{blue}{\frac{eh}{ew \cdot \tan t}}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right| \]
      4. div-inv13.5%

        \[\leadsto \left|eh \cdot \frac{\color{blue}{eh \cdot \frac{1}{ew \cdot \tan t}}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right| \]
      5. hypot-1-def25.3%

        \[\leadsto \left|eh \cdot \frac{eh \cdot \frac{1}{ew \cdot \tan t}}{\color{blue}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}}\right| \]
      6. *-un-lft-identity25.3%

        \[\leadsto \left|eh \cdot \frac{eh \cdot \frac{1}{ew \cdot \tan t}}{\color{blue}{1 \cdot \mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}}\right| \]
      7. times-frac25.5%

        \[\leadsto \left|eh \cdot \color{blue}{\left(\frac{eh}{1} \cdot \frac{\frac{1}{ew \cdot \tan t}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)}\right| \]
    7. Applied egg-rr25.5%

      \[\leadsto \left|eh \cdot \color{blue}{\left(\frac{eh}{1} \cdot \frac{\frac{1}{ew \cdot \tan t}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)}\right| \]
    8. Taylor expanded in eh around inf 47.4%

      \[\leadsto \left|\color{blue}{eh}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification47.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;ew \leq -5.4 \cdot 10^{+216} \lor \neg \left(ew \leq 8.5 \cdot 10^{+186}\right):\\ \;\;\;\;\left|t \cdot ew\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 42.3% accurate, 9.1× speedup?

\[\begin{array}{l} \\ \left|eh\right| \end{array} \]
(FPCore (eh ew t) :precision binary64 (fabs eh))
double code(double eh, double ew, double t) {
	return fabs(eh);
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    code = abs(eh)
end function
public static double code(double eh, double ew, double t) {
	return Math.abs(eh);
}
def code(eh, ew, t):
	return math.fabs(eh)
function code(eh, ew, t)
	return abs(eh)
end
function tmp = code(eh, ew, t)
	tmp = abs(eh);
end
code[eh_, ew_, t_] := N[Abs[eh], $MachinePrecision]
\begin{array}{l}

\\
\left|eh\right|
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Step-by-step derivation
    1. associate-*l*99.7%

      \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. fma-define99.8%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    3. associate-/r*99.8%

      \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
    4. associate-*l*99.7%

      \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
    5. associate-/r*99.7%

      \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
  3. Simplified99.7%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
  4. Add Preprocessing
  5. Taylor expanded in t around 0 40.1%

    \[\leadsto \left|\color{blue}{eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)}\right| \]
  6. Step-by-step derivation
    1. associate-/r*40.1%

      \[\leadsto \left|eh \cdot \sin \tan^{-1} \color{blue}{\left(\frac{\frac{eh}{ew}}{\tan t}\right)}\right| \]
    2. sin-atan13.2%

      \[\leadsto \left|eh \cdot \color{blue}{\frac{\frac{\frac{eh}{ew}}{\tan t}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}}\right| \]
    3. associate-/r*12.5%

      \[\leadsto \left|eh \cdot \frac{\color{blue}{\frac{eh}{ew \cdot \tan t}}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right| \]
    4. div-inv12.3%

      \[\leadsto \left|eh \cdot \frac{\color{blue}{eh \cdot \frac{1}{ew \cdot \tan t}}}{\sqrt{1 + \frac{\frac{eh}{ew}}{\tan t} \cdot \frac{\frac{eh}{ew}}{\tan t}}}\right| \]
    5. hypot-1-def22.3%

      \[\leadsto \left|eh \cdot \frac{eh \cdot \frac{1}{ew \cdot \tan t}}{\color{blue}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}}\right| \]
    6. *-un-lft-identity22.3%

      \[\leadsto \left|eh \cdot \frac{eh \cdot \frac{1}{ew \cdot \tan t}}{\color{blue}{1 \cdot \mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}}\right| \]
    7. times-frac22.5%

      \[\leadsto \left|eh \cdot \color{blue}{\left(\frac{eh}{1} \cdot \frac{\frac{1}{ew \cdot \tan t}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)}\right| \]
  7. Applied egg-rr22.5%

    \[\leadsto \left|eh \cdot \color{blue}{\left(\frac{eh}{1} \cdot \frac{\frac{1}{ew \cdot \tan t}}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}\right)}\right| \]
  8. Taylor expanded in eh around inf 40.7%

    \[\leadsto \left|\color{blue}{eh}\right| \]
  9. Add Preprocessing

Alternative 8: 10.4% accurate, 306.3× speedup?

\[\begin{array}{l} \\ t \cdot ew \end{array} \]
(FPCore (eh ew t) :precision binary64 (* t ew))
double code(double eh, double ew, double t) {
	return t * ew;
}
real(8) function code(eh, ew, t)
    real(8), intent (in) :: eh
    real(8), intent (in) :: ew
    real(8), intent (in) :: t
    code = t * ew
end function
public static double code(double eh, double ew, double t) {
	return t * ew;
}
def code(eh, ew, t):
	return t * ew
function code(eh, ew, t)
	return Float64(t * ew)
end
function tmp = code(eh, ew, t)
	tmp = t * ew;
end
code[eh_, ew_, t_] := N[(t * ew), $MachinePrecision]
\begin{array}{l}

\\
t \cdot ew
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left|\left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
  2. Step-by-step derivation
    1. associate-*l*99.7%

      \[\leadsto \left|\color{blue}{ew \cdot \left(\sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
    2. fma-define99.8%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right| \]
    3. associate-/r*99.8%

      \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}, \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right| \]
    4. associate-*l*99.7%

      \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), \color{blue}{eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)}\right)\right| \]
    5. associate-/r*99.7%

      \[\leadsto \left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \color{blue}{\left(\frac{eh}{ew \cdot \tan t}\right)}\right)\right)\right| \]
  3. Simplified99.7%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-cube-cbrt97.8%

      \[\leadsto \color{blue}{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|} \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right) \cdot \sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}} \]
    2. pow397.8%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\left|\mathsf{fma}\left(ew, \sin t \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right)\right|}\right)}^{3}} \]
  6. Applied egg-rr52.9%

    \[\leadsto \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{\tan t}\right)}, \cos t \cdot \left(\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot eh\right)\right)}\right)}^{3}} \]
  7. Taylor expanded in ew around inf 21.9%

    \[\leadsto {\color{blue}{\left(\sqrt[3]{ew \cdot \sin t}\right)}}^{3} \]
  8. Taylor expanded in t around 0 10.1%

    \[\leadsto \color{blue}{ew \cdot t} \]
  9. Final simplification10.1%

    \[\leadsto t \cdot ew \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024157 
(FPCore (eh ew t)
  :name "Example from Robby"
  :precision binary64
  (fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))