3
$\begingroup$

I was trying to obtain this result:

integrate e^|x| dx

The result is

$$ \int e^{|x|} dx = \frac12 e^{-x} \left( (e^x-1)^2 \operatorname{sgn}(x) -2e^x +e^{2x} - 1 \right) \color{gray}{\,+ \text{constant}} $$

which is fine but I would like to see the 2 part solution for $x>0$ and $x<0$, I know you can see that because just after before the final output I can see it but then it switches to the one line solution above. Is there a way to see the other solution?

If it's not ok to ask about a tool used in mathematics I'm sorry. You can close it.

  • 0
    Well, you can derive it yourself; $\mathrm{sgn}(x)$ is expressible as a piecewise function.2010-09-03
  • 0
    I cannot see what you are asking here... «The other solution» is the same as the solution you have.2010-09-06
  • 0
    btw, Wolfram Alpha uses Mathematica as a backend, you may need to use Mathematica syntax to get more advanced things out of it2010-09-06

2 Answers 2

7

Apparently, giving the input

Integrate[Exp[Piecewise[{{x, x > 0}}, -x]],x]

to WolframAlpha returns a piecewise result, which may be what you're expecting.

1

You can use the following to get the two cases:

Assuming[t>0, integrate e^|x| dx from x=0 to t]
Assuming[t<0, integrate e^|x| dx from x=0 to t]

Or, if you don't care about choosing the constant of integration such that the two pieces fit together, simply:

Assuming[x>0, integrate e^|x| dx]
Assuming[x<0, integrate e^|x| dx]

(although then it's so easy that I don't see why you would need Wolfram Alpha).

  • 0
    I'm playing with the tool :D I was testing something "complicated" from the point of view of the tool, not the math, to see how flexible it is.2010-09-04
  • 0
    BTW nice workaround but since I see the solution I want just before it switches on the one line solution, I would like to see the 2part solution without giving it a restraint on the variable.2010-09-04
  • 0
    What do you mean by "seeing the solution"? For me, Alpha just spits out the answer that you quoted in the question. (No "switching" going on.)2010-09-04
  • 0
    There's a tiny moment, it's a one second switch. Clear your cache, maybe that's the problem. Or try with `integrate e^-|x| dx ` which has a slower process.2010-09-04
  • 0
    Nope, didn't make any difference. Well, never mind...2010-09-04
  • 0
    Don't worry. Tnx. It's there, I've seen that, the truth is out there.2010-09-04