# How to simplify one expression without Negative(-) mark

3 views (last 30 days)
CrossFire on 1 May 2024
Answered: Walter Roberson on 7 May 2024
How to simplify the belowing expression B without the - mark?
I thought the result should be :
but, the result always show the MINUS sign mark.
clc;clear;
syms Z_1 Z_2 Z_3 Z_4 I_1
% (a) V_1
V_1 = I_1 * (Z_1*Z_2/(Z_1+Z_2) + Z_3*Z_4/(Z_3+Z_4));
% (b) I_Z1
I_Z1 = Z_2/(Z_1+Z_2)*I_1;
% (c) I_Z3
I_Z3 = Z_4/(Z_3+Z_4)*I_1;
% (d) I_2
I_2 = I_Z1 - I_Z3;
% (e) B
B = V_1/I_2;
% (f) D
D = I_1/I_2;
simplify(B)
ans =
Torsten on 1 May 2024
Hint: Look at the denominator.
CrossFire on 7 May 2024
@Torsten Thanks so much!
I refered your idea using function numden, and got the denominator result that I wanted!
% to get the denominator from B
[n d]=numden(B)

Walter Roberson on 7 May 2024
MATLAB Symbolic Toolbox automatically re-arranges expressions into "canonical form" in order to make it simpler to share parts of expressions (which in turn makes it more efficient to process expressions, since the repeated parts only have to be processed once.)
The canonical form for polynomials involves sorting each term in alphabetical order, then sorting the terms in alphabetical order, modified by the rule that the first term must normally have a positive coefficient. You can only get a leading negative if all of the terms are negative
>> -Z1+Z_1 - Z10 - Z_10
ans =
Z_1 - Z10 - Z1 - Z_10
>> -Z1-Z_1 - Z10 - Z_10
ans =
- Z1 - Z10 - Z_1 - Z_10
However, when forming rationals, the rule is a bit different: if the leading term of the denominator (as determined by sorting in alphabetical order) would normally be negative, then the negative of the denominator is formed, and the negative of the numerator is taken.
Your denominator is Z_2*Z_3 - Z_1*Z_4 which would sort into -Z_1*Z_4 + Z_2*Z_3 . Because it is the demonator, the negative is taken forming Z_1*Z_4 - Z_2*Z_3 and the negative of the numerator is taken. All of the terms of the numerator are then negative so you get the leading negative together with all positive terms.
You cannot get it to show you the denominator as Z_Z*Z_3 - Z_1*Z_4 because that would violate the rule that for denominators the terms are always sorted alphabetically