Bill Allombert on Sun, 26 Mar 2023 17:13:17 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: from t_POL to t_CLOSURE (and back)
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: from t_POL to t_CLOSURE (and back)
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Sun, 26 Mar 2023 17:12:03 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1679843517; c=relaxed/relaxed; bh=XsjGHsHwCXU8a+p+bQn2FPJkTH1brk7VTke4G6RiKU4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=tVzVIbAXOb2U01unS0MlcdNGnVOG1DjzKaDgTcpjkDG/PvHlyCLgKvz+AIX3AkdcXS+lS31mcUMk747YPHhW+WtITsQvW12u4tCzgSvEE8cBGZJaQmDvHOO3hpe3sTUZ27EsBQe5eLegCuYQyyrADUIYnPUUYtk22L/BmIGHmrw31dI7OCatNDF9gSnBiPdwSizuwrVifHfb8gGpJhPrUarai/T8Ya7xJ3UUoTwMprQGMs07lZ4KOyVcNg7gTd69kQzEaHCNl8/+nBc0AuuWpp+4RAmDv1E4f43kfwcR+H/E0rca7EJgoY5QIajuDQdrvzVVinkeEbgaobCH4ivMULI06sqJiSlfXDTvST2H9erTc3Aa9WSbC/ZJ2w/chV5muTiuB4B7CkhEm2/ONJ8ia3H/mrtwk8Ru+48smXyWGZUEym47VoFjLyymV0N1y7cA8h05QV1SCFxOChlTQa1XtzG7JdRfWqGmrEWqgslRd8AQQboSE+L3fI2oGCLAjF1QtB4ORgcF0esYVV1AFVdVWDVX44SSKWVhZmALYhfDGRRq52GkXBNvTHyl+622j/n6jUK/Pc6tDfp1KC1ZDxT6EX8VAaU4O740RJ2c+HNd+lqLvFaz4FMYx2iexhu5jLOBSxcanQxUJaZdXdgMGWj913KNqDXIfpVFvWl53/ZJy6U=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1679843517; cv=none; b=szbfwUI6BBzu3oNBMemUtDg3e9gm7t96+YEnz5bF18PWB9hf/k+YAMSCYxO1YxX7SnTVBxnZe8KNLgGXpWjw7X5s9Xy9Ilhkzi27UG52xIbzh/iI9rubypkbx8Hnzq2PqfhNe/ON8BMY1P7xOhSqmlXVQzAtlAhA7ejkoJuUoG8938Pb+8xSVK89Y7be6HE7cfyDJfpUHcoPJtEWlAG7gyV8LVggADUmaguIIQiqqp+6YZ4zosjnX8tludvN8GsE2BNo6GWtE0QazBeXWutHtq5wqoXcXjmF0CZSZcxsJgXgDaFGop6He8rGK4Hp1ZSURuFs0I8xDzrUqhLuL6LrNGj+K/66rb2xWxEl5oztUzV1oz8jcN1LC5FEggzBkqNHBuX5aLohiA+ywODEJIXXxVEt4uXA0ka7Y9O1ql9paMZANRNBK+emF97bNCPk3ijS7BYBkwZHjaGqFx1XgGwoKLduv3ZqcA+XS/Eiaga7JMrTzZ2k3//e/2zSyo4SDHMgfl/e+s7xTmci/7muRFVZfzPzkqqyCsPUwb2JYewC2KMcCZkCkrJzH/Lb5bUfJI1wfiJiXXjBkf7jxkASxLPZQ57TijD9S9UvXMD+Gpdj5Va+o7P5u7pTxmzUuPcKANU76o2GYAke9ibofVUUhRSuxQPsk+jgCPj+ATJ0cvOSpvs=
- Authentication-results: smail; arc=none
- Delivery-date: Sun, 26 Mar 2023 17:13:17 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1679843517; bh=XsjGHsHwCXU8a+p+bQn2FPJkTH1brk7VTke4G6RiKU4=; h=Date:From:To:Subject:References:In-Reply-To:From; b=WCwOIs3PsBW0RaC/uZnm3UDnyYs6lfmZrRdGryxq6QIQjt9crq8FT7676hQ+1irRI br7ltFXrEL+KE2LycMwvl+47bYsJ7RN3oA+T1mKKdh7wxwWkp0URzpMH7/pP6ddwsm tn3EmAecvzBWwsZlvP9v1s+JDz8BLY0X8Zf2NaA8nD1m4kIJF8GWo1WiWadxyuwmoM w+ie1qh8YIGe6bh5XSH8tt9BnFN3NSCAPkF+HlMIWdnyL1VJkLXiVUU8BqqWkwbxhF 0e2kj5q3cR35jNMS6BqiZBRqxtBvmHNGrmEQf81OJrnLChJeyjCMwi9v1lktM5LQtA 6WS7KED736n9giC7AvRKii+9DHHNEgiqoCM1X3W+IueDQrG+P3brf8084ma49DNWr7 KdwzO5W4lZgUUMOYzpCfurop5jajeTaCpfcTM4cJK2Gkt4BeR9dJYfJIlgo5Hf1jzu CIc1iTI3S+Pwck+IkMijfl/P+hs+LAGEYdG7/614m/CWKDWo3K0fNSIo9G1s6eIt55 /cbex494v7Sl5K1osHUWzkmZT+GtiFpn8YsiBznoUjZ17+1gWBUh+Blb3IAPbJrXMv QGKsXd4tkrmBhq0HFP9e1D3jRGkgxMguSr+erxabUmBZWr4u07NNFVltq1XkCwyhdp 3Cv3WkaanBP5dhilbbCJqNgQ=
- In-reply-to: <CAJkPp5Ot=7NFVuma2B=+t16hgBBc870TPTwfv9Ld_tZcuuVWnA@mail.gmail.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <CAJkPp5POGV5=LmFOTWr0f+-vgDANnsE6A6ot06YouUqxf7njYg@mail.gmail.com> <ZB91bujSOLFfbvS7@seventeen> <CAJkPp5P=+yb45NFt3oEunWBRn7PwrprxUQsaEvTF+zXMNcHdLg@mail.gmail.com> <CAJkPp5Ot=7NFVuma2B=+t16hgBBc870TPTwfv9Ld_tZcuuVWnA@mail.gmail.com>
On Sun, Mar 26, 2023 at 10:51:35AM -0400, Max Alekseyev wrote:
> Perhaps, I should clarify my question. The definition
> f = z -> subst(p,variable(p),z)
> looks inefficient (and ugly) to me. I'd like to have a direct way to get
> the corresponding t_CLOSURE from a given polynomial, like I'd do for a
> fixed polynomial:
> f(x) = x^3 + x + 1
>
> My best attempt so far is
>
> ? p = x^3 + x + 1
> %1 = x^3 + x + 1
> ? eval(strprintf("f(%s) = %s", variable(p), p))
> %2 = (x)->x^3+x+1
> ? type(f)
> %3 = "t_CLOSURE"
How is it more efficient ? It is much slower since it computes all the powers
separately.
p=(x^1000-1)/(x-1);
eval(strprintf("f(%s) = %s", variable(p), p));
a=ffgen([17,100]);
subst(p,x,a);
*** last result computed in 2 ms.
f(a);
*** last result computed in 34 ms.
subst(p,x,3^1000);
*** last result computed in 210 ms.
f(3^1000);
*** last result computed in 1,565 ms.
subst(p,x,matid(100));
*** last result computed in 464 ms.
f(matid(100));
*** last result computed in 1min, 978 ms.
For the ugliness, define this
poltoclosure(p)=my(v=variable(p));z->subst(p,v,z)
and then you can do
f = poltoclosure(p)
Cheers,
Bill.