Example 2 from Robby

Percentage Accurate: 99.8% → 99.8%
Time: 14.4s
Alternatives: 7
Speedup: 1.0×

Specification

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

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\tan t \cdot eh}{-ew}\right)\\
\left|\sin t\_1 \cdot \left(\sin t \cdot eh\right) - \left(\cos t \cdot ew\right) \cdot \cos t\_1\right|
\end{array}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Final simplification99.8%

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

Alternative 2: 99.0% accurate, 1.1× speedup?

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

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

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Taylor expanded in t around 0

    \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{-1 \cdot \left(eh \cdot t\right)}}{ew}\right)\right| \]
  4. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right| \]
    2. lower-*.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right| \]
    3. mul-1-negN/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot t}{ew}\right)\right| \]
    4. lower-neg.f6499.1

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

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

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

Alternative 3: 98.0% accurate, 1.9× speedup?

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

\\
\left|\sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right) \cdot \left(\sin t \cdot eh\right) - \sqrt{\mathsf{fma}\left(\cos \left(2 \cdot t\right), 0.5, 0.5\right)} \cdot ew\right|
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Taylor expanded in t around 0

    \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{-1 \cdot \left(eh \cdot t\right)}}{ew}\right)\right| \]
  4. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right| \]
    2. lower-*.f64N/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right| \]
    3. mul-1-negN/A

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot t}{ew}\right)\right| \]
    4. lower-neg.f6499.1

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

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

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

    \[\leadsto \left|\color{blue}{ew \cdot \sqrt{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot t\right)}} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
  8. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot t\right)} \cdot ew} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    2. lower-*.f64N/A

      \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot t\right)} \cdot ew} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    3. lower-sqrt.f64N/A

      \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot t\right)}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    4. +-commutativeN/A

      \[\leadsto \left|\sqrt{\color{blue}{\frac{1}{2} \cdot \cos \left(2 \cdot t\right) + \frac{1}{2}}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    5. *-commutativeN/A

      \[\leadsto \left|\sqrt{\color{blue}{\cos \left(2 \cdot t\right) \cdot \frac{1}{2}} + \frac{1}{2}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    6. metadata-evalN/A

      \[\leadsto \left|\sqrt{\cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot t\right) \cdot \frac{1}{2} + \frac{1}{2}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    7. distribute-lft-neg-inN/A

      \[\leadsto \left|\sqrt{\cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot t\right)\right)} \cdot \frac{1}{2} + \frac{1}{2}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    8. lower-fma.f64N/A

      \[\leadsto \left|\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(\mathsf{neg}\left(-2 \cdot t\right)\right), \frac{1}{2}, \frac{1}{2}\right)}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    9. lower-cos.f64N/A

      \[\leadsto \left|\sqrt{\mathsf{fma}\left(\color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot t\right)\right)}, \frac{1}{2}, \frac{1}{2}\right)} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    10. distribute-lft-neg-inN/A

      \[\leadsto \left|\sqrt{\mathsf{fma}\left(\cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot t\right)}, \frac{1}{2}, \frac{1}{2}\right)} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    11. metadata-evalN/A

      \[\leadsto \left|\sqrt{\mathsf{fma}\left(\cos \left(\color{blue}{2} \cdot t\right), \frac{1}{2}, \frac{1}{2}\right)} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    12. *-commutativeN/A

      \[\leadsto \left|\sqrt{\mathsf{fma}\left(\cos \color{blue}{\left(t \cdot 2\right)}, \frac{1}{2}, \frac{1}{2}\right)} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    13. lower-*.f6498.6

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

    \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(\cos \left(t \cdot 2\right), 0.5, 0.5\right)} \cdot ew} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right)\right| \]
  10. Final simplification98.6%

    \[\leadsto \left|\sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot t}{ew}\right) \cdot \left(\sin t \cdot eh\right) - \sqrt{\mathsf{fma}\left(\cos \left(2 \cdot t\right), 0.5, 0.5\right)} \cdot ew\right| \]
  11. Add Preprocessing

Alternative 4: 76.8% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin t \cdot eh\\ t_2 := \cos t \cdot ew\\ t_3 := \left|t\_2\right|\\ t_4 := \left(-eh\right) \cdot t\\ \mathbf{if}\;ew \leq -5.5 \cdot 10^{-76}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;ew \leq 6.8 \cdot 10^{-101}:\\ \;\;\;\;\left|t\_1\right|\\ \mathbf{elif}\;ew \leq 9.6 \cdot 10^{+92}:\\ \;\;\;\;\left|\mathsf{fma}\left(\frac{t\_4}{\sqrt{\frac{t\_4 \cdot t\_4}{ew \cdot ew} + 1} \cdot ew}, t\_1, -t\_2\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (* (sin t) eh))
        (t_2 (* (cos t) ew))
        (t_3 (fabs t_2))
        (t_4 (* (- eh) t)))
   (if (<= ew -5.5e-76)
     t_3
     (if (<= ew 6.8e-101)
       (fabs t_1)
       (if (<= ew 9.6e+92)
         (fabs
          (fma
           (/ t_4 (* (sqrt (+ (/ (* t_4 t_4) (* ew ew)) 1.0)) ew))
           t_1
           (- t_2)))
         t_3)))))
double code(double eh, double ew, double t) {
	double t_1 = sin(t) * eh;
	double t_2 = cos(t) * ew;
	double t_3 = fabs(t_2);
	double t_4 = -eh * t;
	double tmp;
	if (ew <= -5.5e-76) {
		tmp = t_3;
	} else if (ew <= 6.8e-101) {
		tmp = fabs(t_1);
	} else if (ew <= 9.6e+92) {
		tmp = fabs(fma((t_4 / (sqrt((((t_4 * t_4) / (ew * ew)) + 1.0)) * ew)), t_1, -t_2));
	} else {
		tmp = t_3;
	}
	return tmp;
}
function code(eh, ew, t)
	t_1 = Float64(sin(t) * eh)
	t_2 = Float64(cos(t) * ew)
	t_3 = abs(t_2)
	t_4 = Float64(Float64(-eh) * t)
	tmp = 0.0
	if (ew <= -5.5e-76)
		tmp = t_3;
	elseif (ew <= 6.8e-101)
		tmp = abs(t_1);
	elseif (ew <= 9.6e+92)
		tmp = abs(fma(Float64(t_4 / Float64(sqrt(Float64(Float64(Float64(t_4 * t_4) / Float64(ew * ew)) + 1.0)) * ew)), t_1, Float64(-t_2)));
	else
		tmp = t_3;
	end
	return tmp
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]}, Block[{t$95$3 = N[Abs[t$95$2], $MachinePrecision]}, Block[{t$95$4 = N[((-eh) * t), $MachinePrecision]}, If[LessEqual[ew, -5.5e-76], t$95$3, If[LessEqual[ew, 6.8e-101], N[Abs[t$95$1], $MachinePrecision], If[LessEqual[ew, 9.6e+92], N[Abs[N[(N[(t$95$4 / N[(N[Sqrt[N[(N[(N[(t$95$4 * t$95$4), $MachinePrecision] / N[(ew * ew), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] * t$95$1 + (-t$95$2)), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \sin t \cdot eh\\
t_2 := \cos t \cdot ew\\
t_3 := \left|t\_2\right|\\
t_4 := \left(-eh\right) \cdot t\\
\mathbf{if}\;ew \leq -5.5 \cdot 10^{-76}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;ew \leq 6.8 \cdot 10^{-101}:\\
\;\;\;\;\left|t\_1\right|\\

\mathbf{elif}\;ew \leq 9.6 \cdot 10^{+92}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{t\_4}{\sqrt{\frac{t\_4 \cdot t\_4}{ew \cdot ew} + 1} \cdot ew}, t\_1, -t\_2\right)\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if ew < -5.50000000000000014e-76 or 9.60000000000000018e92 < ew

    1. Initial program 99.9%

      \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites36.5%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(-\left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\right)\right) \cdot \left(eh \cdot eh\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(-\tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)\right)\right), {\left(\frac{\cos t \cdot ew}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}\right)}^{2}\right)}{\frac{\cos t \cdot ew - \sin t \cdot \left(\frac{\tan t}{ew} \cdot \left(eh \cdot eh\right)\right)}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}}}\right| \]
    4. Taylor expanded in ew around inf

      \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\cos t \cdot ew}\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\cos t \cdot ew}\right| \]
      3. lower-cos.f6484.0

        \[\leadsto \left|\color{blue}{\cos t} \cdot ew\right| \]
    6. Applied rewrites84.0%

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

    if -5.50000000000000014e-76 < ew < 6.79999999999999978e-101

    1. Initial program 99.7%

      \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites37.0%

      \[\leadsto \color{blue}{\left|\frac{\left(\sin t \cdot \left(-eh\right)\right) \cdot \left(\frac{\tan t}{ew} \cdot eh\right) - \cos t \cdot ew}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}\right|} \]
    4. Taylor expanded in eh around -inf

      \[\leadsto \left|\color{blue}{eh \cdot \sin t}\right| \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      3. lower-sin.f6486.7

        \[\leadsto \left|\color{blue}{\sin t} \cdot eh\right| \]
    6. Applied rewrites86.7%

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

    if 6.79999999999999978e-101 < ew < 9.60000000000000018e92

    1. Initial program 99.8%

      \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

      \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{-1 \cdot \left(eh \cdot t\right)}}{ew}\right)\right| \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(-1 \cdot eh\right) \cdot t}}{ew}\right)\right| \]
      3. mul-1-negN/A

        \[\leadsto \left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\color{blue}{\left(\mathsf{neg}\left(eh\right)\right)} \cdot t}{ew}\right)\right| \]
      4. lower-neg.f6499.8

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

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

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

      \[\leadsto \left|\color{blue}{ew \cdot \sqrt{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot t\right)}} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
    8. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot t\right)} \cdot ew} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot t\right)} \cdot ew} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left|\color{blue}{\sqrt{\frac{1}{2} + \frac{1}{2} \cdot \cos \left(2 \cdot t\right)}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      4. +-commutativeN/A

        \[\leadsto \left|\sqrt{\color{blue}{\frac{1}{2} \cdot \cos \left(2 \cdot t\right) + \frac{1}{2}}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      5. *-commutativeN/A

        \[\leadsto \left|\sqrt{\color{blue}{\cos \left(2 \cdot t\right) \cdot \frac{1}{2}} + \frac{1}{2}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      6. metadata-evalN/A

        \[\leadsto \left|\sqrt{\cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot t\right) \cdot \frac{1}{2} + \frac{1}{2}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \left|\sqrt{\cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot t\right)\right)} \cdot \frac{1}{2} + \frac{1}{2}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      8. lower-fma.f64N/A

        \[\leadsto \left|\sqrt{\color{blue}{\mathsf{fma}\left(\cos \left(\mathsf{neg}\left(-2 \cdot t\right)\right), \frac{1}{2}, \frac{1}{2}\right)}} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      9. lower-cos.f64N/A

        \[\leadsto \left|\sqrt{\mathsf{fma}\left(\color{blue}{\cos \left(\mathsf{neg}\left(-2 \cdot t\right)\right)}, \frac{1}{2}, \frac{1}{2}\right)} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      10. distribute-lft-neg-inN/A

        \[\leadsto \left|\sqrt{\mathsf{fma}\left(\cos \color{blue}{\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot t\right)}, \frac{1}{2}, \frac{1}{2}\right)} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      11. metadata-evalN/A

        \[\leadsto \left|\sqrt{\mathsf{fma}\left(\cos \left(\color{blue}{2} \cdot t\right), \frac{1}{2}, \frac{1}{2}\right)} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      12. *-commutativeN/A

        \[\leadsto \left|\sqrt{\mathsf{fma}\left(\cos \color{blue}{\left(t \cdot 2\right)}, \frac{1}{2}, \frac{1}{2}\right)} \cdot ew - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(\mathsf{neg}\left(eh\right)\right) \cdot t}{ew}\right)\right| \]
      13. lower-*.f6498.3

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(\frac{\left(-eh\right) \cdot t}{\sqrt{\frac{\left(\left(-eh\right) \cdot t\right) \cdot \left(\left(-eh\right) \cdot t\right)}{ew \cdot ew} + 1} \cdot ew}, \sin t \cdot eh, -\cos t \cdot ew\right)\right|} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 75.6% accurate, 7.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left|\cos t \cdot ew\right|\\ \mathbf{if}\;ew \leq -5.5 \cdot 10^{-76}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;ew \leq 3.5 \cdot 10^{-84}:\\ \;\;\;\;\left|\sin t \cdot eh\right|\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (fabs (* (cos t) ew))))
   (if (<= ew -5.5e-76) t_1 (if (<= ew 3.5e-84) (fabs (* (sin t) eh)) t_1))))
