Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Topic: There are a way of instruct the matlab to use sin(pi) = 0 in
the symbolic computations?

Replies: 1   Last Post: Feb 28, 2013 7:36 AM

 Christopher Creutzig Posts: 226 Registered: 2/24/09
Re: There are a way of instruct the matlab to use sin(pi) = 0 in
the symbolic computations?

Posted: Feb 28, 2013 7:36 AM

On 28.01.13 17:48, Fernando wrote:

> I think that I can't do it. My equations system is:
>
> sin(2*q1)*i)/2 == 0
> -(sin(2*q1)*i)/2 == 0
>
> Then, pi is not in my equation, it must be "tested" as solution internally by Matlab, however, the matlab does not recognize pi as solution. I think that I need a way of instruct the matlab to internally use sin(pi) = 0 in the symbolic computations when solve the equations system.

Internally, it does find this solution along with all the other
infinitely many ones, as you can see, e.g., by using the MuPAD Notebook
Interface or by calling the MuPAD solve function via feval:

>> syms q1
>> pretty(feval(symengine, 'solve', sin(q1)==0))

+- -+ { +- -+ | }
| q1 | in { | pi k | | k in Z_ }
+- -+ { +- -+ | }
>> pretty(feval(symengine, 'solve', sin(q1)==0, q1))

{pi k | k in Z_}

Now, such an infinite solution set is not easy to use in MATLAB code.
For that reason, the MATLAB command SOLVE generally tries to extract a
(hopefully representative) finite subset of solutions for the input. If
you have special requirements on this set, it may be worth trying to
tell the system something about your variables:

>> assume(q1 > 0)
>> solve(sin(q1)==0)

ans =

2*pi

or even

>> assume(q1 > 0), assumeAlso(q1 < 4)
>> solve(sin(q1)==0)

ans =

pi

Note that the MATLAB function SOLVE does a few additional things on your
input, too, so there is no easy drop-in replacement that directly calls
the MuPAD command, even if your code can handle the output. But if you
think that getting the complete solution set is something the Symbolic
Math Toolbox should really offer, by all means let MathWorks' tech
support know.

HTH,
Christopher