![difference between matlab a and matlab b difference between matlab a and matlab b](https://www.mathworks.com/help/matlab/matlab_prog/live_function_documentation_example.png)
However, if the variables are not declared symbolically, mldivide and linsolve would give you the same warning message "Matrix is singular to working precision." linsolve enables you to solve it symbolically, mldivide can not do that. This is handy when you have a small underdetermined system which has infinite number of solutions. Moreover, linsolve could also perform symbolic computation. For example, for a dense positive definite system satisfying certain properties, or you have an overdetermined system and both perform least square fitting. If certain criteria are met, linsolve and mldivide do utilize the same factorization process.
![difference between matlab a and matlab b difference between matlab a and matlab b](https://www.differencebetween.info/sites/default/files/images/2/matlab.jpg)
However, an incorrectly chosen opts leads to a wrong result. Would return $x$ if you know $A$ is positive definite in advance. For example: opts.POSDEF = true linsolve(A,b,opts) For large problems, you could save some time. In linsolve as the help doc suggests in mathworks website, you could avoid the extra testing process (Allan used the word "overhead" in his answer) by using opts if and only if you know what $A$ is like in advance. Mldivide and linsolve for rectangular matrices: QR factorization
![difference between matlab a and matlab b difference between matlab a and matlab b](https://media.cheggcdn.com/study/caa/caa77199-9ff2-4062-b759-7cc70e9800cd/image.png)
Linsolve for square matrices: LU factorization with partial pivoting If A is square but is neither permuted triangular, symmetric and positive definite, or Hessenberg, then MATLAB performs a general triangular factorization using LU factorization with partial pivoting If A is upper Hessenberg, MATLAB uses Gaussian elimination to reduce the system to a triangular matrix. If the Cholesky factorization fails, MATLAB performs a symmetric, indefinite factorization. Mldivide for square matrices: If A is symmetric and has real, positive diagonal elements, MATLAB attempts a Cholesky factorization. Also see MATLAB's help on mldivide algorithm here. Please see Allan's answer in this thread for more information. Mldivide does perform the tests for $A$ in solving $Ax = b$. Both of them are direct solver to solve linear systems (opposing to iterative solver).