Help solve 2 equations with 4 unknowns

For my class, we have to solve 2 systems with these equations:
(a*c)/(b*d) = 22.27 +/- 0.01
a+b = c+d
the numbers must be integers and greater than 15.
How would i go about solving this?
I have already tried for a bit and reached a dead end.
I used
syms a b c d;
solve([(a*c)/(b*d) == 22.27, a+b == c+d], [a,b,c,d])
Warning: 6 equations in 4 variables.
> In C:\Program Files\MATLAB\R2014a\toolbox\symbolic\symbolic\symengine.p>symengine at 56
In mupadengine.mupadengine>mupadengine.evalin at 97
In mupadengine.mupadengine>mupadengine.feval at 150
In solve at 170
Warning: Explicit solution could not be found.
> In solve at 179
and get the above error
Any help would be very appreciated.

답변 (1개)

Roger Stafford
Roger Stafford 2014년 9월 15일

2 개 추천

I don't think the approach you describe or anything like it would succeed, David. The 'solve' function is not smart enough for that job. If I were doing your problem I would reduce the number of unknowns by taking the second equation into consideration. Call s = a+b = c+d and replace b and d by the corresponding s, a, and c. Then to avoid round-off problems that can cause you to miss a solution I would rewrite your first equation as
100*a*c-2228*(s-a)*(s-c) = 0 (or 100*a*c-2226*(s-a)*(s-c) = 0)
Finally, I would devise three nested for-loops which go through all possible combinations of integers a, b, and s whose magnitudes do not exceed some large number like N = 100 or whatever you think it would take to find a solution. Set up a test to detect when the above expression is equal to zero and produce a printout of the integers.

댓글 수: 1

Roger Stafford
Roger Stafford 2014년 9월 15일
편집: Roger Stafford 2014년 9월 15일
I tried out my idea above and realized, especially with the 22.26 case, that you would need to use a smarter method to avoid an excessive amount of computation. I would suggest just two nested for-loops looking like this:
N = some pretty big number
for s = 32:N
for a = 16:s-16
Then instead of searching for c in another inside for-loop, just solve for c in the above equation and determine if the result is an integer greater than 15 with d also greater than 15. That would be much, much more efficient. I got lots of solutions that way.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

질문:

2014년 9월 14일

편집:

2014년 9월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by