?

Average Error: 46.6 → 44.2
Time: 22.5s
Precision: binary64
Cost: 34756

?

\[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
\[\begin{array}{l} \mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{t \cdot \left(\left(1 + 2 \cdot a\right) \cdot b\right)}{16}\right) \leq 2 \cdot 10^{+181}:\\ \;\;\;\;x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(b \cdot \left(t \cdot 0.0625\right)\right)\right|\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (*
  (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0)))
  (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))
(FPCore (x y z t a b)
 :precision binary64
 (if (<=
      (*
       (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0)))
       (cos (/ (* t (* (+ 1.0 (* 2.0 a)) b)) 16.0)))
      2e+181)
   (*
    x
    (* (cos (* (* z t) (+ 0.0625 (/ y 8.0)))) (fabs (cos (* b (* t 0.0625))))))
   x))
double code(double x, double y, double z, double t, double a, double b) {
	return (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(((t * ((1.0 + (2.0 * a)) * b)) / 16.0))) <= 2e+181) {
		tmp = x * (cos(((z * t) * (0.0625 + (y / 8.0)))) * fabs(cos((b * (t * 0.0625)))));
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (x * cos((((((y * 2.0d0) + 1.0d0) * z) * t) / 16.0d0))) * cos((((((a * 2.0d0) + 1.0d0) * b) * t) / 16.0d0))
end function
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (((x * cos((((((y * 2.0d0) + 1.0d0) * z) * t) / 16.0d0))) * cos(((t * ((1.0d0 + (2.0d0 * a)) * b)) / 16.0d0))) <= 2d+181) then
        tmp = x * (cos(((z * t) * (0.0625d0 + (y / 8.0d0)))) * abs(cos((b * (t * 0.0625d0)))))
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return (x * Math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * Math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
}
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x * Math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * Math.cos(((t * ((1.0 + (2.0 * a)) * b)) / 16.0))) <= 2e+181) {
		tmp = x * (Math.cos(((z * t) * (0.0625 + (y / 8.0)))) * Math.abs(Math.cos((b * (t * 0.0625)))));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	return (x * math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * math.cos((((((a * 2.0) + 1.0) * b) * t) / 16.0))
def code(x, y, z, t, a, b):
	tmp = 0
	if ((x * math.cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * math.cos(((t * ((1.0 + (2.0 * a)) * b)) / 16.0))) <= 2e+181:
		tmp = x * (math.cos(((z * t) * (0.0625 + (y / 8.0)))) * math.fabs(math.cos((b * (t * 0.0625)))))
	else:
		tmp = x
	return tmp
function code(x, y, z, t, a, b)
	return Float64(Float64(x * cos(Float64(Float64(Float64(Float64(Float64(y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(Float64(Float64(Float64(Float64(Float64(a * 2.0) + 1.0) * b) * t) / 16.0)))
end
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(Float64(x * cos(Float64(Float64(Float64(Float64(Float64(y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(Float64(Float64(t * Float64(Float64(1.0 + Float64(2.0 * a)) * b)) / 16.0))) <= 2e+181)
		tmp = Float64(x * Float64(cos(Float64(Float64(z * t) * Float64(0.0625 + Float64(y / 8.0)))) * abs(cos(Float64(b * Float64(t * 0.0625))))));
	else
		tmp = x;
	end
	return tmp
end
function tmp = code(x, y, z, t, a, b)
	tmp = (x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos((((((a * 2.0) + 1.0) * b) * t) / 16.0));
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (((x * cos((((((y * 2.0) + 1.0) * z) * t) / 16.0))) * cos(((t * ((1.0 + (2.0 * a)) * b)) / 16.0))) <= 2e+181)
		tmp = x * (cos(((z * t) * (0.0625 + (y / 8.0)))) * abs(cos((b * (t * 0.0625)))));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * N[Cos[N[(N[(N[(N[(N[(y * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(N[(N[(N[(a * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(x * N[Cos[N[(N[(N[(N[(N[(y * 2.0), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(t * N[(N[(1.0 + N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] / 16.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2e+181], N[(x * N[(N[Cos[N[(N[(z * t), $MachinePrecision] * N[(0.0625 + N[(y / 8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Abs[N[Cos[N[(b * N[(t * 0.0625), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)
\begin{array}{l}
\mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{t \cdot \left(\left(1 + 2 \cdot a\right) \cdot b\right)}{16}\right) \leq 2 \cdot 10^{+181}:\\
\;\;\;\;x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(b \cdot \left(t \cdot 0.0625\right)\right)\right|\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original46.6
Target44.8
Herbie44.2
\[x \cdot \cos \left(\frac{b}{16} \cdot \frac{t}{\left(1 - a \cdot 2\right) + {\left(a \cdot 2\right)}^{2}}\right) \]

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y 2) 1) z) t) 16))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a 2) 1) b) t) 16))) < 1.9999999999999998e181

    1. Initial program 34.3

      \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
    2. Simplified34.4

      \[\leadsto \color{blue}{x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \cos \left(\left(t \cdot b\right) \cdot \left(\frac{a}{8} + 0.0625\right)\right)\right)} \]
      Proof

      [Start]34.3

      \[ \left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]

      associate-*l* [=>]34.3

      \[ \color{blue}{x \cdot \left(\cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)} \]
    3. Applied egg-rr34.4

      \[\leadsto x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \cos \color{blue}{\left(\frac{t \cdot b}{\frac{1}{\mathsf{fma}\left(a, 0.125, 0.0625\right)}}\right)}\right) \]
    4. Applied egg-rr34.8

      \[\leadsto x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \color{blue}{\sqrt{{\cos \left(t \cdot \left(b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)\right)\right)}^{2}}}\right) \]
    5. Simplified34.8

      \[\leadsto x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \color{blue}{\left|\cos \left(t \cdot \left(b \cdot \mathsf{fma}\left(0.125, a, 0.0625\right)\right)\right)\right|}\right) \]
      Proof

      [Start]34.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \sqrt{{\cos \left(t \cdot \left(b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)\right)\right)}^{2}}\right) \]

      unpow2 [=>]34.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \sqrt{\color{blue}{\cos \left(t \cdot \left(b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)\right)\right) \cdot \cos \left(t \cdot \left(b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)\right)\right)}}\right) \]

      rem-sqrt-square [=>]34.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \color{blue}{\left|\cos \left(t \cdot \left(b \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)\right)\right)\right|}\right) \]

      associate-*r* [=>]34.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \color{blue}{\left(\left(t \cdot b\right) \cdot \mathsf{fma}\left(a, 0.125, 0.0625\right)\right)}\right|\right) \]

      rem-square-sqrt [<=]40.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(\left(t \cdot b\right) \cdot \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, 0.125, 0.0625\right)} \cdot \sqrt{\mathsf{fma}\left(a, 0.125, 0.0625\right)}\right)}\right)\right|\right) \]

      associate-*l* [=>]40.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \color{blue}{\left(t \cdot \left(b \cdot \left(\sqrt{\mathsf{fma}\left(a, 0.125, 0.0625\right)} \cdot \sqrt{\mathsf{fma}\left(a, 0.125, 0.0625\right)}\right)\right)\right)}\right|\right) \]

      rem-square-sqrt [=>]34.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(t \cdot \left(b \cdot \color{blue}{\mathsf{fma}\left(a, 0.125, 0.0625\right)}\right)\right)\right|\right) \]

      fma-udef [=>]34.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(t \cdot \left(b \cdot \color{blue}{\left(a \cdot 0.125 + 0.0625\right)}\right)\right)\right|\right) \]

      *-commutative [<=]34.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(t \cdot \left(b \cdot \left(\color{blue}{0.125 \cdot a} + 0.0625\right)\right)\right)\right|\right) \]

      fma-def [=>]34.8

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(t \cdot \left(b \cdot \color{blue}{\mathsf{fma}\left(0.125, a, 0.0625\right)}\right)\right)\right|\right) \]
    6. Taylor expanded in a around 0 35.0

      \[\leadsto x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\color{blue}{\cos \left(0.0625 \cdot \left(t \cdot b\right)\right)}\right|\right) \]
    7. Simplified35.0

      \[\leadsto x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\color{blue}{\cos \left(\left(t \cdot 0.0625\right) \cdot b\right)}\right|\right) \]
      Proof

      [Start]35.0

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(0.0625 \cdot \left(t \cdot b\right)\right)\right|\right) \]

      associate-*r* [=>]35.0

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \color{blue}{\left(\left(0.0625 \cdot t\right) \cdot b\right)}\right|\right) \]

      *-commutative [<=]35.0

      \[ x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(\color{blue}{\left(t \cdot 0.0625\right)} \cdot b\right)\right|\right) \]

    if 1.9999999999999998e181 < (*.f64 (*.f64 x (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 y 2) 1) z) t) 16))) (cos.f64 (/.f64 (*.f64 (*.f64 (+.f64 (*.f64 a 2) 1) b) t) 16)))

    1. Initial program 60.4

      \[\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]
    2. Simplified59.3

      \[\leadsto \color{blue}{x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \cos \left(\left(t \cdot b\right) \cdot \left(\frac{a}{8} + 0.0625\right)\right)\right)} \]
      Proof

      [Start]60.4

      \[ \left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \]

      associate-*l* [=>]60.4

      \[ \color{blue}{x \cdot \left(\cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right) \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)} \]
    3. Taylor expanded in t around 0 57.6

      \[\leadsto x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \color{blue}{1}\right) \]
    4. Taylor expanded in z around 0 54.6

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{t \cdot \left(\left(1 + 2 \cdot a\right) \cdot b\right)}{16}\right) \leq 2 \cdot 10^{+181}:\\ \;\;\;\;x \cdot \left(\cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right) \cdot \left|\cos \left(b \cdot \left(t \cdot 0.0625\right)\right)\right|\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternatives

Alternative 1
Error44.3
Cost21572
\[\begin{array}{l} \mathbf{if}\;\left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right) \cdot \cos \left(\frac{t \cdot \left(\left(1 + 2 \cdot a\right) \cdot b\right)}{16}\right) \leq 2 \cdot 10^{+181}:\\ \;\;\;\;x \cdot \cos \left(\left(z \cdot t\right) \cdot \left(0.0625 + \frac{y}{8}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error44.7
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023039 
(FPCore (x y z t a b)
  :name "Codec.Picture.Jpg.FastDct:referenceDct from JuicyPixels-3.2.6.1"
  :precision binary64

  :herbie-target
  (* x (cos (* (/ b 16.0) (/ t (+ (- 1.0 (* a 2.0)) (pow (* a 2.0) 2.0))))))

  (* (* x (cos (/ (* (* (+ (* y 2.0) 1.0) z) t) 16.0))) (cos (/ (* (* (+ (* a 2.0) 1.0) b) t) 16.0))))