Re: symbolic math toolbox error



In article <ef3ac40.-1@xxxxxxxxxxxxxxxxxxxxxxx>, jthu
<jrcole45@xxxxxxxxxxx> wrote:

Hello,

I run this code in matlab

solve('cos(x) + sin(2*x) + tan(x)');

eval(S)

??? Error using ==> atan
Incorrect number of inputs.

Does any one know the cause of this error and how to fix it
thanks
-----------------------------------
You can probably get a better insight into your problem if you do a
little algebraic manipulation with your expression first. You are seeking
the zeros of 'cos(x)+sin(2*x)+tan(x)', so write it as:

cos(x)+sin(2*x)+tan(x) = cos(x)+2*sin(x)*cos(x)+sin(x)/cos(x) =
(cos(x)^2*(1+2*sin(x))+sin(x))/cos(x) =
((1-sin(x)^2)*(1+2*sin(x))+sin(x))/cos(x) =
(1+3*sin(x)-sin(x)^2-2*sin(x)^3)/cos(x)

So, you are trying to find the roots of the cubic polynomial:

1+3*u-u^2-2*u^3=0

where u = sin(x). You can use the 'roots' function to determine that it
has three real roots but only one of them is in range for the sine
function, namely u = -0.32103681624075. That means the two arcsines of u,
x1 = 3.46841670383273 and x2 = 5.95636125693665 are solutions and these
repeat periodically for every interval of length 2*pi - that is to say,
there are infinitely many possible solutions.

(Remove "xyzzy" and ".invalid" to send me email.)
Roger Stafford
.



Relevant Pages

  • Re: symbolic math toolbox error
    ... jthu wrote: ... I run this code in matlab ... Error using ==> atan ... Incorrect number of inputs. ...
    (comp.soft-sys.matlab)
  • symbolic math toolbox error
    ... I run this code in matlab ... Error using ==> atan ... Incorrect number of inputs. ... Does any one know the cause of this error and how to fix it ...
    (comp.soft-sys.matlab)
  • Re: Solving polynomials faster with vectors?
    ... using vector calculations in MatLab (especially when using ... of a matrix or solving polynomial functions (roots) ... Thanks I will compare the roots method with eig, ...
    (comp.soft-sys.matlab)
  • Re: Roots of AX^2 + BX + C
    ... However, when I ran a small simulation using MATLAB, I found that the ... roots are positive only 25% of the time. ... I suspect that your random number generator was not producing numbers ... random members of a uniform distribution on. ...
    (sci.math)
  • Re: Solving polynomials faster with vectors?
    ... using vector calculations in MatLab (especially when using ... of a matrix or solving polynomial functions (roots) ... will have to be content with using 'roots' for your quintic equations. ...
    (comp.soft-sys.matlab)