Solving 4 equations with 3 unknowns

40 views (last 30 days)
Steewz
Steewz on 16 Jun 2020
Answered: Walter Roberson on 16 Jun 2020
Hey,
I'm trying to solve a system of 4 equations with 3 unknowns with the function solve, but i read somewhere that with solve we can only solve systems with n equations and n unknows, so i was wondering if there is another function to solve this kind of systems.
TY

Answers (1)

Walter Roberson
Walter Roberson on 16 Jun 2020
When you have more equations than there are unknowns, then you have one of the following cases:
  • there are an infinite number of solutions because rank() of the equations is less than the number of variables. In such a case, it is not completely clear what it means to "solve" the system, unless what you are looking for is a parameterized solution (ideas similar to null space for example). In such a case solve() might give you a definite solution, but if it does then it will be a "representative" solution rather than information about all solutions. Using 'returnconditions', true is more likely to give you information about the class of infinite solutions, but it can be a bit tricky to understand. When you expect indefinite number of solutions, then vpasolve() is often a better choice, especially if you use it to provide initial starting points for the search
  • There is exactly one solution because rank() of the equations is exactly the same as the number of variables, which implies that some of the equations are redundant. If so then get rid of the redundant equations first
  • There are no solutions: solving the first N equations in N variables gives a unique solution and that solution is not consistent with at least one of the remaining equations. This is the most common case. solve() is completely inappropriate for finding a least-squared solution: solve() is intended to find indefinitely precise closed-form solutions whenever practical.
  • Or your equations involve periodic or quasi-periodic functions, in which case exploring different (quasi-) periods might be able to lead to a solution. Sometimes solve() can find solutions in such cases, mostly for trig equations, seldom for Bessel equations. For this kind of system then vpasolve() is often a better choice, especially if you use it to provide initial starting points for the search
There are also numeric linear least squared functions, and there are numeric nonlinear least-squared functions.
Another approach for least-squared is to build a residue function: take left hand side minus right hand side of each equation, square those, and add those together, forming a sum-of-squared expression "residue" that measures how bad any particular proposed set of variables is compred to the ideal of exactly 0 residue if everything balanced exactly. Now provided that the expressions are all real-valued, then least-squared is equivalent to minimizing that residue.
In some cases it is productive to proceed analytically, using calculus to differentiate, solve for 0, substitute, work with the reduced equation, and so on. In other cases... push it through a numeric minimizer such as fmincon or fminsearch.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!