Precision arithmetic

I calculate Lyapunov Exponent. I need a big precision, such as 10000. I create a simple example for verifing calculating: >> vpa(pi, 10) ans = 3.141592654 >> vpa(pi*10, 10) ans = 31.41592654
But, I need a 10 symbols after dot. But not 9 and 8 as in example. How can I achive a calculating with specified symbols after dot?

 采纳的回答

Walter Roberson
Walter Roberson 2011-3-23

0 个投票

Increase the vpa digits much beyond what you need and do the calculations. floor() the result, abs() it, add 1, and take ceil() of the log10 of that. The result of ceil() will be the number of digits that were used before the decimal point. With that number in hand, you can vpa() the result of the calculation, this time specifying 10 + the number of digits before the decimal point as your precision. The result will be a symbolic number.
OR....
Do the calculation with more digits than you need. char() the result of the vpa. locate the '.' in the string and discard everything after the 10th character after the decimal place. The result will be a character string.

2 个评论

Thank you, for your answer. Is there another alternative for function vpa?
No, not for your purpose. All MuPad internal arithmetic is defined in terms of significant digits, not in terms of number of decimal places.

请先登录,再进行评论。

更多回答(0 个)

产品

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by