?

Average Error: 16.7 → 1.3
Time: 15.5s
Precision: binary64
Cost: 52681

?

\[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
\[\begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+45} \lor \neg \left(\pi \cdot \ell \leq 1000000000000\right):\\ \;\;\;\;\pi \cdot \ell + \frac{1}{F \cdot \left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right)\right)\right) \cdot \left(-F\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}\\ \end{array} \]
(FPCore (F l)
 :precision binary64
 (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))
(FPCore (F l)
 :precision binary64
 (if (or (<= (* PI l) -1e+45) (not (<= (* PI l) 1000000000000.0)))
   (+
    (* PI l)
    (/
     1.0
     (*
      F
      (*
       (log1p (expm1 (fma (* PI -0.3333333333333333) l (/ (/ 1.0 l) PI))))
       (- F)))))
   (- (* PI l) (/ (/ (tan (* PI l)) F) F))))
double code(double F, double l) {
	return (((double) M_PI) * l) - ((1.0 / (F * F)) * tan((((double) M_PI) * l)));
}
double code(double F, double l) {
	double tmp;
	if (((((double) M_PI) * l) <= -1e+45) || !((((double) M_PI) * l) <= 1000000000000.0)) {
		tmp = (((double) M_PI) * l) + (1.0 / (F * (log1p(expm1(fma((((double) M_PI) * -0.3333333333333333), l, ((1.0 / l) / ((double) M_PI))))) * -F)));
	} else {
		tmp = (((double) M_PI) * l) - ((tan((((double) M_PI) * l)) / F) / F);
	}
	return tmp;
}
function code(F, l)
	return Float64(Float64(pi * l) - Float64(Float64(1.0 / Float64(F * F)) * tan(Float64(pi * l))))
end
function code(F, l)
	tmp = 0.0
	if ((Float64(pi * l) <= -1e+45) || !(Float64(pi * l) <= 1000000000000.0))
		tmp = Float64(Float64(pi * l) + Float64(1.0 / Float64(F * Float64(log1p(expm1(fma(Float64(pi * -0.3333333333333333), l, Float64(Float64(1.0 / l) / pi)))) * Float64(-F)))));
	else
		tmp = Float64(Float64(pi * l) - Float64(Float64(tan(Float64(pi * l)) / F) / F));
	end
	return tmp
end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(1.0 / N[(F * F), $MachinePrecision]), $MachinePrecision] * N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[F_, l_] := If[Or[LessEqual[N[(Pi * l), $MachinePrecision], -1e+45], N[Not[LessEqual[N[(Pi * l), $MachinePrecision], 1000000000000.0]], $MachinePrecision]], N[(N[(Pi * l), $MachinePrecision] + N[(1.0 / N[(F * N[(N[Log[1 + N[(Exp[N[(N[(Pi * -0.3333333333333333), $MachinePrecision] * l + N[(N[(1.0 / l), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] * (-F)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * l), $MachinePrecision] - N[(N[(N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision]]
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
\begin{array}{l}
\mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+45} \lor \neg \left(\pi \cdot \ell \leq 1000000000000\right):\\
\;\;\;\;\pi \cdot \ell + \frac{1}{F \cdot \left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right)\right)\right) \cdot \left(-F\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}\\


\end{array}

Error?

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < -9.9999999999999993e44 or 1e12 < (*.f64 (PI.f64) l)

    1. Initial program 23.4

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Applied egg-rr23.4

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \color{blue}{\frac{1}{\frac{1}{\tan \left(\pi \cdot \ell\right)}}} \]
    3. Taylor expanded in l around 0 18.5

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \frac{1}{\color{blue}{\left(-0.5 \cdot \pi - -0.16666666666666666 \cdot \pi\right) \cdot \ell + \frac{1}{\ell \cdot \pi}}} \]
    4. Simplified18.5

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right)}} \]
      Proof

      [Start]18.5

      \[ \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \frac{1}{\left(-0.5 \cdot \pi - -0.16666666666666666 \cdot \pi\right) \cdot \ell + \frac{1}{\ell \cdot \pi}} \]

      fma-def [=>]18.5

      \[ \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(-0.5 \cdot \pi - -0.16666666666666666 \cdot \pi, \ell, \frac{1}{\ell \cdot \pi}\right)}} \]

      distribute-rgt-out-- [=>]18.5

      \[ \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \frac{1}{\mathsf{fma}\left(\color{blue}{\pi \cdot \left(-0.5 - -0.16666666666666666\right)}, \ell, \frac{1}{\ell \cdot \pi}\right)} \]

      metadata-eval [=>]18.5

      \[ \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \frac{1}{\mathsf{fma}\left(\pi \cdot \color{blue}{-0.3333333333333333}, \ell, \frac{1}{\ell \cdot \pi}\right)} \]

      associate-/r* [=>]18.5

      \[ \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \frac{1}{\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \color{blue}{\frac{\frac{1}{\ell}}{\pi}}\right)} \]
    5. Applied egg-rr14.1

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{-1}{\left(\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right) \cdot F\right) \cdot \left(-F\right)}} \]
    6. Applied egg-rr0.4

      \[\leadsto \pi \cdot \ell - \frac{-1}{\left(\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right)\right)\right)} \cdot F\right) \cdot \left(-F\right)} \]

    if -9.9999999999999993e44 < (*.f64 (PI.f64) l) < 1e12

    1. Initial program 10.3

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Applied egg-rr2.1

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+45} \lor \neg \left(\pi \cdot \ell \leq 1000000000000\right):\\ \;\;\;\;\pi \cdot \ell + \frac{1}{F \cdot \left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right)\right)\right) \cdot \left(-F\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}\\ \end{array} \]

