There are several problems with that code. First of all, you probably don't want to use std::vector to represent vectors. Despite the tempting name, std::vector is actually a dynamic array. Vectors are things you can add, subtract and scale. You can't do any of these things with std::vector.
A bigger problem with your code is that you are returning a double from Gradient, but the gradient is a vector, not a real number.
It's also hard to know if your Gradient function does the right thing if I don't know what function it's supposed to be the gradient of.
This is the kind of thing I would write:
#include <iostream>
#include <cmath>
struct Vector3D {
double x, y, z;
Vector3D(double x, double y, double z) : x(x), y(y), z(z) {
}
};
std::ostream &operator<<(std::ostream &os, Vector3D v) {
return os << '(' << v.x << ',' << v.y << ',' << v.z << ')';
}
double f(Vector3D v) {
return std::sin(v.x) + std::cos(v.y);
}
Vector3D Gradient(Vector3D v) {
return Vector3D(std::cos(v.x), -std::sin(v.y), 0.0);
}
int main() {
Vector3D v(1.0, 1.0, 1.0);
std::cout << Gradient(v) << std::endl;
}