(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 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) {
return x;
}
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
code = x
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) {
return x;
}
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): return x
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) return x 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 = code(x, y, z, t, a, b) tmp = x; 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_] := 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)
x
Results
| Original | 46.2 |
|---|---|
| Target | 44.6 |
| Herbie | 44.2 |
Initial program 46.2
Simplified46.0
[Start]46.2 | \[ \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)
\] |
|---|---|
rational_best-simplify-1 [=>]46.2 | \[ \color{blue}{\cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right) \cdot \left(x \cdot \cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right)\right)}
\] |
rational_best-simplify-50 [=>]46.2 | \[ \color{blue}{\cos \left(\frac{\left(\left(y \cdot 2 + 1\right) \cdot z\right) \cdot t}{16}\right) \cdot \left(x \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)}
\] |
rational_best-simplify-1 [=>]46.2 | \[ \cos \left(\frac{\color{blue}{t \cdot \left(\left(y \cdot 2 + 1\right) \cdot z\right)}}{16}\right) \cdot \left(x \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)
\] |
rational_best-simplify-1 [=>]46.2 | \[ \cos \left(\frac{t \cdot \color{blue}{\left(z \cdot \left(y \cdot 2 + 1\right)\right)}}{16}\right) \cdot \left(x \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)
\] |
rational_best-simplify-50 [=>]46.0 | \[ \cos \left(\frac{\color{blue}{\left(y \cdot 2 + 1\right) \cdot \left(z \cdot t\right)}}{16}\right) \cdot \left(x \cdot \cos \left(\frac{\left(\left(a \cdot 2 + 1\right) \cdot b\right) \cdot t}{16}\right)\right)
\] |
rational_best-simplify-1 [=>]46.0 | \[ \cos \left(\frac{\left(y \cdot 2 + 1\right) \cdot \left(z \cdot t\right)}{16}\right) \cdot \left(x \cdot \cos \left(\frac{\color{blue}{t \cdot \left(\left(a \cdot 2 + 1\right) \cdot b\right)}}{16}\right)\right)
\] |
rational_best-simplify-3 [=>]46.0 | \[ \cos \left(\frac{\left(y \cdot 2 + 1\right) \cdot \left(z \cdot t\right)}{16}\right) \cdot \left(x \cdot \cos \left(\frac{t \cdot \left(\color{blue}{\left(1 + a \cdot 2\right)} \cdot b\right)}{16}\right)\right)
\] |
rational_best-simplify-1 [=>]46.0 | \[ \cos \left(\frac{\left(y \cdot 2 + 1\right) \cdot \left(z \cdot t\right)}{16}\right) \cdot \left(x \cdot \cos \left(\frac{t \cdot \left(\left(1 + \color{blue}{2 \cdot a}\right) \cdot b\right)}{16}\right)\right)
\] |
Taylor expanded in t around 0 45.2
Taylor expanded in z around 0 44.2
Final simplification44.2
herbie shell --seed 2023099
(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))))