?

Average Error: 59.5 → 58.1
Time: 1.2min
Precision: binary64
Cost: 20104

?

\[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
\[\begin{array}{l} t_0 := \frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{-162}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;\frac{\left(-1 - \sin^{-1} \left(\sqrt{0.5}\right) \cdot 4\right) + \left(\pi + 1\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0)))))))
   (if (<= x -1.7e-162)
     t_0
     (if (<= x 5.5e-17)
       (/ (+ (- -1.0 (* (asin (sqrt 0.5)) 4.0)) (+ PI 1.0)) 2.0)
       t_0))))
double code(double x) {
	return (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
}
double code(double x) {
	double t_0 = (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
	double tmp;
	if (x <= -1.7e-162) {
		tmp = t_0;
	} else if (x <= 5.5e-17) {
		tmp = ((-1.0 - (asin(sqrt(0.5)) * 4.0)) + (((double) M_PI) + 1.0)) / 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double x) {
	return (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
}
public static double code(double x) {
	double t_0 = (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
	double tmp;
	if (x <= -1.7e-162) {
		tmp = t_0;
	} else if (x <= 5.5e-17) {
		tmp = ((-1.0 - (Math.asin(Math.sqrt(0.5)) * 4.0)) + (Math.PI + 1.0)) / 2.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x):
	return (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0))))
def code(x):
	t_0 = (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0))))
	tmp = 0
	if x <= -1.7e-162:
		tmp = t_0
	elif x <= 5.5e-17:
		tmp = ((-1.0 - (math.asin(math.sqrt(0.5)) * 4.0)) + (math.pi + 1.0)) / 2.0
	else:
		tmp = t_0
	return tmp
function code(x)
	return Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0)))))
end
function code(x)
	t_0 = Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0)))))
	tmp = 0.0
	if (x <= -1.7e-162)
		tmp = t_0;
	elseif (x <= 5.5e-17)
		tmp = Float64(Float64(Float64(-1.0 - Float64(asin(sqrt(0.5)) * 4.0)) + Float64(pi + 1.0)) / 2.0);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp = code(x)
	tmp = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
end
function tmp_2 = code(x)
	t_0 = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
	tmp = 0.0;
	if (x <= -1.7e-162)
		tmp = t_0;
	elseif (x <= 5.5e-17)
		tmp = ((-1.0 - (asin(sqrt(0.5)) * 4.0)) + (pi + 1.0)) / 2.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_] := N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7e-162], t$95$0, If[LessEqual[x, 5.5e-17], N[(N[(N[(-1.0 - N[(N[ArcSin[N[Sqrt[0.5], $MachinePrecision]], $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] + N[(Pi + 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$0]]]
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\begin{array}{l}
t_0 := \frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{-162}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 5.5 \cdot 10^{-17}:\\
\;\;\;\;\frac{\left(-1 - \sin^{-1} \left(\sqrt{0.5}\right) \cdot 4\right) + \left(\pi + 1\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original59.5
Target0
Herbie58.1
\[\sin^{-1} x \]

Derivation?

  1. Split input into 2 regimes
  2. if x < -1.7e-162 or 5.50000000000000001e-17 < x

    1. Initial program 53.0

      \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]

    if -1.7e-162 < x < 5.50000000000000001e-17

    1. Initial program 62.2

      \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    2. Applied egg-rr60.1

      \[\leadsto \color{blue}{\frac{\pi \cdot 2 - \left(\pi + \sin^{-1} \left(\sqrt{0.5 + \frac{x}{-2}}\right) \cdot 4\right)}{2}} \]
    3. Applied egg-rr60.1

      \[\leadsto \frac{\color{blue}{\left(-1 - \sin^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right) \cdot 4\right) + \left(\pi + 1\right)}}{2} \]
    4. Taylor expanded in x around 0 60.1

      \[\leadsto \frac{\left(-1 - \sin^{-1} \color{blue}{\left(\sqrt{0.5}\right)} \cdot 4\right) + \left(\pi + 1\right)}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-162}:\\ \;\;\;\;\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;\frac{\left(-1 - \sin^{-1} \left(\sqrt{0.5}\right) \cdot 4\right) + \left(\pi + 1\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error58.6
Cost46336
\[\begin{array}{l} t_0 := \sin^{-1} \left(\sqrt{-0.5 \cdot x + 0.5}\right)\\ \frac{\frac{\pi}{-2} + \left(2 \cdot \left(\pi - t_0\right) + \left(\frac{\pi}{-2} - 2 \cdot t_0\right)\right)}{2} \end{array} \]
Alternative 2
Error58.6
Cost39552
\[\begin{array}{l} t_0 := \sin^{-1} \left(\sqrt{-0.5 \cdot x + 0.5}\right)\\ \frac{\left(-\pi\right) - 2 \cdot \left(t_0 - \left(\pi - t_0\right)\right)}{2} \end{array} \]
Alternative 3
Error58.6
Cost20096
\[\frac{\left(-1 - \sin^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right) \cdot 4\right) + \left(\pi + 1\right)}{2} \]
Alternative 4
Error59.5
Cost19840
\[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
Alternative 5
Error61.4
Cost19584
\[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{0.5}\right) \]

Error

Reproduce?

herbie shell --seed 2023099 
(FPCore (x)
  :name "Ian Simplification"
  :precision binary64

  :herbie-target
  (asin x)

  (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))