double code(double eh, double ew, double t) {
	double t_1 = fabs((cos(t) * ew));
	double tmp;
	if (ew <= -5.5e-76) {
		tmp = t_1;
	} else if (ew <= 3.5e-84) {
		tmp = fabs((sin(t) * eh));
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_1 = abs((cos(t) * ew))
    if (ew <= (-5.5d-76)) then
        tmp = t_1
    else if (ew <= 3.5d-84) then
        tmp = abs((sin(t) * eh))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double eh, double ew, double t) {
	double t_1 = Math.abs((Math.cos(t) * ew));
	double tmp;
	if (ew <= -5.5e-76) {
		tmp = t_1;
	} else if (ew <= 3.5e-84) {
		tmp = Math.abs((Math.sin(t) * eh));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(eh, ew, t):
	t_1 = math.fabs((math.cos(t) * ew))
	tmp = 0
	if ew <= -5.5e-76:
		tmp = t_1
	elif ew <= 3.5e-84:
		tmp = math.fabs((math.sin(t) * eh))
	else:
		tmp = t_1
	return tmp
function code(eh, ew, t)
	t_1 = abs(Float64(cos(t) * ew))
	tmp = 0.0
	if (ew <= -5.5e-76)
		tmp = t_1;
	elseif (ew <= 3.5e-84)
		tmp = abs(Float64(sin(t) * eh));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(eh, ew, t)
	t_1 = abs((cos(t) * ew));
	tmp = 0.0;
	if (ew <= -5.5e-76)
		tmp = t_1;
	elseif (ew <= 3.5e-84)
		tmp = abs((sin(t) * eh));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, -5.5e-76], t$95$1, If[LessEqual[ew, 3.5e-84], N[Abs[N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left|\cos t \cdot ew\right|\\
\mathbf{if}\;ew \leq -5.5 \cdot 10^{-76}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;ew \leq 3.5 \cdot 10^{-84}:\\
\;\;\;\;\left|\sin t \cdot eh\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if ew < -5.50000000000000014e-76 or 3.5000000000000001e-84 < ew

    1. Initial program 99.9%

      \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites46.5%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(-\left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\right)\right) \cdot \left(eh \cdot eh\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(-\tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)\right)\right), {\left(\frac{\cos t \cdot ew}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}\right)}^{2}\right)}{\frac{\cos t \cdot ew - \sin t \cdot \left(\frac{\tan t}{ew} \cdot \left(eh \cdot eh\right)\right)}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}}}\right| \]
    4. Taylor expanded in ew around inf

      \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\cos t \cdot ew}\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\cos t \cdot ew}\right| \]
      3. lower-cos.f6479.1

        \[\leadsto \left|\color{blue}{\cos t} \cdot ew\right| \]
    6. Applied rewrites79.1%

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

    if -5.50000000000000014e-76 < ew < 3.5000000000000001e-84

    1. Initial program 99.7%

      \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
    2. Add Preprocessing
    3. Applied rewrites38.9%

      \[\leadsto \color{blue}{\left|\frac{\left(\sin t \cdot \left(-eh\right)\right) \cdot \left(\frac{\tan t}{ew} \cdot eh\right) - \cos t \cdot ew}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}\right|} \]
    4. Taylor expanded in eh around -inf

      \[\leadsto \left|\color{blue}{eh \cdot \sin t}\right| \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      2. lower-*.f64N/A

        \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
      3. lower-sin.f6486.1

        \[\leadsto \left|\color{blue}{\sin t} \cdot eh\right| \]
    6. Applied rewrites86.1%

      \[\leadsto \left|\color{blue}{\sin t \cdot eh}\right| \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 63.1% accurate, 8.0× speedup?

\[\begin{array}{l} \\ \left|\cos t \cdot ew\right| \end{array} \]
(FPCore (eh ew t) :precision binary64 (fabs (* (cos t) ew)))
double code(double eh, double ew, double t) {
	return fabs((cos(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 = abs((cos(t) * ew))
end function
public static double code(double eh, double ew, double t) {
	return Math.abs((Math.cos(t) * ew));
}
def code(eh, ew, t):
	return math.fabs((math.cos(t) * ew))
function code(eh, ew, t)
	return abs(Float64(cos(t) * ew))
end
function tmp = code(eh, ew, t)
	tmp = abs((cos(t) * ew));
end
code[eh_, ew_, t_] := N[Abs[N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|\cos t \cdot ew\right|
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Applied rewrites36.3%

    \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(-\left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\right)\right) \cdot \left(eh \cdot eh\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(-\tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right)\right)\right), {\left(\frac{\cos t \cdot ew}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}\right)}^{2}\right)}{\frac{\cos t \cdot ew - \sin t \cdot \left(\frac{\tan t}{ew} \cdot \left(eh \cdot eh\right)\right)}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}}}\right| \]
  4. Taylor expanded in ew around inf

    \[\leadsto \left|\color{blue}{ew \cdot \cos t}\right| \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left|\color{blue}{\cos t \cdot ew}\right| \]
    2. lower-*.f64N/A

      \[\leadsto \left|\color{blue}{\cos t \cdot ew}\right| \]
    3. lower-cos.f6456.3

      \[\leadsto \left|\color{blue}{\cos t} \cdot ew\right| \]
  6. Applied rewrites56.3%

    \[\leadsto \left|\color{blue}{\cos t \cdot ew}\right| \]
  7. Add Preprocessing

Alternative 7: 43.1% accurate, 287.3× speedup?

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

\\
\left|ew\right|
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Add Preprocessing
  3. Applied rewrites70.9%

    \[\leadsto \color{blue}{\left|\frac{\left(\sin t \cdot \left(-eh\right)\right) \cdot \left(\frac{\tan t}{ew} \cdot eh\right) - \cos t \cdot ew}{\sqrt{{\left(\frac{-ew}{\tan t \cdot eh}\right)}^{-2} + 1}}\right|} \]
  4. Taylor expanded in t around 0

    \[\leadsto \left|\color{blue}{-1 \cdot ew}\right| \]
  5. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \left|\color{blue}{\mathsf{neg}\left(ew\right)}\right| \]
    2. lower-neg.f6436.1

      \[\leadsto \left|\color{blue}{-ew}\right| \]
  6. Applied rewrites36.1%

    \[\leadsto \left|\color{blue}{-ew}\right| \]
  7. Step-by-step derivation
    1. Applied rewrites36.1%

      \[\leadsto \color{blue}{\left|ew\right|} \]
    2. Add Preprocessing

    Reproduce

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