Opened 4 years ago

Closed 4 years ago

#19957 closed enhancement (fixed)

Asymptotic ring: list plot comparing values

Reported by: cheuberg Owned by:
Priority: major Milestone: sage-7.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 4 years ago by cheuberg

  • Branch set to u/cheuberg/asy/commpare-with-values

comment:2 Changed 4 years ago by cheuberg

  • Commit set to 9be60a072f561272cd8e79961acda0dbbd269971
  • Dependencies set to #19931

New commits:

8aa55e2implement exact_part
9be60a0Trac #19957: Asymptotic ring: list plot comparing values

comment:3 Changed 4 years ago by git

  • Commit changed from 9be60a072f561272cd8e79961acda0dbbd269971 to fd6b4ec75f7917d326c3c1e4ab5b1f2b715a6c95

Branch pushed to git repo; I updated commit sha1. New commits:

fd6b4ecTrac #19957: additional doctests

comment:4 Changed 4 years ago by cheuberg

  • Status changed from new to needs_review

comment:5 follow-up: Changed 4 years ago by 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?
  • 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 4 years ago by behackl

  • Status changed from needs_review to needs_info

comment:7 in reply to: ↑ 5 Changed 4 years ago by cheuberg

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 follow-up: Changed 4 years ago by behackl

  • Authors changed from Clemens Heuberger to Benjamin Hackl, Clemens Heuberger
  • Branch changed from u/cheuberg/asy/commpare-with-values to u/behackl/asy/compare-with-values
  • 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 and scaled=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 flag return_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:

83125aalet compare_with_values return a list of tuples
85bf9a0add rescaled-parameter
d110580allow symbolic arguments for values
b09ae92improve doctests with shorter workaround
5b20379add plot_comparison method

comment:9 in reply to: ↑ 8 Changed 4 years ago by dkrenn

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. 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.

#15011.

comment:10 follow-up: Changed 4 years ago by cheuberg

  • Reviewers set to Clemens Heuberger
  • Status changed from needs_review to needs_work
  1. compare_with_value should have a parameter ring=RIF and results should be converted into ring
  2. Examples section should still contain an example with a function
  3. see also block from compare_with_value to plot_comparison
  4. why *kwargs in the call of list_plot instead of **kwargs?
  5. Example with non-trivial arguments, i.e. setting a color.
  6. 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.
  7. plot_comparison should also accept a ring; it should be documented and treated to be a RealIntervalField.

comment:11 Changed 4 years ago by cheuberg

  • Branch changed from u/behackl/asy/compare-with-values to u/cheuberg/asy/compare-with-values

comment:12 in reply to: ↑ 10 Changed 4 years ago by behackl

  • Branch changed from u/cheuberg/asy/compare-with-values to u/behackl/asy/compare-with-values
  • Commit changed from 5b20379b8dafbf0467eb040d55bc0d857f2a1ea3 to 51668a9d5c0b8af1c11f9d5b1703e326e7b4d317
  • Status changed from needs_work to needs_review

Thanks for looking over my adaptions!

Replying to cheuberg:

  1. compare_with_value should have a parameter ring=RIF and results should be converted into ring

Done.

  1. Examples section should still contain an example with a function

Done.

  1. see also block from compare_with_value to plot_comparison

Done.

  1. why *kwargs in the call of list_plot instead of **kwargs?

Typo. Fixed.

  1. Example with non-trivial arguments, i.e. setting a color.

I've added a more sophisticated doctest.

  1. 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).

  1. plot_comparison should also accept a ring; it should be documented and treated to be a RealIntervalField.

Done.

Back to needs_review.


New commits:

2041027Trac #19957: reviewer commit
0990eedadd ring-parameter for compare_with_value
6d1de23adapt doctests
7a6c9bbadd doctest with function
7023a0eadd seealso-block
f0f349dadd doctest with plot-options
154299flet plot_comparison deal with RIFs
79bbc61improve code in loop
51668a9add doctest for numerical noise check

comment:13 Changed 4 years ago by dkrenn

  • Branch changed from u/behackl/asy/compare-with-values to u/dkrenn/asy/compare-with-values

comment:14 follow-up: Changed 4 years ago by dkrenn

  • 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 using expansion would be better?
  • In the plot the hard-coded 0.025 should be adjustable by a parameter.

New commits:

311141fTrac 19957 review: minor code rewrite
7337e61Trac 19957 review: restructure part of the code and remove inner list to make it better readable
0632fd3Trac 19957 review: minor changes in doc

comment:15 Changed 4 years ago by cheuberg

  • Branch changed from u/dkrenn/asy/compare-with-values to u/cheuberg/asy/compare-with-values

comment:16 in reply to: ↑ 14 ; follow-up: Changed 4 years ago by cheuberg

  • Commit changed from 0632fd3d610aa1c53ecd9b562c67502cb4ac4986 to 5d6e9b2528fdafb7f9cf513e4d7f954fe1f06eba

I reviewed your changes and added a couple of commits. Please cross-review.

Replying to dkrenn:

Two comments:

  • I find the naming of a variable e confusing...maybe using expansion would be better?

Done.

  • In the plot the hard-coded 0.025 should be adjustable by a parameter.

Done.


Last 10 new commits:

7918417Trac #19946: additional doctest
1471336Trac #19946: rewrite and improve explaination of 1b62954
9f9a23fTrac #19961: document rpow
101e4deMerge branch 'u/dkrenn/t/19961' of trac.sagemath.org:sage into t/19946
7179c78Trac #19946: link from general doc to detailed explaination
1259201Trac #19946: fix typo
3d51289Trac #19957: Merge #19946 to avoid work-around
b606fdfTrac #19957: remove work-around for #19946
4346994Trac #19957: rename e to expansion in doctests
5d6e9b2Trac #19957: Introduce parameter relative tolerance

comment:17 Changed 4 years ago by cheuberg

  • Dependencies changed from #19931 to #19931, #19946

comment:18 in reply to: ↑ 16 Changed 4 years ago by dkrenn

  • Status changed from needs_review to positive_review

Replying to cheuberg:

I reviewed your changes and added a couple of commits. Please cross-review.

Look good.

Replying to dkrenn:

Two comments:

  • I find the naming of a variable e confusing...maybe using expansion would be better?

Done.

  • In the plot the hard-coded 0.025 should be adjustable by a parameter.

Done.

Reviewed and good.

comment:19 Changed 4 years ago by vbraun

  • Branch changed from u/cheuberg/asy/compare-with-values to 5d6e9b2528fdafb7f9cf513e4d7f954fe1f06eba
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.