?

Average Error: 43.59% → 3.39%
Time: 17.6s
Precision: binary64
Cost: 13705

?

\[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
\[\begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ t_1 := \cos \left(x + x\right)\\ \mathbf{if}\;s \leq -1.08 \cdot 10^{-200} \lor \neg \left(s \leq 5.2 \cdot 10^{-192}\right):\\ \;\;\;\;t_1 \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{t_0} \cdot \frac{1}{t_0}\\ \end{array} \]
(FPCore (x c s)
 :precision binary64
 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* x (* c s))) (t_1 (cos (+ x x))))
   (if (or (<= s -1.08e-200) (not (<= s 5.2e-192)))
     (* t_1 (pow (* s (* x c)) -2.0))
     (* (/ t_1 t_0) (/ 1.0 t_0)))))
double code(double x, double c, double s) {
	return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	double t_1 = cos((x + x));
	double tmp;
	if ((s <= -1.08e-200) || !(s <= 5.2e-192)) {
		tmp = t_1 * pow((s * (x * c)), -2.0);
	} else {
		tmp = (t_1 / t_0) * (1.0 / t_0);
	}
	return tmp;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (c * s)
    t_1 = cos((x + x))
    if ((s <= (-1.08d-200)) .or. (.not. (s <= 5.2d-192))) then
        tmp = t_1 * ((s * (x * c)) ** (-2.0d0))
    else
        tmp = (t_1 / t_0) * (1.0d0 / t_0)
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
public static double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	double t_1 = Math.cos((x + x));
	double tmp;
	if ((s <= -1.08e-200) || !(s <= 5.2e-192)) {
		tmp = t_1 * Math.pow((s * (x * c)), -2.0);
	} else {
		tmp = (t_1 / t_0) * (1.0 / t_0);
	}
	return tmp;
}
def code(x, c, s):
	return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
def code(x, c, s):
	t_0 = x * (c * s)
	t_1 = math.cos((x + x))
	tmp = 0
	if (s <= -1.08e-200) or not (s <= 5.2e-192):
		tmp = t_1 * math.pow((s * (x * c)), -2.0)
	else:
		tmp = (t_1 / t_0) * (1.0 / t_0)
	return tmp
function code(x, c, s)
	return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x)))
end
function code(x, c, s)
	t_0 = Float64(x * Float64(c * s))
	t_1 = cos(Float64(x + x))
	tmp = 0.0
	if ((s <= -1.08e-200) || !(s <= 5.2e-192))
		tmp = Float64(t_1 * (Float64(s * Float64(x * c)) ^ -2.0));
	else
		tmp = Float64(Float64(t_1 / t_0) * Float64(1.0 / t_0));
	end
	return tmp
end
function tmp = code(x, c, s)
	tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x));
