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

Exponential expression is not factored. #19776

Open
proy87 opened this issue Jul 15, 2020 · 4 comments
Open

Exponential expression is not factored. #19776

proy87 opened this issue Jul 15, 2020 · 4 comments
Labels

Comments

@proy87
Copy link

proy87 commented Jul 15, 2020

factor(4**x-2**x-2) does nothing.

@oscarbenjamin
Copy link
Contributor

The problem is that Poly treats both 2**x and 4**x is algebraically independent generators:

In [16]: Poly(4**x - 2**x - 2)                                                                                         
Out[16]: Poly(-(2**x) + (4**x) - 2, 2**x, 4**x, domain='ZZ')

Even if told the generator it can not spot the relationship between 2**x and 4**x:

In [24]: Poly(4**x - 2**x - 2, 2**x)                                                                                   
Out[24]: Poly(-(2**x) + 4**x - 2, 2**x, domain='ZZ[4**x]')

If 4**x is instead written as (2**x)**2 then it works:

In [23]: factor((2**x)**2 - 2**x - 2)                                                                                  
Out[23]: 
⎛ x    ⎞ ⎛ x    ⎞
⎝2  - 2⎠⋅⎝2  + 1⎠

I think the implementation of Poly in identifying generators can be improved to detect algebraic relationships among the generators.

@sylee957
Copy link
Member

sylee957 commented Jul 17, 2020

I think that powdenest that is used by exponential equation solvers in sympy, is able to decompose the exponential equation into convenient forms

>>> powdenest(8**x + (S(1)/4)**(x+1) - 12)
2**(3*x) + 2**(-2*x - 2) - 12
>>> powdenest(8**x + sqrt(2)*2**(x+1) - 12)
2**(3*x) + 2**(x + 3/2) - 12

But I don't think that it makes stuff that much canonical if rational or polynomial terms are involved in the base e.g. (S(3)/2)**x + (2/S(3))**x - 12 and a**x + (a**2)**x - 12

And I'm even finding it annoying that there are relatively poor studies done on the topic of solving exponential equations in more computationally stable way via substitutions with polynomial terms, besides the materials that are taught for precalculus level students.

@smichr
Copy link
Member

smichr commented Dec 12, 2021

solving exponential equations in more computationally stable way via substitutions with polynomial terms

Could you please give an example of this?

@smichr
Copy link
Member

smichr commented Dec 14, 2021

using #22267

>>> generators(4**x-2**x-2)
{2**x}
>>> (4**x-2**x-2).subs(_.pop(),y)
y**2 - y - 2
>>> factor(_)
(y - 2)*(y + 1)

and also

>>> generators(8**x + (S(1)/4)**(x+1) - 12)
{2**(-x - 1), 2**x}  <--------- should that be {2**-x, 2**x}?
>>> generators((S(3)/2)**x + (2/S(3))**x - 12)
{(3/2)**x}
>>> generators(a**x + (a**2)**x - 12)
{a**x, (a**2)**x}
>>> a = Symbol('a', nonnegative=True)
>>> generators(a**x + (a**2)**x - 12)
{a**x}

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

No branches or pull requests

5 participants