Average Error: 0.1 → 0.1
Time: 16.4s
Precision: binary64
Cost: 77888
\[\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, \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\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))
   (expm1 (log1p (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((((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)), expm1(log1p(cos(atan((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)), expm1(log1p(cos(atan(Float64(eh / Float64(ew * tan(t))))))), Float64(eh * Float64(cos(t) * sin(atan(Float64(Float64(eh / 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[(Exp[N[Log[1 + N[Cos[N[ArcTan[N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] + N[(eh * N[(N[Cos[t], $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $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, \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\right), eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\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{\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 (*.f64 ew (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 (*.f64 ew (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)))))))): 1 points increase in error, 0 points decrease in error
    (fabs.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.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)))))))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.1

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

    \[\leadsto \left|\mathsf{fma}\left(ew \cdot \sin t, \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right)\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
Cost58880
\[\begin{array}{l} t_1 := \frac{\frac{eh}{ew}}{\tan t}\\ \left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\mathsf{hypot}\left(1, t_1\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} t_1\right)\right)\right| \end{array} \]
Alternative 2
Error0.1
Cost58816
\[\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 + \sin t_1 \cdot \left(eh \cdot \cos t\right)\right| \end{array} \]
Alternative 3
Error0.1
Cost52608
\[\begin{array}{l} t_1 := \frac{\frac{eh}{ew}}{\tan t}\\ \left|\sin \tan^{-1} t_1 \cdot \left(eh \cdot \cos t\right) + \left(ew \cdot \sin t\right) \cdot \frac{1}{\mathsf{hypot}\left(1, t_1\right)}\right| \end{array} \]
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
Cost45632
\[\left|\mathsf{fma}\left(ew \cdot \sin t, 1, 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|ew \cdot \sin t + \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right)\right| \]
Alternative 7
Error2.2
Cost33608
\[\begin{array}{l} t_1 := ew \cdot \sin t\\ t_2 := eh \cdot \cos t\\ t_3 := \left|t_1 + t_2 \cdot \sin \tan^{-1} \left(-0.3333333333333333 \cdot \frac{t \cdot eh}{ew} + \frac{eh}{ew \cdot t}\right)\right|\\ \mathbf{if}\;t \leq -1.7 \cdot 10^{+85}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 7 \cdot 10^{+81}:\\ \;\;\;\;\left|t_1 + t_2 \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error7.0
Cost32832
\[\left|ew \cdot \sin t + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right| \]
Alternative 9
Error13.8
Cost32704
\[\left|ew \cdot \sin t + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right| \]
Alternative 10
Error42.7
Cost26688
\[\left|eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \left(ew \cdot ew\right) \cdot \left(t \cdot \frac{t}{eh}\right)\right| \]
Alternative 11
Error42.0
Cost26688
\[\left|eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) + \frac{t}{\frac{\frac{eh}{ew \cdot ew}}{t}}\right| \]
Alternative 12
Error43.1
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| \]

Error

Reproduce

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