Discussion:
There are a way of instruct the matlab to use sin(pi) = 0 in the symbolic computations?
(too old to reply)
Fernando
2013-01-28 14:55:08 UTC
Permalink
Hi,

I have the equations system eqs = [(sin(2*q1)*i)/2; -(sin(2*q1)*i)/2] and when I do solve(eqs == 0) I get zero as unique solution, I know that, due to limited precision, is correct the matlab does not to make sin(pi) = 0. But, would be very usefull to me if I could make some symbolic computations using sin(pi) = 0, and equally cos(pi/2) = 0. There are a way of instruct the matlab to use both sin(pi) and cos(pi/2) equal to zero in the symbolic computations?


This would greatly simplify my life! :)

Best regards!
Steven_Lord
2013-01-28 16:04:03 UTC
Permalink
Post by Fernando
Hi,
I have the equations system eqs = [(sin(2*q1)*i)/2; -(sin(2*q1)*i)/2]
and when I do solve(eqs == 0) I get zero as unique solution, I know that,
due to limited precision, is correct the matlab does not to make sin(pi) =
0. But, would be very usefull to me if I could make some symbolic
computations using sin(pi) = 0, and equally cos(pi/2) = 0. There are a way
of instruct the matlab to use both sin(pi) and cos(pi/2) equal to zero in
the symbolic computations?
Make it symbolic.

spi = sym(pi);
sin(spi)
cos(spi/2)
--
Steve Lord
***@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
Fernando
2013-01-28 16:48:08 UTC
Permalink
Post by Steven_Lord
Make it symbolic.
spi = sym(pi);
sin(spi)
cos(spi/2)
--
Steve Lord
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
Hi Steve, thanks by your attention.

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.


Best ragards!
Christopher Creutzig
2013-02-28 12:36:52 UTC
Permalink
Post by Fernando
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
Post by Fernando
syms q1
pretty(feval(symengine, 'solve', sin(q1)==0))
+- -+ { +- -+ | }
| q1 | in { | pi k | | k in Z_ }
+- -+ { +- -+ | }
Post by Fernando
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
Post by Fernando
assume(q1 > 0)
solve(sin(q1)==0)
ans =

2*pi

or even
Post by Fernando
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
Fernando
2013-03-01 11:52:07 UTC
Permalink
Christopher,


Great answer! Thank you very much by your precious help! :)


Best regards!
Post by Christopher Creutzig
Post by Fernando
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
Post by Fernando
syms q1
pretty(feval(symengine, 'solve', sin(q1)==0))
+- -+ { +- -+ | }
| q1 | in { | pi k | | k in Z_ }
+- -+ { +- -+ | }
Post by Fernando
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
Post by Fernando
assume(q1 > 0)
solve(sin(q1)==0)
ans =
2*pi
or even
Post by Fernando
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
Fernando
2013-06-29 21:40:10 UTC
Permalink
I'm with problem about this again! :(

See, http://www.mathworks.com/matlabcentral/newsreader/view_thread/330310!

I already try some ways using mupad, but nothing, not work!

Loading...