From: Prof T. R. <Pro...@pr...> - 2024-03-01 22:15:13
|
Hi all, a working solution exists. However, I did not see that "lisp tolerance" made any difference. What is working for my test program is the following adjustment to Arthur's code: change his first two lines to the following three lines share tolerance; symbolic procedure zeroSmall v; if floatp v and v <= cdr(car(car(cdr tolerance))) then 0.0 then it looks like one can change tolerance at will through the execution. The attached script is the test I used. It also shows how I gradually stripped "tolerance" of its data structures to just get down to the bare number to be used in the test. Hopefully this stripping is robust enough. Tony On 2/3/2024 1:09 am, Francis Wright wrote: > Point 1: I'm not sure, but I think negative values will always be represented as (minus positive-number) provided you are looking at a fully simplified prefix form. > > Point 2: Yes, you need to use share to transfer values between algebraic and symbolic mode. But the value of tolerance also needs to be an explicit number acceptable to the underlying Lisp, which might not be the case if you compute its value in algebraic mode. My guess is that's why your modified version of kill fails. I suggest you try looking at > > lisp tolerance; > > immediately after you compute it. > > Francis > > --------------------------------------------------------------- > > From: Prof Tony Roberts via Reduce-algebra-developers [<red...@li...>](mailto:red...@li...) > Sent: 28 February 2024 8:12 PM > To: red...@li... [<red...@li...>](mailto:red...@li...) > Subject: Re: [Reduce-algebra-developers] how to zero small coefficients in combined numeric-algebra > > Hi, > > thanks for this procedure, works so far. Two questions follow: > > On 24/2/2024 8:01 pm, Arthur Norman wrote: >> symbolic procedure kill v; >> if floatp v and v <= 1.0e-6 then 0.0 >> else if atom v then v >> else kill car v . kill cdr v; > > 1. Why do I not need "abs(v)<=" I can see in the trace that so > far negative values appears to be always stored as (minus > positive-number) so abs(v) is apparently not needed, but is that > really always the case? > > 2. In the interim I have found that my current problem really needs > the threshold to vary depending upon the overall norm of stuff that > I am dealing with, so I want to code something like > > symbolic procedure kill v; > if floatp v and v <= tolerance then 0.0 > else if atom v then v > else kill car v . kill cdr v; > ... > on rounded; > for i:=1:99 do begin > ... > tolerance:=1e-8*normStuff; > kill(v); > ... > end; > > But then kill(v) fails. I have tried declaring "share tolerance;" > but that also fails. > > Tony > > -- > --------------------------------------------------------------------- > Four books and a toolbox: > > * (2020) Linear Algebra for the 21st Century > Oxford University Press. isbn: 978-0-19-885640-5, 978-0-19-885639-9 > https://global.oup.com/academic/product/linear-algebra-for-the-21st-century-9780198856399 > > * (2015) Model emergent dynamics in complex systems > SIAM, Philadelphia. isbn: 9781611973556. > https://epubs.siam.org/doi/10.1137/1.9781611973563 > > * (2009) Elementary calculus of financial mathematics > SIAM, Philadelphia. isbn: 978-0-898716-67-2. > https://epubs.siam.org/doi/10.1137/1.9780898718225 > > * (1994) A one-dimensional introduction to continuum mechanics > World Sci. isbn: 978-981-02-1913-0. > > * (2020) with John Maclean, and J. E. Bunder; Equation-Free > function toolbox for Matlab/Octave. > http://github.com/uoa1184615/EquationFreeGit > > Emeritus Professor A.J. Roberts, FAustMS > School of Mathematical Sciences, University of Adelaide > https://profajroberts.github.io/ > mailto:Pro...@pr... > http://orcid.org/0000-0001-8930-1552 > > _______________________________________________ > Reduce-algebra-developers mailing list > Red...@li... > https://lists.sourceforge.net/lists/listinfo/reduce-algebra-developers -- --------------------------------------------------------------------- Four books and a toolbox: * (2020) Linear Algebra for the 21st Century Oxford University Press. isbn: 978-0-19-885640-5, 978-0-19-885639-9 https://global.oup.com/academic/product/linear-algebra-for-the-21st-century-9780198856399 * (2015) Model emergent dynamics in complex systems SIAM, Philadelphia. isbn: 9781611973556. https://epubs.siam.org/doi/10.1137/1.9781611973563 * (2009) Elementary calculus of financial mathematics SIAM, Philadelphia. isbn: 978-0-898716-67-2. https://epubs.siam.org/doi/10.1137/1.9780898718225 * (1994) A one-dimensional introduction to continuum mechanics World Sci. isbn: 978-981-02-1913-0. * (2020) with John Maclean, and J. E. Bunder; Equation-Free function toolbox for Matlab/Octave. http://github.com/uoa1184615/EquationFreeGit Emeritus Professor A.J. Roberts, FAustMS School of Mathematical Sciences, University of Adelaide https://profajroberts.github.io/ mailto:Pro...@pr... http://orcid.org/0000-0001-8930-1552 |