Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctest: Numerics in nested symbolic powers not combined #21360

Closed
rwst opened this issue Aug 29, 2016 · 11 comments
Closed

Doctest: Numerics in nested symbolic powers not combined #21360

rwst opened this issue Aug 29, 2016 · 11 comments

Comments

@rwst
Copy link

rwst commented Aug 29, 2016

Numerics in power towers are not combined if nonnumerics present:

sage: ((x^(1/2) + 1)^2).expand()
x + 2*sqrt(x) + 1
sage: ((x^(x/2) + 1)^2).expand()
(x^(1/2*x))^2 + 2*x^(1/2*x) + 1
sage: ((x^(1/2*x))^2).expand()
(x^(1/2*x))^2

Also in GiNaC:

ginsh - GiNaC Interactive Shell (GiNaC V1.7.0)
  __,  _______  Copyright (C) 1999-2016 Johannes Gutenberg University Mainz,
 (__) *       | Germany.  This is free software with ABSOLUTELY NO WARRANTY.
  ._) i N a C | You are welcome to redistribute it under certain conditions.
<-------------' For details type `warranty;'.

Type ?? for a list of help topics.
> expand((x^(x/2)+1)^2);
1+2*x^(1/2*x)+(x^(1/2*x))^2
> expand((x^(x/2))^2);
(x^(1/2*x))^2

Sympy does it as expected:

In [5]: ((x**(x/2) + 1)**2).expand()
Out[5]:
   x
   ─
   2    x
2⋅x  + x  + 1

In [1]: ((x**(x/2))**2).expand()
Out[1]:
 x
x

Component: symbolics

Author: Ralf Stephan

Branch/Commit: c4f4952

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/21360

@rwst rwst added this to the sage-7.4 milestone Aug 29, 2016
@rwst
Copy link
Author

rwst commented Aug 29, 2016

comment:1

The ticket is questioning this GiNaC code snippet (power.cpp:566):

        // Turn (x^c)^d into x^(c*d) in the case that x is positive and c is real.
        if (is_exactly_a<power>(ebasis) && ebasis.op(0).info(info_flags::positive) && ebasis.op(1).info(info_flags::real))
                return power(ebasis.op(0), ebasis.op(1) * eexponent);

@rwst
Copy link
Author

rwst commented Aug 29, 2016

comment:2

Note there are two parts to this. If the outer exponent is a fraction then branches play a role and the discussion in #14305, which makes the GiNaC code in this case correct. This does not apply to the sqrt(x)^2 case and even less to:

sage: ((x^(2*x))^2)
(x^(2*x))^2

@rwst
Copy link
Author

rwst commented Aug 29, 2016

comment:3

This is now implemented in Pynac for the outer exponent a positive integer.

@rwst
Copy link
Author

rwst commented Aug 31, 2016

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 18, 2016

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

c4f4952Merge branch 'develop' into t/21360/numerics_in_nested_symbolic_powers_not_combined

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 18, 2016

Commit: c4f4952

@rwst rwst changed the title Numerics in nested symbolic powers not combined Doctest: Numerics in nested symbolic powers not combined Sep 18, 2016
@fchapoton
Copy link
Contributor

comment:7

looks good. Please fill the Author field

@fchapoton
Copy link
Contributor

Reviewer: Frédéric Chapoton

@rwst
Copy link
Author

rwst commented Sep 18, 2016

comment:8

Thanks.

@rwst
Copy link
Author

rwst commented Sep 18, 2016

Author: Ralf Stephan

@vbraun
Copy link
Member

vbraun commented Sep 19, 2016

Changed branch from u/rws/numerics_in_nested_symbolic_powers_not_combined to c4f4952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants