# Why does vpasolve work where solve doesn't for the following:

조회 수: 3 (최근 30일)
David 2013년 10월 21일
답변: David 2013년 10월 21일
When I pass the following equations into solve like so
eqn1 = (120*Lt*pi*Rt)/(14400*Lt^2*pi^2 + Rt^2)^(1/2) - 338920901889975/17592186044416
eqn2 = (42000*Lt*pi*Rt)/(1764000000*Lt^2*pi^2 + Rt^2)^(1/2) - 8473022547249375/17592186044416
S = solve([eqn1,eqn2],[Rt, Lt])
I get the following error:
Warning: 4 equations in 2 variables.
> In C:\Program Files (x86)\MATLAB\R2013a Student\toolbox\symbolic\symbolic\symengine.p>symengine at 56
In solve at 170
In Main at 152
Warning: Explicit solution could not be found.
> In solve at 179
In Main at 152
However, if I plug these same two equations into vpasolve like so
S = vpasolve([eqn1, eqn2], [Rt, Lt], [1e3, 1e-6]);
I get
double(S.Rt) = 482.866983 and
double(S.Lt) = 0.051144.
What am I doing wrong inside the solve function??? Thanks for any help.

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

### 채택된 답변

David 2013년 10월 21일
Hey everyone,
It turns out, not surprisingly, that I needed to make eqn1 and eqn2 symbolic objects, which I did by wrapping sym() around each one. Now everything works fine. Yippee!
eqn1 = sym((120*Lt*pi*Rt)/(14400*Lt^2*pi^2 + Rt^2)^(1/2) - 338920901889975/17592186044416)
eqn2 = sym((42000*Lt*pi*Rt)/(1764000000*Lt^2*pi^2 + Rt^2)^(1/2) - 8473022547249375/17592186044416)
S = solve([eqn1, eqn2])

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

### 추가 답변 (1개)

Walter Roberson 2013년 10월 21일
There are two solutions:
Lt = (135/7881299347898368)*sqrt(87986205389370659588312581)/pi,
Rt = (405/17592186044416)*sqrt(439931026946853297941562905)
and the negatives of those.
I suggest switching to symbolic numbers when you construct the equation:
eqn1 = sqrt(sym(120)*Lt*sym('pi')*Rt)/(sym(14400)*Lt^2*sym('pi')^2 + Rt^2) - sym('338920901889975')/sym('17592186044416')
eqn2 = sqrt(sym(42000)*Lt*sym('pi')*Rt)/(sym('1764000000')*Lt^2*sym('pi')^2 + Rt^2) - sym('8473022547249375')/sym('17592186044416')
I used sym(120) and other small numbers, but sym('17592186044416') and other large numbers, to avoid the possibility of losing precision in converting the double precision representation of the larger numbers to symbolic form.
##### 댓글 수: 2없음 표시없음 숨기기
David 2013년 10월 21일
편집: David 2013년 10월 21일
Thanks for your quick reply and suggestions. However, I would like to ask, how is that you got these solutions using the solve function where I couldn't? Were there any differences between how you and I called the solve function? Thanks again.
David
David 2013년 10월 21일
Nevermind Walter, I figured out my problem. It turns out, not surprisingly, that I needed to make eqn1 and eqn2 symbolic objects, which I did by wrapping sym() around each one. Now everything works fine. Yippee!
eqn1 = sym((120*Lt*pi*Rt)/(14400*Lt^2*pi^2 + Rt^2)^(1/2) - 338920901889975/17592186044416)
eqn2 = sym((42000*Lt*pi*Rt)/(1764000000*Lt^2*pi^2 + Rt^2)^(1/2) - 8473022547249375/17592186044416)
S = solve([eqn1, eqn2])

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

### 카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by