?

Average Error: 28.2 → 2.7
Time: 14.5s
Precision: binary64
Cost: 13440

?

\[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
\[{\left(x \cdot \left(c \cdot s\right)\right)}^{-2} \cdot \cos \left(x + x\right) \]
(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 (* (pow (* x (* c s)) -2.0) (cos (+ x x))))
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) {
	return pow((x * (c * s)), -2.0) * cos((x + x));
}
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
    code = ((x * (c * s)) ** (-2.0d0)) * cos((x + x))
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) {
	return Math.pow((x * (c * s)), -2.0) * Math.cos((x + x));
}
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):
	return math.pow((x * (c * s)), -2.0) * math.cos((x + x))
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)
	return Float64((Float64(x * Float64(c * s)) ^ -2.0) * cos(Float64(x + x)))
end
function tmp = code(x, c, s)
	tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x));
end
function tmp = code(x, c, s)
	tmp = ((x * (c * s)) ^ -2.0) * cos((x + x));
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_] := N[(N[Power[N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
{\left(x \cdot \left(c \cdot s\right)\right)}^{-2} \cdot \cos \left(x + x\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 28.2

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

    \[\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]28.2

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

    *-commutative [=>]28.2

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

    associate-*l* [=>]31.6

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

    associate-*r* [=>]31.4

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

    *-commutative [=>]31.4

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

    unpow2 [=>]31.4

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

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

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

    \[ \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-rr2.7

    \[\leadsto \color{blue}{{\left(x \cdot \left(c \cdot s\right)\right)}^{-2} \cdot \cos \left(x + x\right)} \]
  4. Final simplification2.7

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

Alternatives

Alternative 1
Error15.1
Cost7756
\[\begin{array}{l} t_0 := \frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)\right)}\\ t_1 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;s \leq -6.8 \cdot 10^{-124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;s \leq 7 \cdot 10^{-149}:\\ \;\;\;\;\frac{\frac{1}{t_1}}{t_1}\\ \mathbf{elif}\;s \leq 3.8 \cdot 10^{+123}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{x \cdot s}}{c} \cdot \frac{-1}{c \cdot \left(x \cdot s\right)}\\ \end{array} \]
Alternative 2
Error7.1
Cost7625
\[\begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;x \leq -2.35 \cdot 10^{-64} \lor \neg \left(x \leq 3 \cdot 10^{-14}\right):\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot \left(s \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{t_0}}{t_0}\\ \end{array} \]
Alternative 3
Error3.9
Cost7625
\[\begin{array}{l} \mathbf{if}\;x \leq -2.06 \cdot 10^{-162} \lor \neg \left(x \leq 6 \cdot 10^{-124}\right):\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(s \cdot \left(x \cdot c\right)\right)}^{-2}\\ \end{array} \]
Alternative 4
Error2.9
Cost7360
\[\begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0} \end{array} \]
Alternative 5
Error2.7
Cost7360
\[\begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \frac{\frac{\cos \left(x + x\right)}{t_0}}{t_0} \end{array} \]
Alternative 6
Error16.3
Cost6916
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \mathbf{if}\;c \leq -2.7 \cdot 10^{+214}:\\ \;\;\;\;{t_0}^{-2}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-18}:\\ \;\;\;\;\frac{\frac{-1}{x \cdot s}}{c} \cdot \frac{-1}{c \cdot \left(x \cdot s\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{t_0}}{x \cdot \left(c \cdot s\right)}\\ \end{array} \]
Alternative 7
Error18.3
Cost1097
\[\begin{array}{l} \mathbf{if}\;c \leq -1.08 \cdot 10^{+172} \lor \neg \left(c \leq -9 \cdot 10^{+35}\right):\\ \;\;\;\;\frac{1}{c \cdot \left(\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)}\\ \end{array} \]
Alternative 8
Error19.5
Cost964
\[\begin{array}{l} \mathbf{if}\;x \leq 1.35 \cdot 10^{-229}:\\ \;\;\;\;\frac{1}{x \cdot \left(s \cdot \left(c \cdot \left(x \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot s\right)\right)}\\ \end{array} \]
Alternative 9
Error17.2
Cost964
\[\begin{array}{l} \mathbf{if}\;s \leq 10^{+132}:\\ \;\;\;\;\frac{\frac{1}{s \cdot \left(x \cdot c\right)}}{x \cdot \left(c \cdot s\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot s\right)\right)}\\ \end{array} \]
Alternative 10
Error34.8
Cost832
\[\frac{-1}{s \cdot \left(s \cdot \left(x \cdot \left(x \cdot \left(c \cdot c\right)\right)\right)\right)} \]
Alternative 11
Error18.5
Cost832
\[\frac{1}{c \cdot \left(\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot s\right)\right)} \]
Alternative 12
Error16.8
Cost832
\[\begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \frac{\frac{1}{t_0}}{t_0} \end{array} \]

Error

Reproduce?

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