Average Error: 0.1 → 0.1
Time: 19.0s
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{\frac{eh}{ew}}{\tan t}\right)\\ \left|\mathsf{fma}\left(ew, \sin t \cdot \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(Float64(eh / ew) / tan(t)))
	return abs(fma(ew, Float64(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[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(ew * N[(N[Sin[t], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $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{\frac{eh}{ew}}{\tan t}\right)\\
\left|\mathsf{fma}\left(ew, \sin t \cdot \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, \sin t \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right|} \]
    Proof
    (fabs.f64 (fma.f64 ew (*.f64 (sin.f64 t) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (*.f64 eh (*.f64 (cos.f64 t) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (sin.f64 t) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 ew (*.f64 (sin.f64 t) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))))): 1 points increase in error, 1 points decrease in error
    (fabs.f64 (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 ew (sin.f64 t)) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))))): 1 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error0.1
Cost58752
\[\left|\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
Alternative 2
Error0.2
Cost52480
\[\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + \frac{\sin t}{\frac{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}{ew}}\right| \]
Alternative 3
Error0.1
Cost52480
\[\left|\sin t \cdot \frac{ew}{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)} + \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right)\right| \]
Alternative 4
Error0.6
Cost52416
\[\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right| \]
Alternative 5
Error0.9
Cost45504
\[\left|\mathsf{fma}\left(ew, \sin t, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
Alternative 6
Error0.9
Cost39232
\[\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + ew \cdot \sin t\right| \]
Alternative 7
Error30.6
Cost33480
\[\begin{array}{l} t_1 := \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\ t_2 := \left|t_1 \cdot \left(eh \cdot \cos t\right) + t \cdot \left(t \cdot \left(ew \cdot \frac{ew}{eh}\right)\right)\right|\\ \mathbf{if}\;t \leq -2.3029387703270613 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3.23974755028935 \cdot 10^{-108}:\\ \;\;\;\;\left|\frac{{\left(ew \cdot t\right)}^{2}}{eh} + eh \cdot t_1\right|\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error31.0
Cost33348
\[\begin{array}{l} t_1 := \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right)\\ \mathbf{if}\;ew \leq -5.581973334199524 \cdot 10^{+63}:\\ \;\;\;\;\left|t_1 + ew \cdot \left(ew \cdot \frac{t}{\frac{eh}{t}}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_1 + t \cdot \left(t \cdot \left(ew \cdot \frac{ew}{eh}\right)\right)\right|\\ \end{array} \]
Alternative 9
Error34.8
Cost33216
\[\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + ew \cdot \left(\frac{ew}{eh} \cdot \left(t \cdot t\right)\right)\right| \]
Alternative 10
Error31.5
Cost33216
\[\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + \left(ew \cdot t\right) \cdot \frac{t}{\frac{eh}{ew}}\right| \]
Alternative 11
Error35.4
Cost26948
\[\begin{array}{l} \mathbf{if}\;ew \leq -3.0413654570959255 \cdot 10^{+146}:\\ \;\;\;\;\left|ew \cdot \left(ew \cdot \frac{t}{\frac{eh}{t}}\right) + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{t \cdot t}{\frac{\frac{eh}{ew}}{ew}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right|\\ \end{array} \]
Alternative 12
Error38.9
Cost26688
\[\left|\left(ew \cdot t\right) \cdot \frac{t}{\frac{eh}{ew}} + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
Alternative 13
Error42.8
Cost20288
\[\left|\frac{t \cdot t}{\frac{eh}{ew \cdot ew}} + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right| \]

Error

Reproduce

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