large value explanation mixing sym vars with double
2 views (last 30 days)
Show older comments
Hello and thanks ahead for taking the time to answer my question. Please consider the following
a = wc*((s^2+200)/(10*s)) wc is assigned the value 1.2279 and 's' is a sym var.
when I execute the above code can someone explain to me why I get these rather large coefficients? Like where did these numbers even come from?
a =
(552840675468697*(s^2 + 200))/(4503599627370496*s)
I guess it has something to do with mixing doubles with sym vars, using VPA gives me what I'm looking for:
ans =
0.12275528937093427295224046247313*s + 24.551057874186854590448092494626/s
again can someone explain to me why this is? Thanks again.
0 Comments
Answers (1)
Steven Lord
on 23 Oct 2015
When you perform computations like * using a double precision value and a symbolic variable, MATLAB converts the double precision value into a symbolic value. By default it does so by converting the double precision value into a rational or "nice" form. If it can't do that, it instead converts the double precision value exactly into N*2^e (in this case, 1/4503599627370496 is 2^(-52).) See the description of the 'r' and 'f' flags in the documentation for the SYM function for additional information.
0 Comments
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!