Solving for a variable with many solutions

조회 수: 1 (최근 30일)
Betsy Kirtland
Betsy Kirtland 2016년 2월 6일
댓글: Star Strider 2016년 2월 11일
I have a equation which I know must equal zero.
(( 2*L^2*k*cos(k*L)*sin(k*L)-2*L*sin(k*L)^2 = 0))
I know that this expression will be true when k = n*pi/L, where n=1,2,3,... However, using the solve function in Matlab returns a "cannot find explicit solution" error. Is there a way I can solve for k and get an answer similar to k = pi/L?
Here is my code:
syms k L
eqn = 2*L^2*k*cos(k*L)*sin(k*L)-2*L*sin(k*L)^2 ==0
>> solve(eqn,k)
Warning: Cannot find explicit solution.
> In solve (line 318)
ans =
Empty sym: 0-by-1
To prove that there is an explicit solution, see:
>> f = @(k) 2*L^2*k*cos(k*L)*sin(k*L)-2*L*sin(k*L)^2
f =
@(k)2*L^2*k*cos(k*L)*sin(k*L)-2*L*sin(k*L)^2
>> f(pi/L)
ans =
0

답변 (1개)

Kiran
Kiran 2016년 2월 11일
MATLAB is trying to find the "Explicit" solution, meaning particular variable should be expressed in terms of other variables. If a variable cannot be isolated and thus appears on both sides of the equation then solution is implicit.
In your case to get the explicit solution you need to simplify the equation a bit.
After simplification your equation become:
sin(x) ( xcos(x) - sin(x))==0
where x = kL
This will give two separate solutions to your original equation. If you give
eqn = sin(x) == 0;
[solx, params, conds] = solve(eqn, x, 'ReturnConditions', true)
This will give you result as pi*k which will be, after substitution, the generic solution pi*x/L
However I simplified second equation to x = tan(x) still it has implicit solution.
Hope this help.
  댓글 수: 2
Betsy Kirtland
Betsy Kirtland 2016년 2월 11일
Two things:
1. I'm not sure how you simplified to that first equation, considering that there is an instance of both L^2*k and L*sin(k*L) in my original equation.
2. When I typed in your code, I received an error message.
>> syms x
>> eqn = sin(x) ==0;
>> [solx, params, conds] = solve(eqn, x, 'Return Conditions', true)
Error using sym>convertExpression (line 1409)
Conversion to 'sym' returned the MuPAD error:
symbolic:kernel:UnexpectedToken|identifier#
Error in sym>convertChar (line 1324)
s = convertExpression(x);
Error in sym>tomupad (line 1124)
S = convertChar(x);
Error in sym (line 151)
S.s = tomupad(x);
Error in solve>getEqns (line 410)
a = formula(sym(a));
Error in solve (line 227)
[eqns,vars,options] = getEqns(varargin{:});
What am I doing wrong?
Star Strider
Star Strider 2016년 2월 11일
What version of MATLAB are you using?

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

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by