Opened 5 years ago
Closed 5 years ago
#19957 closed enhancement (fixed)
Asymptotic ring: list plot comparing values
Reported by:  cheuberg  Owned by:  

Priority:  major  Milestone:  sage7.1 
Component:  asymptotic expansions  Keywords:  
Cc:  dkrenn, behackl  Merged in:  
Authors:  Benjamin Hackl, Clemens Heuberger  Reviewers:  Clemens Heuberger, Daniel Krenn 
Report Upstream:  N/A  Work issues:  
Branch:  5d6e9b2 (Commits)  Commit:  5d6e9b2528fdafb7f9cf513e4d7f954fe1f06eba 
Dependencies:  #19931, #19946  Stopgaps: 
Description
Implement a new helper method for plausibility check of asymptotic expansions.
Change History (19)
comment:1 Changed 5 years ago by
 Branch set to u/cheuberg/asy/commparewithvalues
comment:2 Changed 5 years ago by
 Commit set to 9be60a072f561272cd8e79961acda0dbbd269971
 Dependencies set to #19931
comment:3 Changed 5 years ago by
 Commit changed from 9be60a072f561272cd8e79961acda0dbbd269971 to fd6b4ec75f7917d326c3c1e4ab5b1f2b715a6c95
Branch pushed to git repo; I updated commit sha1. New commits:
fd6b4ec  Trac #19957: additional doctests

comment:4 Changed 5 years ago by
 Status changed from new to needs_review
comment:5 followup: ↓ 7 Changed 5 years ago by
Hi! I really like the idea of this ticket; graphic comparison is quite useful. Quick remarks:
 should there be a keyword
scaled=True
with which the division by the error term can be controlled?  would it make sense to be able to compare against expansions without error term?
 what do you think of a
PLOTS::
section for the documentation?
comment:6 Changed 5 years ago by
 Status changed from needs_review to needs_info
comment:7 in reply to: ↑ 5 Changed 5 years ago by
Replying to behackl:
Hi! I really like the idea of this ticket; graphic comparison is quite useful. Quick remarks:
 should there be a keyword
scaled=True
with which the division by the error term can be controlled?
what would scaled=True
and scaled=False
do?
 would it make sense to be able to compare against expansions without error term?
if there is no error term, then there is no need to rescale nor plot,
all( ... for ...)
should do the trick in that case.
 what do you think of a
PLOTS::
section for the documentation?
Within a finite amount of time, I could not get it to work. In any case, this is distinct from doctesting; thus one would have to repeat all commands to generate the plot. Sage preparsing apparently does not work here. Then I got a strange error message.
For doctests, I rather think that we might want to output the list itself instead of the list plot, perhaps already piped through RIF
or something like that. That would make useful doctests (and could be used throughout the modules during review phases). Thus there could be a flag return_list=True
or something like that (or a separate method computing the list which could be used in this method here ...).
comment:8 followup: ↓ 9 Changed 5 years ago by
 Branch changed from u/cheuberg/asy/commparewithvalues to u/behackl/asy/comparewithvalues
 Commit changed from fd6b4ec75f7917d326c3c1e4ab5b1f2b715a6c95 to 5b20379b8dafbf0467eb040d55bc0d857f2a1ea3
 Status changed from needs_info to needs_review
Replying to cheuberg:
 should there be a keyword
scaled=True
with which the division by the error term can be controlled?what would
scaled=True
andscaled=False
do?
Plot the relative and the absolute error, respectively. Sometimes I like to look at both.
 what do you think of a
PLOTS::
section for the documentation?Within a finite amount of time, I could not get it to work. In any case, this is distinct from doctesting; thus one would have to repeat all commands to generate the plot. Sage preparsing apparently does not work here. Then I got a strange error message.
I couldn't get it to work either: some strange error regarding coercion of a function to SR
occurrs...
For doctests, I rather think that we might want to output the list itself instead of the list plot, perhaps already piped through
RIF
or something like that. That would make useful doctests (and could be used throughout the modules during review phases). Thus there could be a flagreturn_list=True
or something like that (or a separate method computing the list which could be used in this method here ...).
I've implemented parts of this: there are now two methods; one for computing the list of differences and one for actually plotting. Also, for the sake of convenience, I've added the option to input a symbolic expression containing at most one variable.
Regarding the output: while I'd really like to have RIFs in the output of the difference method, unfortunately this causes problems for list_plot
, e.g. try
sage: list_plot([(k, RIF(sqrt(k))) for k in srange(10)])
If the difference should lie in a RIF, the list would have to be processed again before plotting.
Opinions?
New commits:
83125aa  let compare_with_values return a list of tuples

85bf9a0  add rescaledparameter

d110580  allow symbolic arguments for values

b09ae92  improve doctests with shorter workaround

5b20379  add plot_comparison method

comment:9 in reply to: ↑ 8 Changed 5 years ago by
Replying to behackl:
Regarding the output: while I'd really like to have RIFs in the output of the difference method, unfortunately this causes problems for
list_plot
, e.g. trysage: list_plot([(k, RIF(sqrt(k))) for k in srange(10)])If the difference should lie in a RIF, the list would have to be processed again before plotting.
comment:10 followup: ↓ 12 Changed 5 years ago by
 Reviewers set to Clemens Heuberger
 Status changed from needs_review to needs_work
