?

Average Error: 16.7 → 5.3
Time: 8.5s
Precision: binary64
Cost: 32904

?

\[\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right) \]
\[\begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -100000000:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-35}:\\ \;\;\;\;\pi \cdot \ell - \frac{\ell \cdot \pi}{{F}^{2}}\\ \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) -100000000.0)
   (* l PI)
   (if (<= (* PI l) 5e-35) (- (* PI l) (/ (* l PI) (pow F 2.0))) (* 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) <= -100000000.0) {
		tmp = l * ((double) M_PI);
	} else if ((((double) M_PI) * l) <= 5e-35) {
		tmp = (((double) M_PI) * l) - ((l * ((double) M_PI)) / pow(F, 2.0));
	} 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) <= -100000000.0) {
		tmp = l * Math.PI;
	} else if ((Math.PI * l) <= 5e-35) {
		tmp = (Math.PI * l) - ((l * Math.PI) / Math.pow(F, 2.0));
	} 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) <= -100000000.0:
		tmp = l * math.pi
	elif (math.pi * l) <= 5e-35:
		tmp = (math.pi * l) - ((l * math.pi) / math.pow(F, 2.0))
	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) <= -100000000.0)
		tmp = Float64(l * pi);
	elseif (Float64(pi * l) <= 5e-35)
		tmp = Float64(Float64(pi * l) - Float64(Float64(l * pi) / (F ^ 2.0)));
	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) <= -100000000.0)
		tmp = l * pi;
	elseif ((pi * l) <= 5e-35)
		tmp = (pi * l) - ((l * pi) / (F ^ 2.0));
	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], -100000000.0], N[(l * Pi), $MachinePrecision], If[LessEqual[N[(Pi * l), $MachinePrecision], 5e-35], N[(N[(Pi * l), $MachinePrecision] - N[(N[(l * Pi), $MachinePrecision] / N[Power[F, 2.0], $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 -100000000:\\
\;\;\;\;\ell \cdot \pi\\

\mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-35}:\\
\;\;\;\;\pi \cdot \ell - \frac{\ell \cdot \pi}{{F}^{2}}\\

\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) < -1e8 or 4.99999999999999964e-35 < (*.f64 (PI.f64) l)

    1. Initial program 22.4

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell \cdot \pi}{{F}^{2}}} \]
    3. Taylor expanded in F around inf 1.8

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

    if -1e8 < (*.f64 (PI.f64) l) < 4.99999999999999964e-35

    1. Initial program 9.8

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

      \[\leadsto \pi \cdot \ell - \color{blue}{\frac{\ell \cdot \pi}{{F}^{2}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;\pi \cdot \ell \leq -100000000:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\pi \cdot \ell \leq 5 \cdot 10^{-35}:\\ \;\;\;\;\pi \cdot \ell - \frac{\ell \cdot \pi}{{F}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]

Alternatives

Alternative 1
Error5.2
Cost13896
\[\begin{array}{l} \mathbf{if}\;\ell \leq -3.7 \cdot 10^{-13}:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\ell \leq 2.5:\\ \;\;\;\;\pi \cdot \ell - \left(-\left(\frac{1}{F \cdot F} \cdot \left(-\ell\right)\right) \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
Alternative 2
Error5.2
Cost13768
\[\begin{array}{l} \mathbf{if}\;\ell \leq -3 \cdot 10^{-13}:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\ell \leq 2.5:\\ \;\;\;\;\pi \cdot \ell - \ell \cdot \left(\pi \cdot \frac{1}{F \cdot F}\right)\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
Alternative 3
Error5.2
Cost13768
\[\begin{array}{l} \mathbf{if}\;\ell \leq -3.7 \cdot 10^{-13}:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;\ell \leq 2.5:\\ \;\;\;\;\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \left(\ell \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
Alternative 4
Error13.3
Cost13448
\[\begin{array}{l} \mathbf{if}\;F \leq -5.8 \cdot 10^{-24}:\\ \;\;\;\;\ell \cdot \pi\\ \mathbf{elif}\;F \leq -9 \cdot 10^{-109}:\\ \;\;\;\;-\frac{\ell \cdot \pi}{{F}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \pi\\ \end{array} \]
Alternative 5
Error13.4
Cost6528
\[\ell \cdot \pi \]

Error

Reproduce?

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