?

Average Error: 0.1 → 0.1
Time: 20.1s
Precision: binary64
Cost: 58880

?

\[\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| \]
\[\left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\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)\right| \]
(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
 (fabs
  (fma
   (* ew (sin t))
   (/ 1.0 (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((((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) {
	return fabs(fma((ew * sin(t)), (1.0 / hypot(1.0, ((eh / ew) / tan(t)))), (eh * (cos(t) * sin(atan((eh / (ew * tan(t)))))))));
}
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)
	return abs(fma(Float64(ew * sin(t)), Float64(1.0 / hypot(1.0, Float64(Float64(eh / ew) / tan(t)))), Float64(eh * Float64(cos(t) * sin(atan(Float64(eh / Float64(ew * tan(t)))))))))
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_] := N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision] ^ 2], $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]
\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|
\left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\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)\right|

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. Applied egg-rr0.1

    \[\leadsto \left|\mathsf{fma}\left(ew \cdot \sin t, \color{blue}{\frac{1}{\mathsf{hypot}\left(1, \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| \]
  4. Simplified0.1

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

    *-commutative [=>]0.1

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

    associate-/r* [=>]0.1

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

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

Alternatives

Alternative 1
Error0.2
Cost52480
\[\begin{array}{l} t_1 := \frac{\frac{eh}{ew}}{\tan t}\\ \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t_1 + \frac{ew}{\frac{\mathsf{hypot}\left(1, t_1\right)}{\sin t}}\right| \end{array} \]
Alternative 2
Error0.2
Cost52480
\[\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \frac{\sin t}{\frac{\mathsf{hypot}\left(1, \frac{\frac{eh}{\tan t}}{ew}\right)}{ew}}\right| \]
Alternative 3
Error0.1
Cost52480
\[\left|\frac{ew \cdot \sin t}{\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| \]
Alternative 4
Error0.6
Cost52416
\[\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right| \]
Alternative 5
Error1.0
Cost39232
\[\left|ew \cdot \sin t + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
Alternative 6
Error23.3
Cost33481
\[\begin{array}{l} t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-6} \lor \neg \left(t \leq 6.5 \cdot 10^{-5}\right):\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(t \cdot \frac{ew}{eh}\right) \cdot \left(ew \cdot t\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \left(t \cdot \cos t_1\right) + eh \cdot \sin t_1\right|\\ \end{array} \]
Alternative 7
Error21.4
Cost33481
\[\begin{array}{l} t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-6} \lor \neg \left(t \leq 6.5 \cdot 10^{-5}\right):\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + t \cdot \frac{t}{\frac{eh}{ew \cdot ew}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|ew \cdot \left(t \cdot \cos t_1\right) + eh \cdot \sin t_1\right|\\ \end{array} \]
Alternative 8
Error23.3
Cost33480
\[\begin{array}{l} t_1 := \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\ t_2 := \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;\left|t_1 + \left(t \cdot \frac{ew}{eh}\right) \cdot \left(ew \cdot t\right)\right|\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{-5}:\\ \;\;\;\;\left|ew \cdot \left(t \cdot \cos t_2\right) + eh \cdot \sin t_2\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_1 + t \cdot \left(\frac{ew}{eh} \cdot \left(ew \cdot t\right)\right)\right|\\ \end{array} \]
Alternative 9
Error23.3
Cost33480
\[\begin{array}{l} t_1 := \frac{eh}{ew \cdot t}\\ t_2 := \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\ t_3 := \tan^{-1} t_1\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;\left|t_2 + \left(t \cdot \frac{ew}{eh}\right) \cdot \left(ew \cdot t\right)\right|\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-5}:\\ \;\;\;\;\left|ew \cdot \left(t \cdot \cos t_3\right) + eh \cdot \sin t_3\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_2 + t \cdot \frac{ew}{t_1}\right|\\ \end{array} \]
Alternative 10
Error23.3
Cost33352
\[\begin{array}{l} t_1 := \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\\ t_2 := \sin t_1\\ t_3 := \left(eh \cdot \cos t\right) \cdot t_2\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;\left|\left(t \cdot \frac{ew}{eh}\right) \cdot \left(ew \cdot t\right) + t_3\right|\\ \mathbf{elif}\;t \leq 0.00011:\\ \;\;\;\;\left|ew \cdot \left(t \cdot \cos t_1\right) + eh \cdot t_2\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t \cdot \left(\frac{ew}{eh} \cdot \left(ew \cdot t\right)\right) + t_3\right|\\ \end{array} \]
Alternative 11
Error32.2
Cost26816
\[\left|\left(t \cdot \frac{ew}{eh}\right) \cdot \left(ew \cdot t\right) + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right| \]
Alternative 12
Error32.2
Cost26816
\[\begin{array}{l} t_1 := \frac{eh}{ew \cdot t}\\ \left|t \cdot \frac{ew}{t_1} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} t_1\right| \end{array} \]
Alternative 13
Error35.1
Cost21129
\[\begin{array}{l} t_1 := \frac{eh}{ew \cdot t}\\ t_2 := \frac{ew}{\frac{eh}{t \cdot \left(ew \cdot t\right)}}\\ \mathbf{if}\;t \leq -0.0095 \lor \neg \left(t \leq 2.1 \cdot 10^{-18}\right):\\ \;\;\;\;\left|t_2 + \left(\cos t \cdot t_1\right) \cdot \frac{eh}{\mathsf{hypot}\left(1, t_1\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_2 + \left(eh \cdot \sin \tan^{-1} t_1\right) \cdot \left(1 + t \cdot \left(t \cdot -0.5\right)\right)\right|\\ \end{array} \]
Alternative 14
Error38.8
Cost20996
\[\begin{array}{l} t_1 := \frac{\frac{eh}{t}}{ew}\\ t_2 := \frac{ew}{\frac{eh}{t \cdot \left(ew \cdot t\right)}}\\ \mathbf{if}\;t \leq -16:\\ \;\;\;\;\left|t_2 + \left(eh \cdot t_1\right) \cdot \frac{\cos t}{\mathsf{hypot}\left(1, t_1\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + t_2\right|\\ \end{array} \]
Alternative 15
Error39.8
Cost20288
\[\left|eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) + \frac{ew}{\frac{eh}{t \cdot \left(ew \cdot t\right)}}\right| \]

Error

Reproduce?

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