Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Replies: 3   Last Post: Jun 29, 2013 5:40 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Christopher Creutzig

Posts: 271
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
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.