# Least squares example?

**URL:** https://discourse.julialang.org/t/least-squares-example/4845
**Category:** General Usage
**Tags:** linearalgebra
**Created:** [July 14, 2017, 12:49am UTC](https://discourse.julialang.org/t/least-squares-example/4845 "2017-07-14T00:49:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hpoit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpoit/32/245_2.png) [@hpoit](https://discourse.julialang.org/u/hpoit)
#### Post date: [July 14, 2017, 12:49am UTC](https://discourse.julialang.org/t/least-squares-example/4845/1 "2017-07-14T00:49:48Z")

</div>

How does this work?

```julia
julia> r = [1, 2]
2-element Array{Int64,1}:
 1
 2

julia> [1 2; 3 4]
2×2 Array{Int64,2}:
 1 2
 3 4

julia> r \ [1 2; 3 4]
1×2 Array{Float64,2}:
 1.4 2.0

```

If A is a rectangular m-by-n matrix with m ~= n, and B is a matrix with m rows, then A\B returns a least-squares solution to the system of equations A\*x= B, or

If A is a scalar, then A\B is equivalent to A.\B?

I couldn’t figure out if what was stated in `?\` meant the same thing, I don’t think it did. Thanks!

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [July 14, 2017, 5:59am UTC](https://discourse.julialang.org/t/least-squares-example/4845/2 "2017-07-14T05:59:07Z")

</div>

`?\` has all the answers.
