?

Average Error: 28.2 → 2.6
Time: 17.5s
Precision: binary64
Cost: 13440

?

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

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. Simplified3.0

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

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

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

    *-commutative [=>]31.5

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

    unpow2 [=>]31.5

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

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

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

    \[ \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 31.5

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

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

    [Start]31.5

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

    count-2 [<=]31.5

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

    associate-*r* [=>]31.5

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

    unpow2 [=>]31.5

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

    associate-/r* [=>]31.5

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

    unpow2 [=>]31.5

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

    unpow2 [=>]31.5

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

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

    unpow2 [<=]19.4

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

    *-lft-identity [<=]19.4

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

    associate-*l/ [<=]19.6

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

    unpow2 [=>]19.6

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

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

    times-frac [<=]15.5

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

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

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

    \[ \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} \]
  5. Final simplification2.6

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

Alternatives

Alternative 1
Error9.8
Cost7625
\[\begin{array}{l} \mathbf{if}\;x \leq -8.2 \lor \neg \left(x \leq 0.00062\right):\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot \left(c \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(s \cdot \left(x \cdot c\right)\right)}^{-2}\\ \end{array} \]
Alternative 2
Error6.6
Cost7625
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \mathbf{if}\;x \leq -2.15 \cdot 10^{-7} \lor \neg \left(x \leq 0.00045\right):\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot \left(s \cdot t_0\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;{t_0}^{-2}\\ \end{array} \]
Alternative 3
Error2.8
Cost7625
\[\begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \mathbf{if}\;x \leq -5 \cdot 10^{-114} \lor \neg \left(x \leq 1.5 \cdot 10^{-210}\right):\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{s \cdot \left(x \cdot c\right)}{\frac{\frac{\frac{1}{c}}{x}}{s}}}\\ \end{array} \]
Alternative 4
Error7.2
Cost7624
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ t_1 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq -2.3 \cdot 10^{-8}:\\ \;\;\;\;\frac{t_1}{x \cdot \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)\right)}\\ \mathbf{elif}\;x \leq 0.00045:\\ \;\;\;\;{t_0}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{x \cdot \left(c \cdot \left(s \cdot t_0\right)\right)}\\ \end{array} \]
Alternative 5
Error2.8
Cost7492
\[\begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ t_1 := x \cdot \left(s \cdot c\right)\\ \mathbf{if}\;x \leq 2 \cdot 10^{+160}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_1 \cdot t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t_0}}{t_0}\\ \end{array} \]
Alternative 6
Error3.0
Cost7360
\[\begin{array}{l} t_0 := x \cdot \left(s \cdot c\right)\\ \frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0} \end{array} \]
Alternative 7
Error2.7
Cost7360
\[\begin{array}{l} t_0 := x \cdot \left(s \cdot c\right)\\ \frac{\frac{\cos \left(x + x\right)}{t_0}}{t_0} \end{array} \]
Alternative 8
Error16.9
Cost6784
\[{\left(s \cdot \left(x \cdot c\right)\right)}^{-2} \]
Alternative 9
Error23.6
Cost1228
\[\begin{array}{l} t_0 := \frac{1}{c \cdot \left(x \cdot \left(c \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)\right)}\\ \mathbf{if}\;s \leq -3.2 \cdot 10^{+15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;s \leq 4 \cdot 10^{-123}:\\ \;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(c \cdot \left(c \cdot \left(x \cdot x\right)\right)\right)\right)}\\ \mathbf{elif}\;s \leq 2.05 \cdot 10^{+170}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot s\right) \cdot \left(s \cdot \left(x \cdot \left(c \cdot c\right)\right)\right)}\\ \end{array} \]
Alternative 10
Error20.5
Cost1161
\[\begin{array}{l} \mathbf{if}\;c \leq -3.1 \cdot 10^{+140} \lor \neg \left(c \leq -1.35 \cdot 10^{-128}\right):\\ \;\;\;\;\frac{\frac{\frac{-1}{x}}{c}}{\left(s \cdot c\right) \cdot \left(x \cdot \left(-s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot s\right) \cdot \left(s \cdot \left(x \cdot \left(c \cdot c\right)\right)\right)}\\ \end{array} \]
Alternative 11
Error25.0
Cost1097
\[\begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-158} \lor \neg \left(x \leq 1.32 \cdot 10^{-143}\right):\\ \;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(c \cdot \left(c \cdot \left(x \cdot x\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot \left(c \cdot c\right)\right)\right)}\\ \end{array} \]
Alternative 12
Error24.6
Cost1097
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-159} \lor \neg \left(x \leq 2.6 \cdot 10^{-143}\right):\\ \;\;\;\;\frac{1}{s \cdot \left(s \cdot \left(c \cdot \left(c \cdot \left(x \cdot x\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot s\right) \cdot \left(s \cdot \left(x \cdot \left(c \cdot c\right)\right)\right)}\\ \end{array} \]
Alternative 13
Error16.5
Cost1092
\[\begin{array}{l} t_0 := \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{if}\;s \leq 3.1 \cdot 10^{+19}:\\ \;\;\;\;\frac{1}{x \cdot \left(s \cdot c\right)} \cdot \frac{1}{s \cdot \left(x \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot t_0\\ \end{array} \]
Alternative 14
Error16.5
Cost1092
\[\begin{array}{l} t_0 := \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{if}\;s \leq 3 \cdot 10^{+20}:\\ \;\;\;\;\frac{\frac{1}{s}}{x \cdot c} \cdot \frac{1}{x \cdot \left(s \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot t_0\\ \end{array} \]
Alternative 15
Error16.5
Cost1092
\[\begin{array}{l} t_0 := \frac{\frac{1}{x \cdot s}}{c}\\ \mathbf{if}\;s \leq 20:\\ \;\;\;\;\frac{\frac{1}{s}}{x \cdot c} \cdot \frac{1}{x \cdot \left(s \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot t_0\\ \end{array} \]
Alternative 16
Error18.3
Cost960
\[\frac{1}{x \cdot \left(s \cdot c\right)} \cdot \frac{1}{s \cdot \left(x \cdot c\right)} \]
Alternative 17
Error17.1
Cost960
\[\frac{1}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \frac{s}{\frac{1}{x \cdot c}}} \]
Alternative 18
Error17.1
Cost960
\[\frac{1}{\frac{s \cdot \left(x \cdot c\right)}{\frac{\frac{\frac{1}{c}}{x}}{s}}} \]
Alternative 19
Error29.0
Cost832
\[\frac{1}{s \cdot \left(s \cdot \left(c \cdot \left(c \cdot \left(x \cdot x\right)\right)\right)\right)} \]
Alternative 20
Error17.0
Cost832
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \frac{1}{t_0 \cdot t_0} \end{array} \]

Error

Reproduce?

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