Average Error: 27.8 → 2.5
Time: 12.2s
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)} \]
\[{\left(c \cdot \left(x \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 (* c (* x 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((c * (x * 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 = ((c * (x * 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((c * (x * 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((c * (x * 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(c * Float64(x * 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 = ((c * (x * 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[(c * N[(x * 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(c \cdot \left(x \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 27.8

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

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(c \cdot \left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)\right)}} \]
    Proof
    (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 c (*.f64 c (*.f64 x (*.f64 x (*.f64 s s)))))): 0 points increase in error, 0 points decrease in error
    (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 c (*.f64 c (*.f64 x (*.f64 x (Rewrite<= unpow2_binary64 (pow.f64 s 2))))))): 0 points increase in error, 0 points decrease in error
    (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 c (*.f64 c (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 x (pow.f64 s 2)) x))))): 0 points increase in error, 0 points decrease in error
    (/.f64 (cos.f64 (*.f64 2 x)) (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 c c) (*.f64 (*.f64 x (pow.f64 s 2)) x)))): 36 points increase in error, 3 points decrease in error
    (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 c 2)) (*.f64 (*.f64 x (pow.f64 s 2)) x))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr13.4

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

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

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

Alternatives

Alternative 1
Error11.0
Cost8548
\[\begin{array}{l} t_0 := s \cdot \left(x \cdot s\right)\\ t_1 := c \cdot \left(x \cdot s\right)\\ t_2 := \frac{1}{t_1}\\ t_3 := \cos \left(x \cdot 2\right)\\ t_4 := \frac{t_3}{t_0 \cdot \left(c \cdot \left(c \cdot x\right)\right)}\\ t_5 := \frac{t_3}{x \cdot \left(x \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)\right)}\\ t_6 := \frac{1}{x \cdot \left(c \cdot s\right)}\\ \mathbf{if}\;c \leq -5 \cdot 10^{+226}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq -2.15 \cdot 10^{+153}:\\ \;\;\;\;t_2 \cdot \frac{1}{\frac{c}{\frac{1}{x \cdot s}}}\\ \mathbf{elif}\;c \leq -1.22 \cdot 10^{+36}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq -4.1 \cdot 10^{-134}:\\ \;\;\;\;\frac{t_3}{c \cdot \left(c \cdot \left(x \cdot t_0\right)\right)}\\ \mathbf{elif}\;c \leq -8.6 \cdot 10^{-203}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{-178}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-128}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 4.2 \cdot 10^{-116}:\\ \;\;\;\;t_6 \cdot t_6\\ \mathbf{elif}\;c \leq 4.9 \cdot 10^{-61}:\\ \;\;\;\;t_5\\ \mathbf{else}:\\ \;\;\;\;\frac{t_2}{t_1}\\ \end{array} \]
Alternative 2
Error8.8
Cost7756
\[\begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ t_1 := \frac{t_0}{c \cdot \left(c \cdot \left(x \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\ \mathbf{if}\;x \leq -6.2 \cdot 10^{+21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-18}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+109}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(x \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error10.1
Cost7624
\[\begin{array}{l} t_0 := \frac{\cos \left(x \cdot 2\right)}{c \cdot \left(c \cdot \left(x \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)\right)}\\ \mathbf{if}\;x \leq -6.2 \cdot 10^{+21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-40}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error2.5
Cost7360
\[\begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{\frac{\cos \left(x + x\right)}{t_0}}{t_0} \end{array} \]
Alternative 5
Error18.9
Cost1096
\[\begin{array}{l} t_0 := \frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \mathbf{if}\;x \leq -1.9 \cdot 10^{-263}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-237}:\\ \;\;\;\;\frac{1}{\left(s \cdot s\right) \cdot \left(\left(c \cdot x\right) \cdot \left(c \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error17.8
Cost1096
\[\begin{array}{l} t_0 := \frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \mathbf{if}\;x \leq 7.5 \cdot 10^{-155}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+22}:\\ \;\;\;\;\frac{1}{\left(c \cdot s\right) \cdot \left(\left(c \cdot s\right) \cdot \left(x \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error17.5
Cost964
\[\begin{array}{l} \mathbf{if}\;s \leq 9 \cdot 10^{-95}:\\ \;\;\;\;\frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}\\ \end{array} \]
Alternative 8
Error16.6
Cost960
\[\begin{array}{l} t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\ t_0 \cdot t_0 \end{array} \]
Alternative 9
Error16.6
Cost960
\[\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s} \]
Alternative 10
Error22.5
Cost832
\[\frac{1}{\left(c \cdot s\right) \cdot \left(c \cdot \left(x \cdot \left(x \cdot s\right)\right)\right)} \]
Alternative 11
Error19.3
Cost832
\[\frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)} \]
Alternative 12
Error16.6
Cost832
\[\begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{\frac{1}{t_0}}{t_0} \end{array} \]

Error

Reproduce

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