compare_with_value
should have a parameterring=RIF
and results should be converted into ring Examples section should still contain an example with a function
see also
block fromcompare_with_value
toplot_comparison
 why
*kwargs
in the call oflist_plot
instead of**kwargs
?  Example with nontrivial arguments, i.e. setting a color.
plot_comparison
will then need conversion from RIF to RR; this could also check whether there is still precision left (relative error of 1% seems to be tolerable for a plot) and raise an error otherwise.plot_comparison
should also accept aring
; it should be documented and treated to be aRealIntervalField
.
comment:11 Changed 5 years ago by
 Branch changed from u/behackl/asy/comparewithvalues to u/cheuberg/asy/comparewithvalues
comment:12 in reply to: ↑ 10 Changed 5 years ago by
 Branch changed from u/cheuberg/asy/comparewithvalues to u/behackl/asy/comparewithvalues
 Commit changed from 5b20379b8dafbf0467eb040d55bc0d857f2a1ea3 to 51668a9d5c0b8af1c11f9d5b1703e326e7b4d317
 Status changed from needs_work to needs_review
Thanks for looking over my adaptions!
Replying to cheuberg:
compare_with_value
should have a parameterring=RIF
and results should be converted into ring
Done.
 Examples section should still contain an example with a function
Done.
see also
block fromcompare_with_value
toplot_comparison
Done.
 why
*kwargs
in the call oflist_plot
instead of**kwargs
?
Typo. Fixed.
 Example with nontrivial arguments, i.e. setting a color.
I've added a more sophisticated doctest.
plot_comparison
will then need conversion from RIF to RR; this could also check whether there is still precision left (relative error of 1% seems to be tolerable for a plot) and raise an error otherwise.
Done. The check currently is for a relative diameter of less than 0.025
, which seems like a somewhat practical choice (the example with the harmonic numbers then works up to n \approx 500
).
plot_comparison
should also accept aring
; it should be documented and treated to be aRealIntervalField
.
Done.
Back to needs_review
.
New commits:
2041027  Trac #19957: reviewer commit

0990eed  add ringparameter for compare_with_value

6d1de23  adapt doctests

7a6c9bb  add doctest with function

7023a0e  add seealsoblock

f0f349d  add doctest with plotoptions

154299f  let plot_comparison deal with RIFs

79bbc61  improve code in loop

51668a9  add doctest for numerical noise check

comment:13 Changed 5 years ago by
 Branch changed from u/behackl/asy/comparewithvalues to u/dkrenn/asy/comparewithvalues
comment:14 followup: ↓ 16 Changed 5 years ago by
 Commit changed from 51668a9d5c0b8af1c11f9d5b1703e326e7b4d317 to 0632fd3d610aa1c53ecd9b562c67502cb4ac4986
 Reviewers changed from Clemens Heuberger to Clemens Heuberger, Daniel Krenn
I've added a couple of small commits during review. Please check.
Two comments:
 I find the naming of a variable
e
confusing...maybe usingexpansion
would be better?
 In the plot the hardcoded
0.025
should be adjustable by a parameter.
New commits:
311141f  Trac 19957 review: minor code rewrite

7337e61  Trac 19957 review: restructure part of the code and remove inner list to make it better readable

0632fd3  Trac 19957 review: minor changes in doc

comment:15 Changed 5 years ago by
 Branch changed from u/dkrenn/asy/comparewithvalues to u/cheuberg/asy/comparewithvalues
comment:16 in reply to: ↑ 14 ; followup: ↓ 18 Changed 5 years ago by
 Commit changed from 0632fd3d610aa1c53ecd9b562c67502cb4ac4986 to 5d6e9b2528fdafb7f9cf513e4d7f954fe1f06eba
I reviewed your changes and added a couple of commits. Please crossreview.
Replying to dkrenn:
Two comments:
 I find the naming of a variable
e
confusing...maybe usingexpansion
would be better?
Done.
 In the plot the hardcoded
0.025
should be adjustable by a parameter.
Done.
Last 10 new commits:
7918417  Trac #19946: additional doctest

1471336  Trac #19946: rewrite and improve explaination of 1b62954

9f9a23f  Trac #19961: document rpow

101e4de  Merge branch 'u/dkrenn/t/19961' of trac.sagemath.org:sage into t/19946

7179c78  Trac #19946: link from general doc to detailed explaination

1259201  Trac #19946: fix typo

3d51289  Trac #19957: Merge #19946 to avoid workaround

b606fdf  Trac #19957: remove workaround for #19946

4346994  Trac #19957: rename e to expansion in doctests

5d6e9b2  Trac #19957: Introduce parameter relative tolerance

comment:17 Changed 5 years ago by
 Dependencies changed from #19931 to #19931, #19946
comment:18 in reply to: ↑ 16 Changed 5 years ago by
 Status changed from needs_review to positive_review
Replying to cheuberg:
I reviewed your changes and added a couple of commits. Please crossreview.
Look good.
Replying to dkrenn:
Two comments:
 I find the naming of a variable
e
confusing...maybe usingexpansion
would be better?Done.
 In the plot the hardcoded
0.025
should be adjustable by a parameter.Done.
Reviewed and good.
comment:19 Changed 5 years ago by
 Branch changed from u/cheuberg/asy/comparewithvalues to 5d6e9b2528fdafb7f9cf513e4d7f954fe1f06eba
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
implement exact_part
Trac #19957: Asymptotic ring: list plot comparing values