Why do I get giant values when I plug in very small decimal values in symbolic algebra?
1 次查看(过去 30 天)
显示 更早的评论
syms v
eqn = ((40-20)/(25-20)) == ((0.0010057-0.0009996)/(v-0.0009996))
0 个评论
采纳的回答
DGM
2021-11-26
When doing symbolic operations, it's going to always try to give exact representations of numbers. Ratios of integers are exact, whereas floating point representations are not necessarily exact. You can convert to a more familiar numeric form if you want.
Consider:
syms v
eqn = ((40-20)/(25-20)) == ((0.0010057-0.0009996)/(v-0.0009996))
S = solve(eqn,v) % expressed as integer ratios
format long % just so we can see all the digits
double(S) % decimal representation
The result should satisfy the equation
((40-20)/(25-20)) % LHS
((0.0010057-0.0009996)/(S-0.0009996)) % RHS is exactly equal
Though note that the floating point representation isn't exactly the same.
((0.0010057-0.0009996)/(double(S)-0.0009996))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!