Inconsistent solution from a symbolic equation?
이전 댓글 표시
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
채택된 답변
추가 답변 (3개)
Steven Lord
2016년 11월 17일
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
2016년 11월 18일
0 개 추천
댓글 수: 1
Karan Gill
2016년 11월 18일
The warning means that the input condition could not be proved or disproved for all possible values of the inputs.
Walter Roberson
2016년 11월 18일
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)
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!