Average Error: 42.8 → 14.8
Time: 9.3s
Precision: binary64
\[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
\[\begin{array}{l} \mathbf{if}\;t \leq 0:\\ \;\;\;\;-\sqrt{\frac{-1 + x}{x + 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{2} \cdot \left(t \cdot \sqrt{\frac{x + 1}{-1 + x}}\right)}\\ \end{array} \]
(FPCore (x l t)
 :precision binary64
 (/
  (* (sqrt 2.0) t)
  (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))
(FPCore (x l t)
 :precision binary64
 (if (<= t 0.0)
   (- (sqrt (/ (+ -1.0 x) (+ x 1.0))))
   (/ (* t (sqrt 2.0)) (* (sqrt 2.0) (* t (sqrt (/ (+ x 1.0) (+ -1.0 x))))))))
double code(double x, double l, double t) {
	return (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
double code(double x, double l, double t) {
	double tmp;
	if (t <= 0.0) {
		tmp = -sqrt(((-1.0 + x) / (x + 1.0)));
	} else {
		tmp = (t * sqrt(2.0)) / (sqrt(2.0) * (t * sqrt(((x + 1.0) / (-1.0 + x)))));
	}
	return tmp;
}
real(8) function code(x, l, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: l
    real(8), intent (in) :: t
    code = (sqrt(2.0d0) * t) / sqrt(((((x + 1.0d0) / (x - 1.0d0)) * ((l * l) + (2.0d0 * (t * t)))) - (l * l)))
end function
real(8) function code(x, l, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: l
    real(8), intent (in) :: t
    real(8) :: tmp
    if (t <= 0.0d0) then
        tmp = -sqrt((((-1.0d0) + x) / (x + 1.0d0)))
    else
        tmp = (t * sqrt(2.0d0)) / (sqrt(2.0d0) * (t * sqrt(((x + 1.0d0) / ((-1.0d0) + x)))))
    end if
    code = tmp
end function
public static double code(double x, double l, double t) {
	return (Math.sqrt(2.0) * t) / Math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
public static double code(double x, double l, double t) {
	double tmp;
	if (t <= 0.0) {
		tmp = -Math.sqrt(((-1.0 + x) / (x + 1.0)));
	} else {
		tmp = (t * Math.sqrt(2.0)) / (Math.sqrt(2.0) * (t * Math.sqrt(((x + 1.0) / (-1.0 + x)))));
	}
	return tmp;
}
def code(x, l, t):
	return (math.sqrt(2.0) * t) / math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)))
def code(x, l, t):
	tmp = 0
	if t <= 0.0:
		tmp = -math.sqrt(((-1.0 + x) / (x + 1.0)))
	else:
		tmp = (t * math.sqrt(2.0)) / (math.sqrt(2.0) * (t * math.sqrt(((x + 1.0) / (-1.0 + x)))))
	return tmp
function code(x, l, t)
	return Float64(Float64(sqrt(2.0) * t) / sqrt(Float64(Float64(Float64(Float64(x + 1.0) / Float64(x - 1.0)) * Float64(Float64(l * l) + Float64(2.0 * Float64(t * t)))) - Float64(l * l))))
end
function code(x, l, t)
	tmp = 0.0
	if (t <= 0.0)
		tmp = Float64(-sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0))));
	else
		tmp = Float64(Float64(t * sqrt(2.0)) / Float64(sqrt(2.0) * Float64(t * sqrt(Float64(Float64(x + 1.0) / Float64(-1.0 + x))))));
	end
	return tmp
end
function tmp = code(x, l, t)
	tmp = (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
end
function tmp_2 = code(x, l, t)
	tmp = 0.0;
	if (t <= 0.0)
		tmp = -sqrt(((-1.0 + x) / (x + 1.0)));
	else
		tmp = (t * sqrt(2.0)) / (sqrt(2.0) * (t * sqrt(((x + 1.0) / (-1.0 + x)))));
	end
	tmp_2 = tmp;
end
code[x_, l_, t_] := N[(N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] + N[(2.0 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(l * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, l_, t_] := If[LessEqual[t, 0.0], (-N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), N[(N[(t * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[2.0], $MachinePrecision] * N[(t * N[Sqrt[N[(N[(x + 1.0), $MachinePrecision] / N[(-1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}}
\begin{array}{l}
\mathbf{if}\;t \leq 0:\\
\;\;\;\;-\sqrt{\frac{-1 + x}{x + 1}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{2} \cdot \left(t \cdot \sqrt{\frac{x + 1}{-1 + x}}\right)}\\


\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 t < 0.0

    1. Initial program 42.4

      \[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
    2. Simplified42.4

      \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{\sqrt{\mathsf{fma}\left(\frac{x + 1}{x + -1}, \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right), \ell \cdot \left(-\ell\right)\right)}}} \]
    3. Taylor expanded in t around -inf 14.3

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{-1 \cdot \left(\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}\right)}} \]
    4. Simplified14.3

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\sqrt{\frac{x + 1}{x + -1}} \cdot \left(-t \cdot \sqrt{2}\right)}} \]
    5. Taylor expanded in t around 0 14.3

      \[\leadsto \color{blue}{-1 \cdot \sqrt{\frac{x - 1}{1 + x}}} \]
    6. Simplified14.3

      \[\leadsto \color{blue}{-\sqrt{\frac{-1 + x}{x + 1}}} \]

    if 0.0 < t

    1. Initial program 43.2

      \[\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}} \]
    2. Simplified43.2

      \[\leadsto \color{blue}{\frac{\sqrt{2} \cdot t}{\sqrt{\mathsf{fma}\left(\frac{x + 1}{x + -1}, \mathsf{fma}\left(2, t \cdot t, \ell \cdot \ell\right), \ell \cdot \left(-\ell\right)\right)}}} \]
    3. Taylor expanded in t around inf 15.3

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\left(\sqrt{2} \cdot t\right) \cdot \sqrt{\frac{1 + x}{x - 1}}}} \]
    4. Simplified15.3

      \[\leadsto \frac{\sqrt{2} \cdot t}{\color{blue}{\sqrt{2} \cdot \left(t \cdot \sqrt{\frac{x + 1}{x + -1}}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 0:\\ \;\;\;\;-\sqrt{\frac{-1 + x}{x + 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot \sqrt{2}}{\sqrt{2} \cdot \left(t \cdot \sqrt{\frac{x + 1}{-1 + x}}\right)}\\ \end{array} \]

Reproduce

herbie shell --seed 2022181 
(FPCore (x l t)
  :name "Toniolo and Linder, Equation (7)"
  :precision binary64
  (/ (* (sqrt 2.0) t) (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))