Opened 5 years ago

Last modified 10 months ago

#22763 needs_work defect

Assumptions on symbols not preserved with some unevaluated integrals

Reported by: rws Owned by:
Priority: major Milestone: sage-8.2
Component: symbolics Keywords:
Cc: nbruin Merged in:
Authors: Ralf Stephan Reviewers:
Report Upstream: N/A Work issues:
Branch: u/rws/assumptions_on_symbols_not_preserved_with_some_unevaluated_integrals (Commits, GitHub, GitLab) Commit: 39567f474257574983fb0f16bf6fc45aff4c238a
Dependencies: Stopgaps:

Status badges


In a fresh Sage, assumptions on symbols within expressions are preserved when Maxima returns the same expression in an unevaluated integral. But in this case the domain/flag information of m is somehow cleared/deleted:

sage: _ = var('m')
sage: (x^m / sqrt(2+3*x)).integral(x)
integrate(x^m/sqrt(3*x + 2), x)
sage: _= var('m', domain='integer')
sage: (x^m / sqrt(2+3*x)).integral(x)
integrate(x^m/sqrt(3*x + 2), x)
sage: _.operands()[0].operands()[1]
sage: _.operands()[1].is_integer()

assume(m, 'integer') cannot restore the flag of m in the returned integral.

The problem does not occur without the first two lines. Maybe the first creation of m does somehow irrevocably set something in Maxima (or Sage's module for backtranslation)?

Change History (7)

comment:1 Changed 5 years ago by rws

#22650 depends on this.

comment:2 Changed 5 years ago by rws

It looks like sage.interfaces.maxima_lib.sr_to_max has several symbol dicts. sage_sym_dict's keys are symbols and registered constants. At the first encounter of (x^m / sqrt(2+3*x)).integral(x) m is inserted there. The hash of the second m is the same, and presumably that's why there is no change in the dictionary. As the ms are different the hash should be different too and there is the Pynac bug that if fixed should fix this ticket too. Alternatively the dicts should be updated in var when variables are created.

comment:3 Changed 5 years ago by rws

Actually hashes have nothing to do with it. The vars are not the keys in the dictionary and, even if they were, hash makes no difference because keys are compared via bool(a==b), ie ex.__nonzero__() is used and there lhs-rhs is zero even for vars with different flags or hashes.

comment:4 Changed 5 years ago by rws

  • Branch set to u/rws/assumptions_on_symbols_not_preserved_with_some_unevaluated_integrals

comment:5 Changed 5 years ago by rws

  • Authors set to Ralf Stephan
  • Commit set to 39567f474257574983fb0f16bf6fc45aff4c238a
  • Status changed from new to needs_review

New commits:

39567f422763: update maxima_lib about variable changes

comment:6 Changed 4 years ago by rws

  • Milestone changed from sage-8.0 to sage-8.2

comment:7 Changed 10 months ago by chapoton

  • Status changed from needs_review to needs_work

red branch => needs work

Note: See TracTickets for help on using tickets.