Alternatives

Alternative 1
Error7.9
Cost32969
\[\begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+45} \lor \neg \left(\pi \cdot \ell \leq 1000000000000\right):\\ \;\;\;\;\pi \cdot \ell + \frac{3}{F \cdot \left(\pi \cdot \left(\ell \cdot F\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}\\ \end{array} \]
Alternative 2
Error8.3
Cost26697
\[\begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -100000000 \lor \neg \left(\pi \cdot \ell \leq 5 \cdot 10^{-8}\right):\\ \;\;\;\;\pi \cdot \ell + \frac{3}{F \cdot \left(\pi \cdot \left(\ell \cdot F\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \ell - \frac{\pi}{\frac{F}{\frac{\ell}{F}}}\\ \end{array} \]
Alternative 3
Error8.2
Cost26688
\[\pi \cdot \ell + \frac{1}{F \cdot \left(\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right) \cdot \left(-F\right)\right)} \]
Alternative 4
Error8.2
Cost26624
\[\pi \cdot \ell + \frac{\frac{-1}{F}}{\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right) \cdot F} \]
Alternative 5
Error8.2
Cost26624
\[\pi \cdot \ell + \frac{\frac{-1}{\mathsf{fma}\left(\pi \cdot -0.3333333333333333, \ell, \frac{\frac{1}{\ell}}{\pi}\right) \cdot F}}{F} \]
Alternative 6
Error21.4
Cost13376
\[\pi \cdot \ell - \ell \cdot \frac{\pi}{F \cdot F} \]
Alternative 7
Error21.1
Cost13376
\[\pi \cdot \ell - \pi \cdot \frac{\ell}{F \cdot F} \]
Alternative 8
Error17.2
Cost13376
\[\pi \cdot \ell - \frac{\ell}{F} \cdot \frac{\pi}{F} \]
Alternative 9
Error17.2
Cost13376
\[\pi \cdot \ell - \pi \cdot \frac{\frac{\ell}{F}}{F} \]
Alternative 10
Error17.2
Cost13376
\[\pi \cdot \ell - \frac{\pi}{\frac{F}{\frac{\ell}{F}}} \]

Error

Reproduce?

herbie shell --seed 2023066 
(FPCore (F l)
  :name "VandenBroeck and Keller, Equation (6)"
  :precision binary64
  (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))