Export to GitHub

sympy - issue #654

exp._eval_subs contains dead code ?


Posted on Jan 23, 2008 by Helpful Wombat

> > diff --git a/sympy/functions/elementary/exponential.py b/sympy/functions= /elementary/exponential.py > > --- a/sympy/functions/elementary/exponential.py > > +++ b/sympy/functions/elementary/exponential.py > > @@ -13,7 +13,7 @@ class exp(Function): > > raise ArgumentIndexError(self, argindex) > > > > def inverse(self, argindex=3D1): > > - return S.Log > > + return log > > > > @classmethod > > def _eval_apply_subs(self, *args): > > @@ -124,7 +124,7 @@ class exp(Function): > > arg =3D self.args[0] > > o =3D old > > if isinstance(old, Basic.Pow): # handle (exp(3*log(x))).subs(x*= 2, z) -> z*(3/2) > > - old =3D exp(old.exp * S.Log(old.base)) > > + old =3D exp(old.exp * log(old.base)) > > if isinstance(old, exp): > > b,e =3D self.as_base_exp() > > bo,eo =3D old.as_base_exp() >=20 > I would suggest to either write tests, or remove the code. >=20 > But yes, this patch can go in, but unless there are tests for this, I > don't see any point of having such a code.

It seems this piece of code is never (?) executed in sympy since exp(3*log(x)) canonize to x**3.

On the other hand when autoevaluation would be turned off exp(3*log(x)) will be just that -- so there should be a test which constructs unevaluated exp(3*log(x)) and calls subs.

I'm not sure how to do it now, please advise.

Comment #1

Posted on Dec 2, 2009 by Happy Elephant

(No comment was entered for this change.)

Comment #2

Posted on Nov 8, 2011 by Quick Bird

exp(3*log(x),evaluate=False) exp(3*log(x))

Comment #3

Posted on Nov 9, 2011 by Happy Elephant

(No comment was entered for this change.)

Comment #4

Posted on Nov 18, 2011 by Massive Dog

(No comment was entered for this change.)

Comment #5

Posted on Nov 20, 2011 by Happy Elephant

(No comment was entered for this change.)

Comment #6

Posted on Nov 22, 2011 by Happy Elephant

This was rather confusing to the Code-In student who is doing it. In the future, to be very explicit about what needs to be done if you add the CodeIn labels to an issue.

Comment #7

Posted on Nov 23, 2011 by Happy Elephant

This was fixed. See https://github.com/sympy/sympy/pull/733.

Comment #8

Posted on Mar 5, 2014 by Happy Elephant

We have moved issues to GitHub https://github.com/sympy/sympy/issues.

Comment #9

Posted on Apr 6, 2014 by Happy Rabbit

Migrated to http://github.com/sympy/sympy/issues/3753

Status: Fixed

Labels:
Type-Defect Priority-Medium Matching CodeInCategory-Code CodeInDifficulty-Easy EasyToFix CodeInImportedIntoMelange Restrict-AddIssueComment-Commit