# Dot product

**URL:** <https://discourse.julialang.org/t/dot-product/128704>\
**Category:** General Usage\
**Tags:** linearalgebra\
**Created:** [May 5, 2025, 6:40am UTC](https://discourse.julialang.org/t/dot-product/128704 "2025-05-05T06:40:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [May 5, 2025, 11:06am UTC](https://discourse.julialang.org/t/dot-product/128704/4 "2025-05-05T11:06:47Z")

</div>

I find this definition in wiki

```julia
Algebraically, the dot product is the sum of the products of the corresponding entries of the two sequences of numbers.

```

Translating into julia, it is

```julia
function dot_product(x, y) return sum(x .* y) end

```

But due to the fact that we haven’t restricted the type of args, this function may have some other (pleasantly) unexpected usage. Therefore, I would prefer a more appropriate name for it, see [this](https://discourse.julialang.org/t/inner-product-grammar-is-neater-than-sum-index-in-jump-modeling-but-triggers-warning/124528/28).

My larger point is: **there is no foolproof method**. And we should not hope for this.  
As an example, if sparsity exists, we may sometimes need to write our own code, see [this](https://discourse.julialang.org/t/i-added-1-million-constraints-to-an-lp-unwittingly/127668/9).

In general, the `adjoint` (`'`) or `transpose` are versatile, not restricted to only offering a scalar output (which in math sense, inner product). I think these are already enough.

If there is anyone who knows more about the underlying performance issue, just correct me 🙂

---

_[View the full topic](https://discourse.julialang.org/t/dot-product/128704)._