end
function tmp_2 = code(x, c, s)
	t_0 = x * (c * s);
	t_1 = cos((x + x));
	tmp = 0.0;
	if ((s <= -1.08e-200) || ~((s <= 5.2e-192)))
		tmp = t_1 * ((s * (x * c)) ^ -2.0);
	else
		tmp = (t_1 / t_0) * (1.0 / t_0);
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[s, -1.08e-200], N[Not[LessEqual[s, 5.2e-192]], $MachinePrecision]], N[(t$95$1 * N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
t_1 := \cos \left(x + x\right)\\
\mathbf{if}\;s \leq -1.08 \cdot 10^{-200} \lor \neg \left(s \leq 5.2 \cdot 10^{-192}\right):\\
\;\;\;\;t_1 \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} \cdot \frac{1}{t_0}\\


\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 s < -1.08000000000000002e-200 or 5.2000000000000003e-192 < s

    1. Initial program 37.86

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Simplified4.5

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
      Proof

      [Start]37.86

      \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]

      *-commutative [=>]37.86

      \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]

      associate-*l* [=>]44.59

      \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]

      associate-*r* [=>]44.6

      \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]

      *-commutative [=>]44.6

      \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left({c}^{2} \cdot {s}^{2}\right)}} \]

      unpow2 [=>]44.6

      \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot {s}^{2}\right)} \]

      unpow2 [=>]44.6

      \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]

      unswap-sqr [=>]30.1

      \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}} \]

      unswap-sqr [=>]4.5

      \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
    3. Taylor expanded in x around inf 44.59

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Simplified2.89

      \[\leadsto \color{blue}{\cos \left(x + x\right) \cdot {\left(s \cdot \left(c \cdot x\right)\right)}^{-2}} \]
      Proof

      [Start]44.59

      \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]

      count-2 [<=]44.59

      \[ \frac{\cos \color{blue}{\left(x + x\right)}}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]

      associate-*r* [=>]44.6

      \[ \frac{\cos \left(x + x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]

      unpow2 [=>]44.6

      \[ \frac{\cos \left(x + x\right)}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)}} \]

      associate-/r* [=>]44.54

      \[ \color{blue}{\frac{\frac{\cos \left(x + x\right)}{{c}^{2} \cdot {s}^{2}}}{x \cdot x}} \]

      unpow2 [=>]44.54

      \[ \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot {s}^{2}}}{x \cdot x} \]

      unpow2 [=>]44.54

      \[ \frac{\frac{\cos \left(x + x\right)}{\left(c \cdot c\right) \cdot \color{blue}{\left(s \cdot s\right)}}}{x \cdot x} \]

      swap-sqr [<=]30.13

      \[ \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(c \cdot s\right)}}}{x \cdot x} \]

      unpow2 [<=]30.13

      \[ \frac{\frac{\cos \left(x + x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}}}}{x \cdot x} \]

      *-lft-identity [<=]30.13

      \[ \frac{\color{blue}{1 \cdot \frac{\cos \left(x + x\right)}{{\left(c \cdot s\right)}^{2}}}}{x \cdot x} \]

      associate-*l/ [<=]30.79

      \[ \color{blue}{\frac{1}{x \cdot x} \cdot \frac{\cos \left(x + x\right)}{{\left(c \cdot s\right)}^{2}}} \]

      unpow2 [=>]30.79

      \[ \frac{1}{x \cdot x} \cdot \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(c \cdot s\right)}} \]

      associate-/r* [=>]30.66

      \[ \frac{1}{x \cdot x} \cdot \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c \cdot s}}{c \cdot s}} \]

      times-frac [<=]24.34

      \[ \color{blue}{\frac{1 \cdot \frac{\cos \left(x + x\right)}{c \cdot s}}{\left(x \cdot x\right) \cdot \left(c \cdot s\right)}} \]

      *-commutative [<=]24.34

      \[ \frac{1 \cdot \frac{\cos \left(x + x\right)}{c \cdot s}}{\color{blue}{\left(c \cdot s\right) \cdot \left(x \cdot x\right)}} \]

      associate-*r* [=>]10.54

      \[ \frac{1 \cdot \frac{\cos \left(x + x\right)}{c \cdot s}}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot x}} \]

      *-commutative [<=]10.54

      \[ \frac{1 \cdot \frac{\cos \left(x + x\right)}{c \cdot s}}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right)} \cdot x} \]

    if -1.08000000000000002e-200 < s < 5.2000000000000003e-192

    1. Initial program 100

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Simplified8.39

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
      Proof

      [Start]100

      \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]

      *-commutative [=>]100

      \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\color{blue}{\left({s}^{2} \cdot x\right)} \cdot x\right)} \]

      associate-*l* [=>]100

      \[ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]

      associate-*r* [=>]100

      \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]

      *-commutative [=>]100

      \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left({c}^{2} \cdot {s}^{2}\right)}} \]

      unpow2 [=>]100

      \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot {s}^{2}\right)} \]

      unpow2 [=>]100

      \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]

      unswap-sqr [=>]42.86

      \[ \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}} \]

      unswap-sqr [=>]8.39

      \[ \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
    3. Applied egg-rr8.31

      \[\leadsto \color{blue}{\frac{\cos \left(x + x\right)}{x \cdot \left(c \cdot s\right)} \cdot \frac{1}{x \cdot \left(c \cdot s\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.39

    \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq -1.08 \cdot 10^{-200} \lor \neg \left(s \leq 5.2 \cdot 10^{-192}\right):\\ \;\;\;\;\cos \left(x + x\right) \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x + x\right)}{x \cdot \left(c \cdot s\right)} \cdot \frac{1}{x \cdot \left(c \cdot s\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error2%
Cost33540
\[\begin{array}{l} t_0 := \cos \left(x + x\right)\\ t_1 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{t_0}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{t_1} \cdot \frac{1}{t_1}\\ \end{array} \]
Alternative 2
Error26.45%
Cost7888
\[\begin{array}{l} t_0 := \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)\right)}\\ t_1 := \frac{1}{s \cdot \left(x \cdot c\right)}\\ t_2 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;c \leq -6.2 \cdot 10^{-19}:\\ \;\;\;\;t_1 \cdot t_1\\ \mathbf{elif}\;c \leq -3.1 \cdot 10^{-186}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{-216}:\\ \;\;\;\;\frac{\frac{1}{t_2}}{t_2}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{-35}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{s \cdot \left(c \cdot \left(x \cdot c\right)\right)}{\frac{1}{x \cdot s}}}\\ \end{array} \]
Alternative 3
Error3.87%
Cost7753
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ t_1 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;s \leq -6.8 \cdot 10^{-200} \lor \neg \left(s \leq 1.12 \cdot 10^{-209}\right):\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{t_0 \cdot t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x + x\right)}{t_1} \cdot \frac{1}{t_1}\\ \end{array} \]
Alternative 4
Error11.17%
Cost7625
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ t_1 := \frac{1}{t_0}\\ \mathbf{if}\;x \leq -145000000 \lor \neg \left(x \leq 2.9 \cdot 10^{-23}\right):\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot \left(s \cdot t_0\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot t_1\\ \end{array} \]
Alternative 5
Error3.86%
Cost7625
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ t_1 := x \cdot \left(c \cdot s\right)\\ t_2 := \cos \left(2 \cdot x\right)\\ \mathbf{if}\;s \leq -2.7 \cdot 10^{-201} \lor \neg \left(s \leq 1.2 \cdot 10^{-202}\right):\\ \;\;\;\;\frac{t_2}{t_0 \cdot t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2}{t_1 \cdot t_1}\\ \end{array} \]
Alternative 6
Error12.27%
Cost7624
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ t_1 := \frac{1}{t_0}\\ t_2 := \cos \left(2 \cdot x\right)\\ \mathbf{if}\;x \leq -9 \cdot 10^{-100}:\\ \;\;\;\;\frac{t_2}{x \cdot \left(x \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)\right)}\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-23}:\\ \;\;\;\;t_1 \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2}{x \cdot \left(c \cdot \left(s \cdot t_0\right)\right)}\\ \end{array} \]
Alternative 7
Error4.81%
Cost7360
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \frac{\cos \left(2 \cdot x\right)}{t_0 \cdot t_0} \end{array} \]
Alternative 8
Error32.52%
Cost964
\[\begin{array}{l} \mathbf{if}\;c \leq -1.3 \cdot 10^{+43}:\\ \;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(s \cdot \left(c \cdot \left(x \cdot \left(x \cdot s\right)\right)\right)\right)}\\ \end{array} \]
Alternative 9
Error29.53%
Cost964
\[\begin{array}{l} \mathbf{if}\;c \leq -9.5 \cdot 10^{+67}:\\ \;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \end{array} \]
Alternative 10
Error30.62%
Cost964
\[\begin{array}{l} \mathbf{if}\;c \leq -6.6 \cdot 10^{+164}:\\ \;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot c\right) \cdot \left(s \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \end{array} \]
Alternative 11
Error25.86%
Cost960
\[\begin{array}{l} t_0 := \frac{1}{s \cdot \left(x \cdot c\right)}\\ t_0 \cdot t_0 \end{array} \]
Alternative 12
Error35.23%
Cost832
\[\frac{1}{c \cdot \left(s \cdot \left(c \cdot \left(x \cdot \left(x \cdot s\right)\right)\right)\right)} \]
Alternative 13
Error25.95%
Cost832
\[\begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{1}{t_0 \cdot t_0} \end{array} \]
Alternative 14
Error26.06%
Cost832
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \frac{1}{t_0 \cdot t_0} \end{array} \]
Alternative 15
Error25.83%
Cost832
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \frac{\frac{1}{t_0}}{t_0} \end{array} \]

Error

Reproduce?

herbie shell --seed 2023102 
(FPCore (x c s)
  :name "mixedcos"
  :precision binary64
  (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))