?

Average Error: 28.4 → 2.4
Time: 24.3s
Precision: binary64
Cost: 13832

?

\[ \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)\\ t_1 := {\left(c \cdot \left(s \cdot x\right)\right)}^{2}\\ \mathbf{if}\;c \leq -7.9 \cdot 10^{-162}:\\ \;\;\;\;\frac{1}{t_1} \cdot t_0\\ \mathbf{elif}\;c \leq 2.25 \cdot 10^{-237}:\\ \;\;\;\;\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}} \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{t_1}\\ \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))) (t_1 (pow (* c (* s x)) 2.0)))
   (if (<= c -7.9e-162)
     (* (/ 1.0 t_1) t_0)
     (if (<= c 2.25e-237)
       (* (/ 1.0 (pow (* s (* c x)) 2.0)) t_0)
       (/ t_0 t_1)))))
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 t_1 = pow((c * (s * x)), 2.0);
	double tmp;
	if (c <= -7.9e-162) {
		tmp = (1.0 / t_1) * t_0;
	} else if (c <= 2.25e-237) {
		tmp = (1.0 / pow((s * (c * x)), 2.0)) * t_0;
	} else {
		tmp = t_0 / t_1;
	}
	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 = cos((x + x))
    t_1 = (c * (s * x)) ** 2.0d0
    if (c <= (-7.9d-162)) then
        tmp = (1.0d0 / t_1) * t_0
    else if (c <= 2.25d-237) then
        tmp = (1.0d0 / ((s * (c * x)) ** 2.0d0)) * t_0
    else
        tmp = t_0 / t_1
    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 = Math.cos((x + x));
	double t_1 = Math.pow((c * (s * x)), 2.0);
	double tmp;
	if (c <= -7.9e-162) {
		tmp = (1.0 / t_1) * t_0;
	} else if (c <= 2.25e-237) {
		tmp = (1.0 / Math.pow((s * (c * x)), 2.0)) * t_0;
	} else {
		tmp = t_0 / t_1;
	}
	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))
	t_1 = math.pow((c * (s * x)), 2.0)
	tmp = 0
	if c <= -7.9e-162:
		tmp = (1.0 / t_1) * t_0
	elif c <= 2.25e-237:
		tmp = (1.0 / math.pow((s * (c * x)), 2.0)) * t_0
	else:
		tmp = t_0 / t_1
	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))
	t_1 = Float64(c * Float64(s * x)) ^ 2.0
	tmp = 0.0
	if (c <= -7.9e-162)
		tmp = Float64(Float64(1.0 / t_1) * t_0);
	elseif (c <= 2.25e-237)
		tmp = Float64(Float64(1.0 / (Float64(s * Float64(c * x)) ^ 2.0)) * t_0);
	else
		tmp = Float64(t_0 / t_1);
	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));
	t_1 = (c * (s * x)) ^ 2.0;
	tmp = 0.0;
	if (c <= -7.9e-162)
		tmp = (1.0 / t_1) * t_0;
	elseif (c <= 2.25e-237)
		tmp = (1.0 / ((s * (c * x)) ^ 2.0)) * t_0;
	else
		tmp = t_0 / t_1;
	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]}, Block[{t$95$1 = N[Power[N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[c, -7.9e-162], N[(N[(1.0 / t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[c, 2.25e-237], N[(N[(1.0 / N[Power[N[(s * N[(c * x), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 / t$95$1), $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)\\
t_1 := {\left(c \cdot \left(s \cdot x\right)\right)}^{2}\\
\mathbf{if}\;c \leq -7.9 \cdot 10^{-162}:\\
\;\;\;\;\frac{1}{t_1} \cdot t_0\\

\mathbf{elif}\;c \leq 2.25 \cdot 10^{-237}:\\
\;\;\;\;\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}} \cdot t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 3 regimes
  2. if c < -7.9000000000000002e-162

    1. Initial program 24.8

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

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

      [Start]24.8

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

      rational.json-simplify-46 [=>]24.9

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

      rational.json-simplify-46 [=>]23.2

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

      rational.json-simplify-47 [=>]23.1

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

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

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

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

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

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

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

      [Start]28.6

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

      metadata-eval [<=]28.6

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

      rational.json-simplify-7 [<=]28.6

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

      rational.json-simplify-30 [=>]28.6

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

      rational.json-simplify-7 [=>]28.6

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

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

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

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

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

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

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

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

      \[ \frac{\cos \left(x + x\right)}{\color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}}} \]
    5. Applied egg-rr2.1

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

    if -7.9000000000000002e-162 < c < 2.25000000000000005e-237

    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. Simplified20.2

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

      [Start]64.0

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

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

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

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

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

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

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

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

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

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

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

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

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

      [Start]64.0

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

      metadata-eval [<=]64.0

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

      rational.json-simplify-7 [<=]64.0

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

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

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

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

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

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

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

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

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

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

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

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

      \[ \frac{\cos \left(x + x\right)}{\color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}}} \]
    5. Applied egg-rr12.7

      \[\leadsto \color{blue}{\frac{1}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}} \cdot \cos \left(x + x\right)} \]
    6. Taylor expanded in c around 0 6.0

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

    if 2.25000000000000005e-237 < c

    1. Initial program 23.1

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

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

      [Start]23.1

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

      rational.json-simplify-46 [=>]23.6

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

      rational.json-simplify-46 [=>]22.1

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

      rational.json-simplify-47 [=>]21.6

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

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

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

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

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

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

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

      [Start]27.1

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

      metadata-eval [<=]27.1

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

      rational.json-simplify-7 [<=]27.1

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

      rational.json-simplify-30 [=>]27.1

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

      rational.json-simplify-7 [=>]27.1

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.9 \cdot 10^{-162}:\\ \;\;\;\;\frac{1}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}} \cdot \cos \left(x + x\right)\\ \mathbf{elif}\;c \leq 2.25 \cdot 10^{-237}:\\ \;\;\;\;\frac{1}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}} \cdot \cos \left(x + x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x + x\right)}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}}\\ \end{array} \]

Alternatives

Alternative 1
Error2.3
Cost20036
\[\begin{array}{l} t_0 := \cos \left(x + x\right)\\ \mathbf{if}\;{c}^{2} \leq 0:\\ \;\;\;\;\frac{t_0}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}}\\ \end{array} \]
Alternative 2
Error2.3
Cost13704
\[\begin{array}{l} t_0 := \cos \left(x + x\right)\\ t_1 := {\left(c \cdot \left(s \cdot x\right)\right)}^{2}\\ \mathbf{if}\;c \leq -6 \cdot 10^{-162}:\\ \;\;\;\;\frac{1}{t_1} \cdot t_0\\ \mathbf{elif}\;c \leq 6 \cdot 10^{-164}:\\ \;\;\;\;\frac{t_0}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{t_1}\\ \end{array} \]
Alternative 3
Error3.1
Cost13440
\[\frac{\cos \left(x + x\right)}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}} \]
Alternative 4
Error16.8
Cost6912
\[\frac{1}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}} \]

Error

Reproduce?

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