?

Average Error: 44.36% → 1.76%
Time: 16.0s
Precision: binary64
Cost: 33540

?

\[ \begin{array}{c}[c, s] = \mathsf{sort}([c, s])\\ \end{array} \]
\[\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 := \cos \left(x + x\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}:\\ \;\;\;\;t_0 \cdot \frac{\frac{\frac{1}{x}}{c \cdot s}}{x \cdot \left(c \cdot s\right)}\\ \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 (cos (+ x x))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c 2.0) (* x (* x (pow s 2.0)))))
        INFINITY)
     (/ t_0 (pow (* c (* x s)) 2.0))
     (* t_0 (/ (/ (/ 1.0 x) (* c s)) (* x (* c s)))))))
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 = cos((x + x));
	double tmp;
	if ((cos((2.0 * x)) / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = t_0 / pow((c * (x * s)), 2.0);
	} else {
		tmp = t_0 * (((1.0 / x) / (c * s)) / (x * (c * s)));
	}
	return tmp;
}
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 = Math.cos((x + x));
	double tmp;
	if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
		tmp = t_0 / Math.pow((c * (x * s)), 2.0);
	} else {
		tmp = t_0 * (((1.0 / x) / (c * s)) / (x * (c * s)));
	}
	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 = math.cos((x + x))
	tmp = 0
	if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf:
		tmp = t_0 / math.pow((c * (x * s)), 2.0)
	else:
		tmp = t_0 * (((1.0 / x) / (c * s)) / (x * (c * s)))
	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 = cos(Float64(x + x))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf)
		tmp = Float64(t_0 / (Float64(c * Float64(x * s)) ^ 2.0));
	else
		tmp = Float64(t_0 * Float64(Float64(Float64(1.0 / x) / Float64(c * s)) / Float64(x * Float64(c * s))));
	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 = cos((x + x));
	tmp = 0.0;
	if ((cos((2.0 * x)) / ((c ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf)
		tmp = t_0 / ((c * (x * s)) ^ 2.0);
	else
		tmp = t_0 * (((1.0 / x) / (c * s)) / (x * (c * s)));
	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[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 / N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(1.0 / x), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision] / N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $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 := \cos \left(x + x\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}:\\
\;\;\;\;t_0 \cdot \frac{\frac{\frac{1}{x}}{c \cdot s}}{x \cdot \left(c \cdot s\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 (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x))) < +inf.0

    1. Initial program 28.98

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

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

      [Start]28.98

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

      associate-*r* [=>]25.73

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

      *-commutative [=>]25.73

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

      *-commutative [=>]25.73

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

      associate-*r* [=>]28.85

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

      *-commutative [=>]28.85

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

      unpow2 [=>]28.85

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

      unpow2 [=>]28.85

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

      unswap-sqr [=>]20.62

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

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

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

      [Start]36.33

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

      count-2 [<=]36.33

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

      associate-*r* [=>]36.46

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

      associate-/r* [=>]36.49

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

      *-commutative [=>]36.49

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

      unpow2 [=>]36.49

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

      unpow2 [=>]36.49

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

      swap-sqr [<=]30.4

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

      unpow2 [<=]30.4

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

      associate-/l/ [=>]30.34

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

      unpow2 [=>]30.34

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

      unpow2 [=>]30.34

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

      swap-sqr [<=]4.3

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

      unpow2 [<=]4.3

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

      *-commutative [=>]4.3

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

      associate-*l* [=>]0.97

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

    if +inf.0 < (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x)))

    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. Simplified5.1

      \[\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* [=>]99.8

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

      *-commutative [=>]99.8

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

      unpow2 [=>]99.8

      \[ \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 [=>]99.8

      \[ \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 [=>]37.29

      \[ \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 [=>]5.1

      \[ \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-rr4.66

      \[\leadsto \color{blue}{{\left(x \cdot \left(c \cdot s\right)\right)}^{-2} \cdot \cos \left(x + x\right)} \]
    4. Applied egg-rr4.62

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

    \[\leadsto \begin{array}{l} \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{\cos \left(x + x\right)}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(x + x\right) \cdot \frac{\frac{\frac{1}{x}}{c \cdot s}}{x \cdot \left(c \cdot s\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error10.26%
Cost7756
\[\begin{array}{l} t_0 := \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot \left(s \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)\right)}\\ \mathbf{if}\;x \leq -4.2 \cdot 10^{-18}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-253}:\\ \;\;\;\;{\left(\frac{1}{x \cdot \left(c \cdot s\right)}\right)}^{2}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-20}:\\ \;\;\;\;\frac{1}{\frac{c \cdot \left(x \cdot s\right)}{\frac{\frac{1}{c}}{x \cdot s}}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error3.93%
Cost7753
\[\begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;x \leq -1 \cdot 10^{-252} \lor \neg \left(x \leq 3.1 \cdot 10^{-43}\right):\\ \;\;\;\;\frac{\cos \left(x + x\right)}{t_0} \cdot \frac{1}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{c \cdot \left(x \cdot s\right)}{\frac{\frac{1}{c}}{x \cdot s}}}\\ \end{array} \]
Alternative 3
Error3.43%
Cost7752
\[\begin{array}{l} t_0 := \cos \left(x + x\right)\\ t_1 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;x \leq -2.7 \cdot 10^{-253}:\\ \;\;\;\;\frac{t_0}{t_1} \cdot \frac{1}{t_1}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-190}:\\ \;\;\;\;\frac{1}{\frac{c \cdot \left(x \cdot s\right)}{\frac{\frac{1}{c}}{x \cdot s}}}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \frac{\frac{\frac{1}{x}}{c \cdot s}}{t_1}\\ \end{array} \]
Alternative 4
Error6.08%
Cost7625
\[\begin{array}{l} t_0 := \frac{1}{s \cdot \left(x \cdot c\right)}\\ \mathbf{if}\;x \leq -2.25 \cdot 10^{-157} \lor \neg \left(x \leq 2.15 \cdot 10^{-190}\right):\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot t_0\\ \end{array} \]
Alternative 5
Error4.26%
Cost7625
\[\begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;x \leq -1.04 \cdot 10^{-252} \lor \neg \left(x \leq 4 \cdot 10^{-25}\right):\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{t_0 \cdot t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{c \cdot \left(x \cdot s\right)}{\frac{\frac{1}{c}}{x \cdot s}}}\\ \end{array} \]
Alternative 6
Error19.54%
Cost7624
\[\begin{array}{l} t_0 := \frac{1}{s \cdot \left(x \cdot c\right)}\\ \mathbf{if}\;s \leq 1.7 \cdot 10^{-155}:\\ \;\;\;\;t_0 \cdot t_0\\ \mathbf{elif}\;s \leq 6.5 \cdot 10^{+101}:\\ \;\;\;\;\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)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{c \cdot \left(x \cdot s\right)}{\frac{\frac{1}{c}}{x \cdot s}}}\\ \end{array} \]
Alternative 7
Error25.61%
Cost7044
\[\begin{array}{l} \mathbf{if}\;c \leq -1.4 \cdot 10^{+246}:\\ \;\;\;\;{\left(\frac{1}{x \cdot \left(c \cdot s\right)}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{c \cdot \left(x \cdot s\right)}{\frac{\frac{1}{c}}{x \cdot s}}}\\ \end{array} \]
Alternative 8
Error37.79%
Cost1229
\[\begin{array}{l} \mathbf{if}\;s \leq -7.8 \cdot 10^{-121} \lor \neg \left(s \leq 1.65 \cdot 10^{-170}\right) \land s \leq 5.6 \cdot 10^{+158}:\\ \;\;\;\;\frac{1}{\left(x \cdot c\right) \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)}\\ \end{array} \]
Alternative 9
Error25.1%
Cost1092
\[\begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ t_1 := \frac{1}{s \cdot \left(x \cdot c\right)}\\ \mathbf{if}\;c \leq -1 \cdot 10^{+246}:\\ \;\;\;\;t_1 \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0 \cdot t_0}\\ \end{array} \]
Alternative 10
Error25.1%
Cost1092
\[\begin{array}{l} t_0 := \frac{1}{s \cdot \left(x \cdot c\right)}\\ \mathbf{if}\;c \leq -1.4 \cdot 10^{+246}:\\ \;\;\;\;t_0 \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{c \cdot \left(x \cdot s\right)}{\frac{\frac{1}{c}}{x \cdot s}}}\\ \end{array} \]
Alternative 11
Error26.08%
Cost964
\[\begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \mathbf{if}\;c \leq -1 \cdot 10^{+246}:\\ \;\;\;\;\frac{1}{x \cdot \left(\left(c \cdot s\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_0 \cdot t_0}\\ \end{array} \]
Alternative 12
Error44.3%
Cost832
\[\frac{1}{\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)} \]
Alternative 13
Error26.26%
Cost832
\[\begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{1}{t_0 \cdot t_0} \end{array} \]

Error

Reproduce?

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