Solving for a variable with many solutions

1 visualizzazione (ultimi 30 giorni)
Betsy Kirtland
Betsy Kirtland il 6 Feb 2016
Commentato: Star Strider il 11 Feb 2016
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

Risposte (1)

Kiran
Kiran il 11 Feb 2016
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 Commenti
Betsy Kirtland
Betsy Kirtland il 11 Feb 2016
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 il 11 Feb 2016
What version of MATLAB are you using?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by