?

Average Error: 15.3 → 0.4
Time: 24.0s
Precision: binary64
Cost: 59656

?

\[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
\[\begin{array}{l} t_0 := \sin \left(x \cdot 0.5\right)\\ t_1 := \frac{\left(2.6666666666666665 \cdot t_0\right) \cdot t_0}{\sin x}\\ t_2 := {t_0}^{2}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{-8}:\\ \;\;\;\;2.6666666666666665 \cdot \frac{t_2}{\sin x}\\ \mathbf{elif}\;t_1 \leq 4 \cdot 10^{-38}:\\ \;\;\;\;\frac{x}{0.6666666666666666} \cdot 0.4444444444444444\\ \mathbf{else}:\\ \;\;\;\;\frac{2.6666666666666665 \cdot t_2}{\sin x}\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sin (* x 0.5)))
        (t_1 (/ (* (* 2.6666666666666665 t_0) t_0) (sin x)))
        (t_2 (pow t_0 2.0)))
   (if (<= t_1 -5e-8)
     (* 2.6666666666666665 (/ t_2 (sin x)))
     (if (<= t_1 4e-38)
       (* (/ x 0.6666666666666666) 0.4444444444444444)
       (/ (* 2.6666666666666665 t_2) (sin x))))))
double code(double x) {
	return (((8.0 / 3.0) * sin((x * 0.5))) * sin((x * 0.5))) / sin(x);
}
double code(double x) {
	double t_0 = sin((x * 0.5));
	double t_1 = ((2.6666666666666665 * t_0) * t_0) / sin(x);
	double t_2 = pow(t_0, 2.0);
	double tmp;
	if (t_1 <= -5e-8) {
		tmp = 2.6666666666666665 * (t_2 / sin(x));
	} else if (t_1 <= 4e-38) {
		tmp = (x / 0.6666666666666666) * 0.4444444444444444;
	} else {
		tmp = (2.6666666666666665 * t_2) / sin(x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (((8.0d0 / 3.0d0) * sin((x * 0.5d0))) * sin((x * 0.5d0))) / sin(x)
end function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = sin((x * 0.5d0))
    t_1 = ((2.6666666666666665d0 * t_0) * t_0) / sin(x)
    t_2 = t_0 ** 2.0d0
    if (t_1 <= (-5d-8)) then
        tmp = 2.6666666666666665d0 * (t_2 / sin(x))
    else if (t_1 <= 4d-38) then
        tmp = (x / 0.6666666666666666d0) * 0.4444444444444444d0
    else
        tmp = (2.6666666666666665d0 * t_2) / sin(x)
    end if
    code = tmp
end function
public static double code(double x) {
	return (((8.0 / 3.0) * Math.sin((x * 0.5))) * Math.sin((x * 0.5))) / Math.sin(x);
}
public static double code(double x) {
	double t_0 = Math.sin((x * 0.5));
	double t_1 = ((2.6666666666666665 * t_0) * t_0) / Math.sin(x);
	double t_2 = Math.pow(t_0, 2.0);
	double tmp;
	if (t_1 <= -5e-8) {
		tmp = 2.6666666666666665 * (t_2 / Math.sin(x));
	} else if (t_1 <= 4e-38) {
		tmp = (x / 0.6666666666666666) * 0.4444444444444444;
	} else {
		tmp = (2.6666666666666665 * t_2) / Math.sin(x);
	}
	return tmp;
}
def code(x):
	return (((8.0 / 3.0) * math.sin((x * 0.5))) * math.sin((x * 0.5))) / math.sin(x)
def code(x):
	t_0 = math.sin((x * 0.5))
	t_1 = ((2.6666666666666665 * t_0) * t_0) / math.sin(x)
	t_2 = math.pow(t_0, 2.0)
	tmp = 0
	if t_1 <= -5e-8:
		tmp = 2.6666666666666665 * (t_2 / math.sin(x))
	elif t_1 <= 4e-38:
		tmp = (x / 0.6666666666666666) * 0.4444444444444444
	else:
		tmp = (2.6666666666666665 * t_2) / math.sin(x)
	return tmp
function code(x)
	return Float64(Float64(Float64(Float64(8.0 / 3.0) * sin(Float64(x * 0.5))) * sin(Float64(x * 0.5))) / sin(x))
end
function code(x)
	t_0 = sin(Float64(x * 0.5))
	t_1 = Float64(Float64(Float64(2.6666666666666665 * t_0) * t_0) / sin(x))
	t_2 = t_0 ^ 2.0
	tmp = 0.0
	if (t_1 <= -5e-8)
		tmp = Float64(2.6666666666666665 * Float64(t_2 / sin(x)));
	elseif (t_1 <= 4e-38)
		tmp = Float64(Float64(x / 0.6666666666666666) * 0.4444444444444444);
	else
		tmp = Float64(Float64(2.6666666666666665 * t_2) / sin(x));
	end
	return tmp
end
function tmp = code(x)
	tmp = (((8.0 / 3.0) * sin((x * 0.5))) * sin((x * 0.5))) / sin(x);
end
function tmp_2 = code(x)
	t_0 = sin((x * 0.5));
	t_1 = ((2.6666666666666665 * t_0) * t_0) / sin(x);
	t_2 = t_0 ^ 2.0;
	tmp = 0.0;
	if (t_1 <= -5e-8)
		tmp = 2.6666666666666665 * (t_2 / sin(x));
	elseif (t_1 <= 4e-38)
		tmp = (x / 0.6666666666666666) * 0.4444444444444444;
	else
		tmp = (2.6666666666666665 * t_2) / sin(x);
	end
	tmp_2 = tmp;
end
code[x_] := N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(2.6666666666666665 * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$0, 2.0], $MachinePrecision]}, If[LessEqual[t$95$1, -5e-8], N[(2.6666666666666665 * N[(t$95$2 / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e-38], N[(N[(x / 0.6666666666666666), $MachinePrecision] * 0.4444444444444444), $MachinePrecision], N[(N[(2.6666666666666665 * t$95$2), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]]]]]
\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x}
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
t_1 := \frac{\left(2.6666666666666665 \cdot t_0\right) \cdot t_0}{\sin x}\\
t_2 := {t_0}^{2}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-8}:\\
\;\;\;\;2.6666666666666665 \cdot \frac{t_2}{\sin x}\\

\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-38}:\\
\;\;\;\;\frac{x}{0.6666666666666666} \cdot 0.4444444444444444\\

\mathbf{else}:\\
\;\;\;\;\frac{2.6666666666666665 \cdot t_2}{\sin x}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.3
Target0.3
Herbie0.4
\[\frac{\frac{8 \cdot \sin \left(x \cdot 0.5\right)}{3}}{\frac{\sin x}{\sin \left(x \cdot 0.5\right)}} \]

Derivation?

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 (*.f64 (/.f64 8 3) (sin.f64 (*.f64 x 1/2))) (sin.f64 (*.f64 x 1/2))) (sin.f64 x)) < -4.9999999999999998e-8

    1. Initial program 0.6

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Simplified0.6

      \[\leadsto \color{blue}{\frac{2.6666666666666665 \cdot \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right)}{\sin x}} \]
      Proof

      [Start]0.6

      \[ \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]

      rational.json-simplify-2 [=>]0.6

      \[ \frac{\color{blue}{\sin \left(x \cdot 0.5\right) \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right)}}{\sin x} \]

      rational.json-simplify-43 [=>]0.6

      \[ \frac{\color{blue}{\frac{8}{3} \cdot \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right)}}{\sin x} \]

      metadata-eval [=>]0.6

      \[ \frac{\color{blue}{2.6666666666666665} \cdot \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right)}{\sin x} \]
    3. Taylor expanded in x around inf 0.6

      \[\leadsto \color{blue}{2.6666666666666665 \cdot \frac{{\sin \left(0.5 \cdot x\right)}^{2}}{\sin x}} \]
    4. Simplified0.6

      \[\leadsto \color{blue}{2.6666666666666665 \cdot \frac{{\sin \left(x \cdot 0.5\right)}^{2}}{\sin x}} \]
      Proof

      [Start]0.6

      \[ 2.6666666666666665 \cdot \frac{{\sin \left(0.5 \cdot x\right)}^{2}}{\sin x} \]

      rational.json-simplify-2 [=>]0.6

      \[ 2.6666666666666665 \cdot \frac{{\sin \color{blue}{\left(x \cdot 0.5\right)}}^{2}}{\sin x} \]

    if -4.9999999999999998e-8 < (/.f64 (*.f64 (*.f64 (/.f64 8 3) (sin.f64 (*.f64 x 1/2))) (sin.f64 (*.f64 x 1/2))) (sin.f64 x)) < 3.9999999999999998e-38

    1. Initial program 31.8

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Simplified60.4

      \[\leadsto \color{blue}{\frac{2.6666666666666665 \cdot \frac{1 - \cos x}{2}}{\sin x}} \]
      Proof

      [Start]31.8

      \[ \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    3. Taylor expanded in x around 0 0.3

      \[\leadsto \color{blue}{0.6666666666666666 \cdot x} \]
    4. Simplified0.3

      \[\leadsto \color{blue}{x \cdot 0.6666666666666666} \]
      Proof

      [Start]0.3

      \[ 0.6666666666666666 \cdot x \]

      rational.json-simplify-2 [=>]0.3

      \[ \color{blue}{x \cdot 0.6666666666666666} \]
    5. Applied egg-rr60.0

      \[\leadsto \color{blue}{\left(0 - \left(-1 - x \cdot 0.6666666666666666\right)\right) - 1} \]
    6. Applied egg-rr0.2

      \[\leadsto \color{blue}{\frac{x}{0.6666666666666666} \cdot 0.4444444444444444} \]

    if 3.9999999999999998e-38 < (/.f64 (*.f64 (*.f64 (/.f64 8 3) (sin.f64 (*.f64 x 1/2))) (sin.f64 (*.f64 x 1/2))) (sin.f64 x))

    1. Initial program 0.6

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Simplified0.6

      \[\leadsto \color{blue}{\frac{2.6666666666666665 \cdot \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right)}{\sin x}} \]
      Proof

      [Start]0.6

      \[ \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]

      rational.json-simplify-2 [=>]0.6

      \[ \frac{\color{blue}{\sin \left(x \cdot 0.5\right) \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right)}}{\sin x} \]

      rational.json-simplify-43 [=>]0.6

      \[ \frac{\color{blue}{\frac{8}{3} \cdot \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right)}}{\sin x} \]

      metadata-eval [=>]0.6

      \[ \frac{\color{blue}{2.6666666666666665} \cdot \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right)}{\sin x} \]
    3. Taylor expanded in x around inf 0.6

      \[\leadsto \frac{2.6666666666666665 \cdot \color{blue}{{\sin \left(0.5 \cdot x\right)}^{2}}}{\sin x} \]
    4. Simplified0.6

      \[\leadsto \frac{2.6666666666666665 \cdot \color{blue}{{\sin \left(x \cdot 0.5\right)}^{2}}}{\sin x} \]
      Proof

      [Start]0.6

      \[ \frac{2.6666666666666665 \cdot {\sin \left(0.5 \cdot x\right)}^{2}}{\sin x} \]

      rational.json-simplify-2 [=>]0.6

      \[ \frac{2.6666666666666665 \cdot {\sin \color{blue}{\left(x \cdot 0.5\right)}}^{2}}{\sin x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(2.6666666666666665 \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \leq -5 \cdot 10^{-8}:\\ \;\;\;\;2.6666666666666665 \cdot \frac{{\sin \left(x \cdot 0.5\right)}^{2}}{\sin x}\\ \mathbf{elif}\;\frac{\left(2.6666666666666665 \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \leq 4 \cdot 10^{-38}:\\ \;\;\;\;\frac{x}{0.6666666666666666} \cdot 0.4444444444444444\\ \mathbf{else}:\\ \;\;\;\;\frac{2.6666666666666665 \cdot {\sin \left(x \cdot 0.5\right)}^{2}}{\sin x}\\ \end{array} \]

Alternatives

Alternative 1
Error0.4
Cost19976
\[\begin{array}{l} t_0 := 2.6666666666666665 \cdot \frac{{\sin \left(x \cdot 0.5\right)}^{2}}{\sin x}\\ \mathbf{if}\;x \leq -5 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-38}:\\ \;\;\;\;\frac{x}{0.6666666666666666} \cdot 0.4444444444444444\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.7
Cost14024
\[\begin{array}{l} t_0 := \frac{\left(\cos x + -1\right) \cdot -1.3333333333333333}{\sin x}\\ \mathbf{if}\;x \leq -0.018:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.0235:\\ \;\;\;\;2.6666666666666665 \cdot \left(0.25 \cdot x + \left(0.020833333333333332 \cdot {x}^{3} + 0.0020833333333333333 \cdot {x}^{5}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.7
Cost13896
\[\begin{array}{l} t_0 := \frac{\left(\cos x + -1\right) \cdot -1.3333333333333333}{\sin x}\\ \mathbf{if}\;x \leq -0.018:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.0235:\\ \;\;\;\;x \cdot 0.6666666666666666 + \left(0.05555555555555555 \cdot {x}^{3} + 0.005555555555555556 \cdot {x}^{5}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.7
Cost13512
\[\begin{array}{l} t_0 := 1.3333333333333333 \cdot \frac{1 - \cos x}{\sin x}\\ \mathbf{if}\;x \leq -0.0045:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.0044:\\ \;\;\;\;2.6666666666666665 \cdot \left(0.25 \cdot x + 0.020833333333333332 \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.7
Cost13512
\[\begin{array}{l} t_0 := \frac{\left(\cos x + -1\right) \cdot -1.3333333333333333}{\sin x}\\ \mathbf{if}\;x \leq -0.0045:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.0044:\\ \;\;\;\;2.6666666666666665 \cdot \left(0.25 \cdot x + 0.020833333333333332 \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error31.0
Cost320
\[\frac{x}{0.6666666666666666} \cdot 0.4444444444444444 \]
Alternative 7
Error31.0
Cost192
\[x \cdot 0.6666666666666666 \]

Error

Reproduce?

herbie shell --seed 2023077 
(FPCore (x)
  :name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
  :precision binary64

  :herbie-target
  (/ (/ (* 8.0 (sin (* x 0.5))) 3.0) (/ (sin x) (sin (* x 0.5))))

  (/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))