|
When executing
Sure. In this case you're really just doing a small number of operations on rationals. The essence of the xreal idea doesn't even come into play.
However when using rational_power->xreal to pass arguments that have more elaborate precision functions, it's obvious that most of the time is spent retrieving the necessary decimal expansion.There's a huge amount of variation possible here. It depends a lot on the operation that you're computing, and also on the method that you choose for computing it. When computing a function of one xreal argument, such as x^2, the precision required of the input is determined by the derivative of the function in an interval near the input. The more complicated the variation of the derivative, the more difficult it is to determine the right precsion for the input xreal.
Notice that many operations will offer a tradeoff between the cost of choosing the precision of the inputs vs. the exactness with which you get the desired output precision. You are always allowed to return greater output precision than required, but if the number of computer words in the numerators and denominators of the rational endpoints gets too big, you will pay for that in the rational operations. But the number of words to represent an integer is proportional to the logarithm of the integer, so in many cases it's best to take a quick and dirty approximation to the precision requirement. Only when the extra precision raises the numerators and denominators to large powers is it likely to dominate the cost of the operation. For functions of more than one Mike O'D. |
to: