Average Error: 0.1 → 0.1
Time: 22.0s
Precision: binary64
Cost: 58752
\[\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, \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| \]
(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) (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) / 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(ew, Float64(sin(t) / hypot(1.0, 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[(ew * N[(N[Sin[t], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + N[(eh / N[(ew * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $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, \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|

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)))))))): 1 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)))))))): 0 points increase in error, 0 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))))))): 0 points increase in error, 1 points decrease in error
  3. Applied egg-rr0.1

    \[\leadsto \left|\mathsf{fma}\left(ew, \color{blue}{\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| \]
  4. Final simplification0.1

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

Alternatives

Alternative 1
Error0.2
Cost52480
\[\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot \left(eh \cdot \cos t\right) + \frac{ew}{\frac{\mathsf{hypot}\left(1, \frac{eh}{ew \cdot \tan t}\right)}{\sin t}}\right| \]
Alternative 2
Error0.1
Cost52480
\[\left|\frac{ew \cdot \sin t}{\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 3
Error0.6
Cost52352
\[\left|\mathsf{fma}\left(ew, \frac{\sin t}{\mathsf{hypot}\left(1, \frac{\frac{eh}{ew}}{t}\right)}, eh \cdot \left(\cos t \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right)\right)\right| \]
Alternative 4
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 5
Error2.3
Cost33608
\[\begin{array}{l} t_1 := eh \cdot \cos t\\ t_2 := \left|ew \cdot \sin t + t_1 \cdot \sin \tan^{-1} \left(-0.3333333333333333 \cdot \frac{t \cdot eh}{ew} + \frac{eh}{ew \cdot t}\right)\right|\\ \mathbf{if}\;ew \leq -1.1056743929759096 \cdot 10^{-162}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ew \leq 1.271127590272913 \cdot 10^{-261}:\\ \;\;\;\;\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot t_1 + \frac{t}{\frac{\frac{eh}{ew \cdot ew}}{t}}\right|\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error5.7
Cost33480
\[\begin{array}{l} t_1 := eh \cdot \cos t\\ t_2 := \left|ew \cdot \sin t + t_1 \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right|\\ \mathbf{if}\;ew \leq -1.1056743929759096 \cdot 10^{-162}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ew \leq 2.1147211794104157 \cdot 10^{-160}:\\ \;\;\;\;\left|\sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right) \cdot t_1 + \frac{t}{\frac{\frac{eh}{ew \cdot ew}}{t}}\right|\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error7.8
Cost33096
\[\begin{array}{l} t_1 := eh \cdot \cos t\\ t_2 := \left|ew \cdot \sin t + t_1 \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right|\\ \mathbf{if}\;ew \leq -1.1056743929759096 \cdot 10^{-162}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ew \leq 2.1147211794104157 \cdot 10^{-160}:\\ \;\;\;\;\left|t_1 \cdot \sin \tan^{-1} \left(-0.3333333333333333 \cdot \frac{t \cdot eh}{ew} + \frac{eh}{ew \cdot t}\right) + \frac{t}{\frac{\frac{eh}{ew \cdot ew}}{t}}\right|\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error11.0
Cost32968
\[\begin{array}{l} t_1 := \left|ew \cdot \sin t + eh \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot \tan t}\right)\right|\\ \mathbf{if}\;ew \leq -1.1056743929759096 \cdot 10^{-162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ew \leq 1.6198385335633215 \cdot 10^{-119}:\\ \;\;\;\;\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(-0.3333333333333333 \cdot \frac{t \cdot eh}{ew} + \frac{eh}{ew \cdot t}\right) + \frac{t}{\frac{\frac{eh}{ew \cdot ew}}{t}}\right|\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error31.5
Cost27592
\[\begin{array}{l} t_1 := \left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(-0.3333333333333333 \cdot \frac{t \cdot eh}{ew} + \frac{eh}{ew \cdot t}\right) + \frac{t}{\frac{\frac{eh}{ew \cdot ew}}{t}}\right|\\ \mathbf{if}\;t \leq -3.246938973046916 \cdot 10^{+21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.5735413487961166 \cdot 10^{-10}:\\ \;\;\;\;\left|\frac{ew \cdot \left(t \cdot t\right)}{\frac{eh}{ew}} + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error31.9
Cost27080
\[\begin{array}{l} t_1 := \left|\frac{ew \cdot \left(t \cdot t\right)}{\frac{eh}{ew}} + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|\\ \mathbf{if}\;ew \leq -1.5964790470159132 \cdot 10^{+154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ew \leq 1.4723100663854253 \cdot 10^{+119}:\\ \;\;\;\;\left|\frac{t}{\frac{\frac{eh}{ew \cdot ew}}{t}} + \left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{ew \cdot t}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error39.3
Cost26952
\[\begin{array}{l} t_1 := eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\ t_2 := \left|t_1 + \frac{ew \cdot \left(ew \cdot \left(t \cdot t\right)\right)}{eh}\right|\\ \mathbf{if}\;ew \leq -1.5964790470159132 \cdot 10^{+154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ew \leq 7.409300126759388 \cdot 10^{+143}:\\ \;\;\;\;\left|t_1 + t \cdot \frac{ew \cdot ew}{\frac{eh}{t}}\right|\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error38.9
Cost26952
\[\begin{array}{l} t_1 := eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\ t_2 := \left|\frac{ew \cdot \left(t \cdot t\right)}{\frac{eh}{ew}} + t_1\right|\\ \mathbf{if}\;ew \leq -1.5964790470159132 \cdot 10^{+154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ew \leq 7.409300126759388 \cdot 10^{+143}:\\ \;\;\;\;\left|t_1 + t \cdot \frac{ew \cdot ew}{\frac{eh}{t}}\right|\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 13
Error41.3
Cost20288
\[\left|\left(t \cdot t\right) \cdot \left(ew \cdot \frac{ew}{eh}\right) + eh \cdot \sin \tan^{-1} \left(\frac{\frac{eh}{t}}{ew}\right)\right| \]

Error

Reproduce

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