Show that $d(x,x) = 0$ for $x\in\mathbb{R}$ and $d(x,y) = \cos(x-y) + 3$ for $x,y\in\mathbb{R}$ is a metric.

I have a problem with showing that $d(x,y) \le d(x,z) + d(y,z)$.

I showed that $$d(x,z) + d(y,z) = \cos x\cos z+\sin x\sin z + \cos y\cos z + \sin y\sin z + 6$$ What should I do next?

  • 1
    $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Feb 25, 2023 at 17:59
  • $\begingroup$ @BrunoB yes it does by definition $\endgroup$ Feb 25, 2023 at 18:07
  • $\begingroup$ @SineoftheTime Oh I see, it's a piecewise definition, gotcha. $\endgroup$
    – Bruno B
    Feb 25, 2023 at 18:09
  • 5
    $\begingroup$ The formula of $d$ isn't correct. Take $x\neq y$ instead of $x, y\in\Bbb{R}$ $\endgroup$ Feb 25, 2023 at 18:12

3 Answers 3


There's a bit of a red herring in this question. All you need from the metric is that, for two different points $x$ and $y$, the distance between them satisfies $2 \leq d(x,y) \leq 4$. You don't need anything about $cos$ other than the fact that it's between $-1$ and $1$.

Given this property, you should be able to find an upper bound to $d(x,y)$, the left side of the triangle inequality, and a lower bound for $d(x,z) + d(y,z)$, the right hand side. With these two bounds you'll be able to show that the triangle inequality holds for all different $x$, $y$, and $z$.

  • $\begingroup$ thanks, I get it now $\endgroup$ Mar 1, 2023 at 18:57

You have: $d(x,y) \le d(x,z)+d(y,z) \iff \cos x\cos y+\cos y\cos z+\cos z\cos x+\sin x\sin y+\sin y\sin z+\sin z\sin x \le 3\iff \cos(x-y)-\cos(y-z)-\cos(z-x) \le 3$. This is clearly true since $-1\le\sin t\le 1$ for all real $t$.


Notice that $-1 ≤ \cos(x-y)≤1$ and hence $2≤d(x,y)≤4$ for every $x,y\in \mathbb R$.

Thus we have $$ d(x,y)≤4=2+2≤d(x,z)+d(z,y). $$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .