|
From: Stavros M. <mac...@gm...> - 2024-02-29 19:53:23
|
I wonder if anyone is using NaN payloads to add, say, high-precision numbers or numerical differentiation or intervals arithmetic? Similar to using it for symbolic calculation but should be simpler.... On Thu, Feb 29, 2024 at 2:48 PM Richard Fateman <fa...@gm...> wrote: > Typically, yes the Newton iteration would be terminated either > when the result is deemed close enough/ but not always. > > A really fast sqrt program might start with pretty good initial > guess and an in-line expansion of 2 iterations. > > See https://en.algorithmica.org/hpc/arithmetic/rsqrt/ for a fun > exposition of > how to compute sqrt(1/x) using 1 Newton step. Maybe 2. > > There is the well-known potential to understand (or debug or optimize) > programs by > "symbolic execution". This has something of that flavor. > > The novelty presented by using NaNs is that you could > try to run and better understand a large, opaque, proprietary numerical > program by > inserting some NaN(s) in the input and look at the output. > > I am unaware of anyone doing this for real, or > even an implemented framework by which one could try to do this. > RJF > > > > > On Thu, Feb 29, 2024 at 11:30 AM Stavros Macrakis <mac...@gm...> > wrote: > >> Won't the Newton iteration typically be wrapped in a *while* clause? How >> will the termination condition be evaluated? >> >> On Thu, Feb 29, 2024 at 12:32 AM Richard Fateman <fa...@gm...> >> wrote: >> >>> In the context of taking a numerical program and reusing it >>> with partial symbolic input, here's another example.. >>> >>> Here is one step of a newton iteration: x[n+1] = x[n] - >>> f(x[n])/df(x[n])... >>> >>> newtstep(f,x,val):= block([d:diff(f,x)], val- subst(val, x,f/d)); >>> >>> how does this work? val is a guess... here, a guess the root of x^2-9... >>> >>> newtstep(x^2-9,x, 5.0); --> returns 3.4 >>> newtstep(x^2-9,x, 3.4); --> returns 3.023529411764706 >>> newtstep(x^2-9,x, 3.023529411764706); --> returns 3.00009155413138 >>> you get the idea. >>> >>> Now try putting an expression in there for the guess.. [ could use a NaN >>> perhaps] >>> newtstep(x^2-9,x,3-eps)$ /* could put 5-eps or anything else... >>> newtstep(x^2-9,x,%)$ >>> newtstep(x^2-9,x,%)$ --> >>> >>> -((eps^8-24*eps^7+504*eps^6-6048*eps^5+45360*eps^4-217728*eps^3+653184*eps^2-1119744*eps+839808)/(8*eps^7-168*eps^6+2016*eps^5-15120*eps^4+72576*eps^3-217728*eps^2+373248*eps-279936)) >>> >>> whew! try to understand this by using Taylor expansion.. >>> >>> taylor(%,eps,0, 9) --> 3+eps^8/279936+eps^9/209952 >>> >>> The newtstep program could instead be some large mysterious >>> iterative numerical program in a language that normally does not >>> allow symbols. But we might fool it by using NaNs as substitutes for >>> symbolic >>> expressions. >>> If you had this all hooked up via trap handling >>> you might get some insight as to how a program works.. >>> >>> RJF >>> >>> >>> _______________________________________________ >>> Maxima-discuss mailing list >>> Max...@li... >>> https://lists.sourceforge.net/lists/listinfo/maxima-discuss >>> >> |