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

Error

Derivation

  1. Initial program 0.1

    \[\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right| \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(ew, \cos t \cdot \cos \tan^{-1} \left(-\frac{\tan t}{\frac{ew}{eh}}\right), \left(eh \cdot \sin t\right) \cdot \left(-\sin \tan^{-1} \left(-\frac{\tan t}{\frac{ew}{eh}}\right)\right)\right)\right|} \]
    Proof
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (neg.f64 (/.f64 (tan.f64 t) (/.f64 ew eh)))))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (neg.f64 (/.f64 (tan.f64 t) (/.f64 ew eh))))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (neg.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (tan.f64 t) eh) ew)))))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (neg.f64 (/.f64 (tan.f64 t) (/.f64 ew eh))))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (neg.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 eh (tan.f64 t))) ew))))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (neg.f64 (/.f64 (tan.f64 t) (/.f64 ew eh))))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (Rewrite<= distribute-frac-neg_binary64 (/.f64 (neg.f64 (*.f64 eh (tan.f64 t))) ew))))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (neg.f64 (/.f64 (tan.f64 t) (/.f64 ew eh))))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 eh) (tan.f64 t))) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (neg.f64 (/.f64 (tan.f64 t) (/.f64 ew eh))))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (neg.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (tan.f64 t) eh) ew))))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (neg.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 eh (tan.f64 t))) ew)))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (Rewrite<= distribute-frac-neg_binary64 (/.f64 (neg.f64 (*.f64 eh (tan.f64 t))) ew)))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (neg.f64 (sin.f64 (atan.f64 (/.f64 (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 eh) (tan.f64 t))) ew))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (Rewrite<= +-rgt-identity_binary64 (+.f64 (neg.f64 (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) 0))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (Rewrite=> +-rgt-identity_binary64 (neg.f64 (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (fma.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))))))): 0 points increase in error, 0 points decrease in error
    (fabs.f64 (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 ew (*.f64 (cos.f64 t) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))))): 1 points increase in error, 0 points decrease in error
    (fabs.f64 (-.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error0.1
Cost58944
\[\begin{array}{l} t_1 := \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right)\\ \left|\left(eh \cdot \sin t\right) \cdot \sin t_1 - \cos t_1 \cdot \left(ew \cdot \cos t\right)\right| \end{array} \]
Alternative 2
Error0.2
Cost52480
\[\begin{array}{l} t_1 := \tan t \cdot \frac{eh}{ew}\\ \left|eh \cdot \left(\sin t \cdot \sin \tan^{-1} t_1\right) + \frac{ew}{\frac{\mathsf{hypot}\left(1, t_1\right)}{\cos t}}\right| \end{array} \]
Alternative 3
Error0.1
Cost52480
\[\begin{array}{l} t_1 := \tan t \cdot \frac{eh}{ew}\\ \left|ew \cdot \frac{\cos t}{\mathsf{hypot}\left(1, t_1\right)} + eh \cdot \left(\sin t \cdot \sin \tan^{-1} t_1\right)\right| \end{array} \]
Alternative 4
Error8.5
Cost46280
\[\begin{array}{l} t_1 := \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(eh \cdot \frac{-t}{ew}\right)\\ \mathbf{if}\;eh \leq -2.2558044157324876 \cdot 10^{-29}:\\ \;\;\;\;\left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)} - t_1\right|\\ \mathbf{elif}\;eh \leq 6.595694042910323 \cdot 10^{-165}:\\ \;\;\;\;\left|ew \cdot \cos t\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_1 - ew \cdot \cos \tan^{-1} \left(\frac{eh \cdot \left(-\tan t\right)}{ew}\right)\right|\\ \end{array} \]
Alternative 5
Error8.5
Cost40008
\[\begin{array}{l} t_1 := \left|ew \cdot \frac{1}{\mathsf{hypot}\left(1, \tan t \cdot \frac{eh}{ew}\right)} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(eh \cdot \frac{-t}{ew}\right)\right|\\ \mathbf{if}\;eh \leq -2.2558044157324876 \cdot 10^{-29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;eh \leq 6.595694042910323 \cdot 10^{-165}:\\ \;\;\;\;\left|ew \cdot \cos t\right|\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error8.9
Cost39880
\[\begin{array}{l} t_1 := \tan^{-1} \left(\frac{t \cdot \left(-eh\right)}{ew}\right)\\ t_2 := \left|ew \cdot \cos t_1 - \left(eh \cdot \sin t\right) \cdot \sin t_1\right|\\ \mathbf{if}\;eh \leq -2.2558044157324876 \cdot 10^{-29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;eh \leq 6.595694042910323 \cdot 10^{-165}:\\ \;\;\;\;\left|ew \cdot \cos t\right|\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error15.9
Cost33368
\[\begin{array}{l} t_1 := eh \cdot \sin \tan^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)\\ t_2 := \left|ew \cdot \cos t\right|\\ t_3 := \left|\sin t \cdot t_1\right|\\ \mathbf{if}\;t \leq -4.539174103790171 \cdot 10^{+214}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -25200.629913037305:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 4.1667186241433605 \cdot 10^{-19}:\\ \;\;\;\;\left|ew + t \cdot t_1\right|\\ \mathbf{elif}\;t \leq 1.0347951074825192 \cdot 10^{+34}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.150022058340306 \cdot 10^{+215}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 7.985253912535933 \cdot 10^{+263}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error16.9
Cost26568
\[\begin{array}{l} t_1 := \left|ew \cdot \cos t\right|\\ \mathbf{if}\;t \leq -2.28115143250595 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.0347951074825192 \cdot 10^{+34}:\\ \;\;\;\;\left|ew + t \cdot \left(eh \cdot \sin \tan^{-1} \left(\frac{\tan t \cdot eh}{ew}\right)\right)\right|\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error24.7
Cost12992
\[\left|ew \cdot \cos t\right| \]
Alternative 10
Error36.9
Cost6464
\[\left|ew\right| \]

Error

Reproduce

herbie shell --seed 2022311 
(FPCore (eh ew t)
  :name "Example 2 from Robby"
  :precision binary64
  (fabs (- (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))