Average Error: 0.1 → 0.1
Time: 19.3s
Precision: binary64
Cost: 65088
\[\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| \]
\[\begin{array}{l} t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\ \left|\mathsf{fma}\left(ew \cdot \sin t, \cos t_1, eh \cdot \left(\cos t \cdot \sin t_1\right)\right)\right| \end{array} \]
(FPCore (eh ew t)
 :precision binary64
 (fabs
  (+
   (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t)))))
   (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))
(FPCore (eh ew t)
 :precision binary64
 (let* ((t_1 (atan (/ eh (* ew (tan t))))))
   (fabs (fma (* ew (sin t)) (cos t_1) (* eh (* (cos t) (sin t_1)))))))
double code(double eh, double ew, double t) {
	return fabs((((ew * sin(t)) * cos(atan(((eh / ew) / tan(t))))) + ((eh * cos(t)) * sin(atan(((eh / ew) / tan(t)))))));
}
double code(double eh, double ew, double t) {
	double t_1 = atan((eh / (ew * tan(t))));
	return fabs(fma((ew * sin(t)), cos(t_1), (eh * (cos(t) * sin(t_1)))));
}
function code(eh, ew, t)
	return abs(Float64(Float64(Float64(ew * sin(t)) * cos(atan(Float64(Float64(eh / ew) / tan(t))))) + Float64(Float64(eh * cos(t)) * sin(atan(Float64(Float64(eh / ew) / tan(t)))))))
end
function code(eh, ew, t)
	t_1 = atan(Float64(eh / Float64(ew * tan(t))))
	return abs(fma(Float64(ew * sin(t)), cos(t_1), Float64(eh * Float64(cos(t) * sin(t_1)))))
end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $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]
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\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|
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\
\left|\mathsf{fma}\left(ew \cdot \sin t, \cos t_1, eh \cdot \left(\cos t \cdot \sin t_1\right)\right)\right|
\end{array}

Error

Derivation

  1. Initial program 0.1

    \[\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. Simplified0.1

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

    [Start]0.1

    \[ \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| \]

    fma-def [=>]0.1

    \[ \left|\color{blue}{\mathsf{fma}\left(ew \cdot \sin t, \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| \]

    associate-/l/ [=>]0.1

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

    associate-*l* [=>]0.1

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

    associate-/l/ [=>]0.1

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

    \[\leadsto \left|\mathsf{fma}\left(ew \cdot \sin t, \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| \]

Alternatives

Alternative 1
Error0.1
Cost58816
\[\left|\sin t \cdot \left(ew \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
Alternative 2
Error0.2
Cost52608
\[\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \frac{1}{\frac{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}{ew \cdot \sin t}}\right| \]
Alternative 3
Error0.2
Cost52480
\[\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \frac{ew}{\frac{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}{\sin t}}\right| \]
Alternative 4
Error0.7
Cost52416
\[\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot \left(ew \cdot \sin t\right)\right| \]
Alternative 5
Error1.1
Cost39232
\[\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + ew \cdot \sin t\right| \]
Alternative 6
Error8.3
Cost32969
\[\begin{array}{l} t_1 := \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\\ \mathbf{if}\;eh \leq -7.6 \cdot 10^{+124} \lor \neg \left(eh \leq 10^{+81}\right):\\ \;\;\;\;\left|t_1 \cdot \left(eh \cdot \cos t\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \sin t + eh \cdot t_1\right|\\ \end{array} \]
Alternative 7
Error6.9
Cost32832
\[\left|ew \cdot \sin t + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right| \]
Alternative 8
Error24.5
Cost32576
\[\left|\sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right) \cdot \left(eh \cdot \cos t\right)\right| \]
Alternative 9
Error35.4
Cost27081
\[\begin{array}{l} \mathbf{if}\;t \leq 1.7 \cdot 10^{-8} \lor \neg \left(t \leq 7.5 \cdot 10^{+101}\right):\\ \;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + \left(ew \cdot ew\right) \cdot \frac{t \cdot t}{eh}\right|\\ \end{array} \]
Alternative 10
Error31.1
Cost27081
\[\begin{array}{l} \mathbf{if}\;ew \leq -1.05 \cdot 10^{+59} \lor \neg \left(ew \leq 1.2 \cdot 10^{+47}\right):\\ \;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + \frac{t}{\frac{\frac{eh}{ew \cdot ew}}{t}}\right|\\ \end{array} \]
Alternative 11
Error34.8
Cost26816
\[\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + \frac{ew}{\frac{\frac{eh}{t \cdot t}}{ew}}\right| \]
Alternative 12
Error31.4
Cost26816
\[\begin{array}{l} t_1 := \frac{eh}{ew \cdot t}\\ \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t_1 + \frac{ew \cdot t}{t_1}\right| \end{array} \]
Alternative 13
Error36.3
Cost26313
\[\begin{array}{l} t_1 := \frac{\frac{eh}{ew}}{t}\\ \mathbf{if}\;t \leq 21000 \lor \neg \left(t \leq 9.6 \cdot 10^{+98}\right):\\ \;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(ew \cdot ew\right) \cdot \frac{t \cdot t}{eh} + \frac{t_1}{\frac{\mathsf{hypot}\left(1, t_1\right)}{eh \cdot \cos t}}\right|\\ \end{array} \]
Alternative 14
Error41.2
Cost20996
\[\begin{array}{l} t_1 := \frac{eh}{ew \cdot t}\\ t_2 := \left(ew \cdot ew\right) \cdot \frac{t \cdot t}{eh}\\ \mathbf{if}\;t \leq 3.8 \cdot 10^{-6}:\\ \;\;\;\;\left|t_2 + eh \cdot \sin \tan^{-1} t_1\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_2 + \frac{eh \cdot \cos t}{\mathsf{hypot}\left(1, t_1\right) \cdot \left(ew \cdot \frac{t}{eh}\right)}\right|\\ \end{array} \]
Alternative 15
Error41.6
Cost20996
\[\begin{array}{l} t_1 := \frac{\frac{eh}{ew}}{t}\\ t_2 := \left(ew \cdot ew\right) \cdot \frac{t \cdot t}{eh}\\ \mathbf{if}\;t \leq 1.25 \cdot 10^{-5}:\\ \;\;\;\;\left|t_2 + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_2 + \frac{t_1}{\frac{\mathsf{hypot}\left(1, t_1\right)}{eh \cdot \cos t}}\right|\\ \end{array} \]
Alternative 16
Error43.0
Cost20288
\[\left|\left(ew \cdot ew\right) \cdot \frac{t \cdot t}{eh} + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right| \]
Alternative 17
Error62.0
Cost13376
\[\left|ew \cdot \left(\sin t \cdot \left(ew \cdot \frac{t}{eh}\right)\right)\right| \]
Alternative 18
Error61.9
Cost13376
\[\left|ew \cdot \left(\sin t \cdot \frac{ew \cdot t}{eh}\right)\right| \]
Alternative 19
Error62.7
Cost6976
\[\left(ew \cdot ew\right) \cdot \frac{t \cdot t}{\left|eh\right|} \]
Alternative 20
Error62.7
Cost6976
\[\frac{t \cdot t}{\frac{\left|eh\right|}{ew \cdot ew}} \]

Error

Reproduce

herbie shell --seed 2023012 
(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))))))))