?

Average Error: 16.5 → 1.5
Time: 15.1s
Precision: binary64
Cost: 33096

?

\[\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^{+27}:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\pi \cdot \ell \leq 2 \cdot 10^{-48}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{1}{F}}{\frac{F}{\tan \left(\pi \cdot \ell\right)}}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
(FPCore (F l)
 :precision binary64
 (- (* PI l) (* (/ 1.0 (* F F)) (tan (* PI l)))))
(FPCore (F l)
 :precision binary64
 (if (<= (* PI l) -1e+27)
   (* l PI)
   (if (<= (* PI l) 2e-48)
     (- (* PI l) (/ (/ 1.0 F) (/ F (tan (* PI l)))))
     (* l PI))))
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+27) {
		tmp = l * ((double) M_PI);
	} else if ((((double) M_PI) * l) <= 2e-48) {
		tmp = (((double) M_PI) * l) - ((1.0 / F) / (F / tan((((double) M_PI) * l))));
	} else {
		tmp = l * ((double) M_PI);
	}
	return tmp;
}
public static double code(double F, double l) {
	return (Math.PI * l) - ((1.0 / (F * F)) * Math.tan((Math.PI * l)));
}
public static double code(double F, double l) {
	double tmp;
	if ((Math.PI * l) <= -1e+27) {
		tmp = l * Math.PI;
	} else if ((Math.PI * l) <= 2e-48) {
		tmp = (Math.PI * l) - ((1.0 / F) / (F / Math.tan((Math.PI * l))));
	} else {
		tmp = l * Math.PI;
	}
	return tmp;
}
def code(F, l):
	return (math.pi * l) - ((1.0 / (F * F)) * math.tan((math.pi * l)))
def code(F, l):
	tmp = 0
	if (math.pi * l) <= -1e+27:
		tmp = l * math.pi
	elif (math.pi * l) <= 2e-48:
		tmp = (math.pi * l) - ((1.0 / F) / (F / math.tan((math.pi * l))))
	else:
		tmp = l * math.pi
	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+27)
		tmp = Float64(l * pi);
	elseif (Float64(pi * l) <= 2e-48)
		tmp = Float64(Float64(pi * l) - Float64(Float64(1.0 / F) / Float64(F / tan(Float64(pi * l)))));
	else
		tmp = Float64(l * pi);
	end
	return tmp
end
function tmp = code(F, l)
	tmp = (pi * l) - ((1.0 / (F * F)) * tan((pi * l)));
end
function tmp_2 = code(F, l)
	tmp = 0.0;
	if ((pi * l) <= -1e+27)
		tmp = l * pi;
	elseif ((pi * l) <= 2e-48)
		tmp = (pi * l) - ((1.0 / F) / (F / tan((pi * l))));
	else
		tmp = l * pi;
	end
	tmp_2 = 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[LessEqual[N[(Pi * l), $MachinePrecision], -1e+27], N[(l * Pi), $MachinePrecision], If[LessEqual[N[(Pi * l), $MachinePrecision], 2e-48], N[(N[(Pi * l), $MachinePrecision] - N[(N[(1.0 / F), $MachinePrecision] / N[(F / N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * Pi), $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^{+27}:\\
\;\;\;\;\ell \cdot \pi\\

\mathbf{elif}\;\pi \cdot \ell \leq 2 \cdot 10^{-48}:\\
\;\;\;\;\pi \cdot \ell - \frac{\frac{1}{F}}{\frac{F}{\tan \left(\pi \cdot \ell\right)}}\\

\mathbf{else}:\\
\;\;\;\;\ell \cdot \pi\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < -1e27 or 1.9999999999999999e-48 < (*.f64 (PI.f64) l)

    1. Initial program 22.1

      \[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
    2. Taylor expanded in l around 0 30.6

      \[\leadsto \pi \cdot \ell - \frac{1}{F \cdot F} \cdot \color{blue}{\left(\ell \cdot \pi\right)} \]
    3. Applied egg-rr30.6

      \[\leadsto \pi \cdot \ell - \color{blue}{\left(\ell \cdot \frac{\pi}{F \cdot F} + 0\right)} \]
    4. Simplified30.6

      \[\leadsto \pi \cdot \ell - \color{blue}{\ell \cdot \frac{\pi}{F \cdot F}} \]
      Proof

      [Start]30.6

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

      rational.json-simplify-4 [=>]30.6

      \[ \pi \cdot \ell - \color{blue}{\ell \cdot \frac{\pi}{F \cdot F}} \]
    5. Taylor expanded in F around inf 1.9

      \[\leadsto \color{blue}{\ell \cdot \pi} \]

    if -1e27 < (*.f64 (PI.f64) l) < 1.9999999999999999e-48

    1. Initial program 10.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+27}:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\pi \cdot \ell \leq 2 \cdot 10^{-48}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{1}{F}}{\frac{F}{\tan \left(\pi \cdot \ell\right)}}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]

Alternatives

Alternative 1
Error2.2
Cost457092
\[\begin{array}{l} t_0 := 0.008333333333333333 \cdot {\pi}^{5} - \left({\pi}^{5} \cdot 0.041666666666666664 + {\pi}^{2} \cdot \left(-0.16666666666666666 \cdot {\pi}^{3}\right)\right)\\ t_1 := {\pi}^{3} \cdot 0.3333333333333333\\ t_2 := F \cdot \left(\frac{t_0}{{\pi}^{2}} + \left(-\frac{{\pi}^{6} \cdot 0.1111111111111111}{{\pi}^{3}}\right)\right)\\ \mathbf{if}\;\pi \cdot \ell \leq 2 \cdot 10^{-48}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{1}{F}}{\frac{F}{\ell \cdot \pi} + -1 \cdot \left(\left(\left(-0.0001984126984126984 \cdot {\pi}^{7} - \left({\pi}^{2} \cdot \left(-0.5 \cdot t_0\right) + \left({\pi}^{4} \cdot \left({\pi}^{3} \cdot 0.013888888888888888\right) + {\pi}^{7} \cdot -0.001388888888888889\right)\right)\right) \cdot \frac{F}{{\pi}^{2}} + \left(-t_1 \cdot \left(\frac{t_2}{\pi} + t_0 \cdot \frac{F}{{\pi}^{3}}\right)\right)\right) \cdot {\ell}^{5} + \left(F \cdot \left(\ell \cdot \frac{t_1}{{\pi}^{2}}\right) + {\ell}^{3} \cdot t_2\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
Alternative 2
Error1.5
Cost32968
\[\begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+27}:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\pi \cdot \ell \leq 2 \cdot 10^{-48}:\\ \;\;\;\;\pi \cdot \ell - \frac{\frac{\tan \left(\pi \cdot \ell\right)}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
Alternative 3
Error1.4
Cost20168
\[\begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -1 \cdot 10^{+14}:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\pi \cdot \ell \leq 2 \cdot 10^{-48}:\\ \;\;\;\;\pi \cdot \left(\ell + \frac{\frac{-\ell}{F}}{F}\right)\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
Alternative 4
Error5.2
Cost7176
\[\begin{array}{l} \mathbf{if}\;\ell \leq -340000:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-41}:\\ \;\;\;\;\pi \cdot \left(\ell - \frac{\ell}{F \cdot F}\right)\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
Alternative 5
Error13.2
Cost6528
\[\ell \cdot \pi \]

Error

Reproduce?

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