Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Triangle inequality
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Triangle inequality for cosine similarity== {{further|Cosine similarity}} By applying the cosine function to the triangle inequality and reverse triangle inequality for arc lengths and employing the angle addition and subtraction formulas for cosines, it follows immediately that<ref>{{cite conference |last=Schubert |first=Erich |title=A Triangle Inequality for Cosine Similarity |conference=International Conference on Similarity Search and Applications |date=2021 |location=Dortmund |doi=10.1007/978-3-030-89657-7_3 |publisher=Springer |arxiv=2107.04071 }}</ref> <math display="block">\operatorname{sim}(u,w) \geq \operatorname{sim}(u,v) \cdot \operatorname{sim}(v,w) - \sqrt{\left(1-\operatorname{sim}(u,v)^2\right)\cdot\left(1-\operatorname{sim}(v,w)^2\right)}</math> and <math display="block">\operatorname{sim}(u,w) \leq \operatorname{sim}(u,v) \cdot \operatorname{sim}(v,w) + \sqrt{\left(1-\operatorname{sim}(u,v)^2\right)\cdot\left(1-\operatorname{sim}(v,w)^2\right)}\,.</math> With these formulas, one needs to compute a [[square root]] for each triple of vectors {{math|{''u'', ''v'', ''w''}<nowiki/>}} that is examined rather than {{math|arccos(sim(''u'',''v''))}} for each pair of vectors {{math|{''u'', ''v''}<nowiki/>}} examined, and could be a performance improvement when the number of triples examined is less than the number of pairs examined.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)