# Assumptions are not being considered in symbolic math.

8 views (last 30 days)
Nick Knowles on 4 Mar 2024
Answered: Paul on 5 Mar 2024
I am trying to solve a system of equations using symbolic math. It's a mass balance around a system. It gives zero values for some outputs, but that is not what I am looking for. I have added "assume(m3>0)" for example, however m3 still comes out as zero.
John D'Errico on 4 Mar 2024
The assumptions were "considered". But then MATLAB realized the assumption was inconsistent with the problem, and ignored it, since it had to ignore something.
You have a full rank, linear system of equations. There will be EXACTLY one solution, ALWAYS. If the solution has one of the variables equal to zero, so be it. Assume as much as you wish. Stamp your feet too, bang your fist on the table, if you think it will help. It won't. ;-)

Torsten on 4 Mar 2024
Edited: Torsten on 4 Mar 2024
What is rank(A) ? If it's 8, your system of equations has a unique solution, and you can't assume anything about it.
Nick Knowles on 4 Mar 2024
rank(A) is 8
Torsten on 4 Mar 2024
Then the m1,...,m8 you get are the only possible values that satisfy A*[m1;m2;m3;m4;m5;m6;m7;m8] = B.

Paul on 5 Mar 2024
Hi Nick
The issue is that the code is using linsolve, which doesn't know anything about the assumptions on the m_i.
Generate an example of A and B
A = sym([1 2;3 4]);
B = A*[2;0]
B =
Define m1 and m2 as the independent variables
syms m1 m2
assume(m2 > 0)
Use linsolve. It returns the expected solution.
linsolve(A,B)
ans =
The original problem used equationsToMatrix to form A and B. The assumptions on m_i have nothing to do with A and B.
solve respects the assumption, which is why it doesn't return a solution (solve does have a name/value input that can be used to ignore assumptions)
sol = solve(A*[m1;m2] == B,[m1 m2])
sol = struct with fields:
m1: [0×1 sym] m2: [0×1 sym]
Verify by removing the assumption
assume(assumptions,'clear')
sol = solve(A*[m1;m2] == B,[m1 m2])
sol = struct with fields:
m1: 2 m2: 0

### Categories

Find more on Special Values in Help Center and File Exchange

R2023a

### Community Treasure Hunt

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

Start Hunting!