Inconsistent solution from a symbolic equation?
Show older comments
Hi,
I'm solving a system of some rather lengthy equations using the solve function after setting up the equations using symbols. Solving one of the equations gives me two solutions, let's denote it like this:
aa=solve(eq3_2==0,N3);
Now if I look at the two solution in "aa", they look the same apart from an overall negative sign..however, since they are very long I wanted to make sure if one was just the negative of the other, so I wrote:
aa(1)+aa(2)
and was expecting to get 0, which I didn't get. To try to spot what made them different i used the pretty-function like:
pretty(solve(eq3_2==0,N3))
which gave me the following output:
[[(#58 + #28 + #55 + #54 + #53 - #52 + #11 - #10 + #9 - #8 + #7 + #6 + #5 + #4 - #3 - #2
+ #24 + #57 - #56 + #33 - #32 - #31 + #30 - #29 + #27 + #26 - #25 + #23 + #22 - #21
- #20 - #19 - #18 + #17 + #16 + #15 - #14 - #13 - #12 - #37 - #36 + #35 - #34 + #51
+ #50 - #49 - #48 - #47 - #46 - #45 + #44 + #43 + #42 + #41 - #40 - #39 - #38)/#1],
[-(#58 - #28 - #55 - #54 - #53 + #52 - #11 + #10 - #9 + #8 - #7 - #6 - #5 - #4 + #3 + #2
- #24 - #57 + #56 - #33 + #32 + #31 - #30 + #29 - #27 - #26 + #25 - #23 - #22 + #21
+ #20 + #19 + #18 - #17 - #16 - #15 + #14 + #13 + #12 + #37 + #36 - #35 + #34 - #51
- #50 + #49 + #48 + #47 + #46 + #45 - #44 - #43 - #42 - #41 + #40 + #39 + #38)/#1]]
and a list with the expression for each number. Just comparing what I got from this, they do seem to be the same apart from an overall negative sign. So my question is if I'm missing something or if this might be a bug caused by too lengthy symbolic expressions or something like that?
Thanks in advance
Robert
Accepted Answer
More Answers (3)
Steven Lord
on 17 Nov 2016
What does:
isAlways(aa(1) == -aa(2))
return? The isAlways function tells you "whether equation or inequality holds for all values of its variables".
Robert
on 18 Nov 2016
0 votes
1 Comment
Karan Gill
on 18 Nov 2016
The warning means that the input condition could not be proved or disproved for all possible values of the inputs.
Walter Roberson
on 18 Nov 2016
One approach you might take in future, which applies for sums and products:
aa1ch = children(aa(1));
aa2ch = children(-aa(2));
tf = ismember(aa1ch, aa2ch);
non_matching_aa1 = aa1ch(~tf);
then non_matching_aa1 are the terms in aa(1) that do not have a match in -aa(2)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!