79552438

Date: 2025-04-03 08:59:05
Score: 1
Natty:
Report link

Maybe you can elaborate a bit on the dot product you are trying to take?

Because taking the dot product along vector [1,1,1] is just the same as the sum:

>>> x = np.random.sample(3)

>>> np.isclose(np.dot(x, [1,1,1]), np.sum(x)) # it's the same up to numerical precision
True

Which would imply that you'd like to do something like:

sb.heatmap(np.cos(X+Y+2*np.pi));

That would result in an image like this: enter image description here

To prove the point, we can do something slow:

def cos_dot(x_grid, y_grid, z_fixed = 2 * np.pi):
    res = np.zeros_like(x_grid)
    # Loop over all x,y coordinates. 
    # Just to be explicit we only use the indices i and j.
    for i, _ in enumerate(x_grid):
        for j, _ in enumerate(y_grid[i[):
            res[i][j] = np.cos(
                np.dot(
                    [x_grid[i][j], y_grid[i][j], z_fixed],
                    [1,1,1]
                ))
    return res

# Let's check that this function gives the same answer as just X+Y+2*np.pi
np.isclose(cos_dot(X,Y), np.cos(X+Y+2*np.pi)).all() 

which returns True

Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: J. R.