I'm trying something essentially like

N[Exp[-x]*(D[Exp[x*y^2], y] /. y -> 1)]

After differentiation and y -> 1 there is an Exp[x] factor that should cancel the Exp[-x], but Mathematica returns something like

2.71828^x (something*2.71828^(-1. x))

How do I tell Mathematica that -1. x is actually x so that it can cancel the two exponentials?


closed as off-topic by Michael E2, m_goldberg, MarcoB, zhk, José Antonio Díaz Navas Feb 16 at 11:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Michael E2, m_goldberg, MarcoB, zhk, José Antonio Díaz Navas
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ This looks interesting ... Do you have a space between "x" and "y^2"? Perhaps see what happens first without applying N[]. Could you please post the code "as code" in a gray box? It may be easier for others to see exactly what is happening. Thanks! $\endgroup$ – mjw Feb 15 at 4:30
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Feb 15 at 4:34
  • $\begingroup$ You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$ – Michael E2 Feb 15 at 4:34

Use FullSimplify

N[Exp[-x] (D[Exp[x*y]*y^(1/2), y] /. y -> 1)] // FullSimplify

0.5 + 1. x


Some further remarks.

In the case of the example code FullSimplify is overkill; Simplify will do.

N[Exp[-x] (D[Exp[x y^2], y] /. y -> 1)] // Simplify

2. x

Even Simplify can be avoided if the replacement is done before the numeric evaluation.

N[Exp[-x] D[Exp[x y^2], y] /. y -> 1]

2. x


Just so you know Mathematica does not treat xy as x times y, but rather as a new variable called xy. So adding an explicit * character will show that you actually want them multiplied. Adding just the space gives me the following, which seems fair enough:

In[5]:= N[Exp[-x] (D[Exp[x * y^2], y] /. y -> 1)]

Which yields

Out[5]= 2. x

Does this solve your issue?

  • $\begingroup$ thanks for the suggestion, but I was aware of 'multiplying' x and y. $\endgroup$ – Siyul Lee Feb 15 at 4:40
  • $\begingroup$ I see this example is working. I simplified the problem a bit too much. Please take a look at N[Exp[-x] (D[Exp[x*y]*y^(1/2), y] /. y -> 1)] $\endgroup$ – Siyul Lee Feb 15 at 4:41
  • $\begingroup$ which gives 2.71828^(-1. x) (0.5 2.71828^x + 2.71828^x x) $\endgroup$ – Siyul Lee Feb 15 at 4:41
  • $\begingroup$ I think the problem arises when there are fractional exponents $\endgroup$ – Siyul Lee Feb 15 at 4:41
  • $\begingroup$ @zhk that works perfectly! Thanks $\endgroup$ – Siyul Lee Feb 15 at 4:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.