An actual non-answer from solve
2 views (last 30 days)
Show older comments
The following code results in a an empty sym. Would anyone care to comment on (a) why no solution? and (b) how to actually get a solution from the symbolic math toolbox?
reset(symengine);clear all;
syms x lambda A k positive;
syms eta;
lambda = sym(1);
k = sym(2*pi);
eq1 = A*sin(eta)-10;
eq2 = A*sin(k*lambda/6 + eta)-20;
eq3 = A*sin(k*5*lambda/12 + eta);
% try to solve
b=solve(eq1,eq2,eq3,A,eta,k)
% --> answer is [ empty sym ]
subs(eq1,{A,eta,k},{20,pi/6,2*pi/lambda})
subs(eq2,{A,eta,k},{20,pi/6,2*pi/lambda})
subs(eq3,{A,eta,k},{20,pi/6,2*pi/lambda})
0 Comments
Accepted Answer
Sean de Wolski
on 2 Jun 2011
You force k to equal 2*pi; how do you expect it to solve for any other value?
0 Comments
More Answers (2)
Walter Roberson
on 2 Jun 2011
solve() is failing because you are attempting to solve for k, but k has a value already so eq1 eq2 and eq3 do not contain k anymore. Even if they did somehow still contain k, because k has a value, it would be the value that would be passed in to solve() where you list k at the end; you would need to quote k to get just the name passed in
solve(eq1,eq2,eq3,A,eta,'k')
but like I said this would fail because there is no k in eq* because eq* were constructed after k was defined.
0 Comments
Susan
on 2 Jun 2011
1 Comment
Walter Roberson
on 2 Jun 2011
Works for me in Maple:
solve([eq1, eq2, eq3], [A, eta, k],UseAssumptions);
[[A = 20, eta = (1/6)*Pi, k = 2*Pi/lambda],
[A = 20, eta = (5/6)*Pi, k = 10*Pi/lambda],
[A = 20, eta = (5/6)*Pi, k = -2*Pi/lambda],
[A = 20, eta = (1/6)*Pi, k = -10*Pi/lambda],
[A = (80/7)*14^(1/2), eta = arctan((1/22)*14^(1/2)*2^(1/2)), k = 12*arctan((1/2)*14^(1/2)*2^(1/2))/lambda],
[A = (80/7)*14^(1/2), eta = -arctan((1/22)*14^(1/2)*2^(1/2))+Pi, k = 12*(-arctan((1/2)*14^(1/2)*2^(1/2))+Pi)/lambda],
[A = (80/7)*14^(1/2), eta = -arctan((1/22)*14^(1/2)*2^(1/2))+Pi, k = -12*arctan((1/2)*14^(1/2)*2^(1/2))/lambda],
[A = (80/7)*14^(1/2), eta = arctan((1/22)*14^(1/2)*2^(1/2)), k = 12*(arctan((1/2)*14^(1/2)*2^(1/2))-Pi)/lambda]]
You have to eliminate the ones with negative k from this, as Maple does not seem to fully process the assumptions on k with the assumptions on lambda,
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!