?

Average Error: 27.9 → 1.1
Time: 17.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 \cdot -2\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq \infty:\\ \;\;\;\;\frac{t_0}{{\left(\left(s \cdot x\right) \cdot c\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}\\ \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 -2.0))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x)))
        INFINITY)
     (/ t_0 (pow (* (* s x) c) 2.0))
     (/ t_0 (pow (* (* c s) x) 2.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 = cos((x * -2.0));
	double tmp;
	if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= ((double) INFINITY)) {
		tmp = t_0 / pow(((s * x) * c), 2.0);
	} else {
		tmp = t_0 / pow(((c * s) * x), 2.0);
	}
	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 * -2.0));
	double tmp;
	if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= Double.POSITIVE_INFINITY) {
		tmp = t_0 / Math.pow(((s * x) * c), 2.0);
	} else {
		tmp = t_0 / Math.pow(((c * s) * x), 2.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 = math.cos((x * -2.0))
	tmp = 0
	if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= math.inf:
		tmp = t_0 / math.pow(((s * x) * c), 2.0)
	else:
		tmp = t_0 / math.pow(((c * s) * x), 2.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 = cos(Float64(x * -2.0))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= Inf)
		tmp = Float64(t_0 / (Float64(Float64(s * x) * c) ^ 2.0));
	else
		tmp = Float64(t_0 / (Float64(Float64(c * s) * x) ^ 2.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 = cos((x * -2.0));
	tmp = 0.0;
	if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= Inf)
		tmp = t_0 / (((s * x) * c) ^ 2.0);
	else
		tmp = t_0 / (((c * s) * x) ^ 2.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[Cos[N[(x * -2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[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], Infinity], N[(t$95$0 / N[Power[N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[Power[N[(N[(c * s), $MachinePrecision] * x), $MachinePrecision], 2.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 := \cos \left(x \cdot -2\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq \infty:\\
\;\;\;\;\frac{t_0}{{\left(\left(s \cdot x\right) \cdot c\right)}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}\\


\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 18.1

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

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

      [Start]18.1

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

      trig.json-simplify-28 [=>]18.1

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

      trig.json-simplify-28 [=>]18.1

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

      trig.json-simplify-28 [=>]18.1

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

      rational.json-simplify-8 [=>]18.1

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

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

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

      rational.json-simplify-12 [=>]18.1

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

      rational.json-simplify-12 [=>]18.1

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

      rational.json-simplify-44 [=>]18.1

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

      metadata-eval [=>]18.1

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

      rational.json-simplify-5 [=>]18.1

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

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

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

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

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

      metadata-eval [=>]18.1

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

      rational.json-simplify-43 [<=]16.2

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

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

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

      exponential.json-simplify-27 [=>]12.8

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

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

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

      [Start]23.0

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

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

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

      rational.json-simplify-43 [<=]22.9

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

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

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

      exponential.json-simplify-27 [=>]9.6

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

      exponential.json-simplify-27 [=>]0.6

      \[ \frac{\cos \left(x \cdot -2\right)}{\color{blue}{{\left(\left(s \cdot x\right) \cdot c\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 64.0

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

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

      [Start]64.0

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

      trig.json-simplify-28 [=>]64.0

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

      trig.json-simplify-28 [=>]64.0

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

      trig.json-simplify-28 [=>]64.0

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

      rational.json-simplify-8 [=>]64.0

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

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

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

      rational.json-simplify-12 [=>]64.0

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

      rational.json-simplify-12 [=>]64.0

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

      rational.json-simplify-44 [=>]64.0

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

      metadata-eval [=>]64.0

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

      rational.json-simplify-5 [=>]64.0

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

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

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

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

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

      metadata-eval [=>]64.0

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

      rational.json-simplify-43 [<=]63.7

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

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

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

      exponential.json-simplify-27 [=>]16.5

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

      \[\leadsto \frac{\cos \left(x \cdot -2\right)}{x \cdot \left(x \cdot \color{blue}{\left({\left(s \cdot \left(s \cdot \left(c \cdot c\right)\right)\right)}^{2} \cdot {\left(\frac{1}{s \cdot c}\right)}^{2}\right)}\right)} \]
    4. Simplified28.0

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

      [Start]58.0

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

      exponential.json-simplify-27 [=>]57.8

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

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

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

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

      \[ \frac{\cos \left(x \cdot -2\right)}{x \cdot \left(x \cdot {\left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \frac{1}{\color{blue}{c \cdot s}}\right)}^{2}\right)} \]
    5. Taylor expanded in x around 0 64.0

      \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\color{blue}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    6. Simplified3.1

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

      [Start]64.0

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

      rational.json-simplify-43 [<=]63.9

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

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

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

      exponential.json-simplify-26 [<=]25.0

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

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

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

      exponential.json-simplify-27 [=>]3.1

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

      rational.json-simplify-2 [<=]3.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq \infty:\\ \;\;\;\;\frac{\cos \left(x \cdot -2\right)}{{\left(\left(s \cdot x\right) \cdot c\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot -2\right)}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}\\ \end{array} \]

Alternatives

Alternative 1
Error3.0
Cost13572
\[\begin{array}{l} t_0 := \cos \left(x \cdot -2\right)\\ \mathbf{if}\;c \leq -1.25 \cdot 10^{+110}:\\ \;\;\;\;\frac{t_0}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}\\ \end{array} \]
Alternative 2
Error2.8
Cost13440
\[\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}} \]
Alternative 3
Error16.5
Cost6912
\[\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}} \]

Error

Reproduce?

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