Gottfried Helms on Thu, 17 Nov 2022 19:31:22 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Conversion of a function/closure with rational coefficients into one with real coefficients

Am 17.11.2022 um 18:25 schrieb Bill Allombert:
> On Thu, Nov 17, 2022 at 01:42:58PM +0100, Gottfried Helms wrote:
>> I'm trying to optimize some bivariate function,
>> and found, that I can create a vector of polynomials p_r(x).
>> Let pp be a vector of closures, so for instance
>>  ...
>>  pp[4](x) =  1/4*x^2-2/3*x+1/6
>>  pp[5](x) = -1/8*x^3+31/48*x^2-7/12*x+1/24
>>  ...
> Why not write
> pp[4] =  1/4*x^2-2/3*x+1/6
> pp[5] = -1/8*x^3+31/48*x^2-7/12*x+1/24
> and use subst to evaluate pp[i] when needed ?
> Cheers,
> Bill
The problem that I have is runtime-behave.
pp[128] has order 126 polynomial with rational coefficients
with hundred or more digits in numerator and denominator.
Experiments with some manually generated real valued
coefficients show much better runtime behave.

I think it is better to have polynomials statically
defined in the most appropriate form, so that any
overload in typeconversion at runtime occurs only