3

(I wasn't sure what to put for the title, so feel free to improve it if you can think of a better one.)

How do I evaluate an integral that contains an unknown function of the integration variable such as the following in Mathematica?

$$\int_{x_1}^{x_2} \frac{dy}{dx} dx$$

It should obviously give me back $y(x_2) - y(x_1)$.

user541686
  • 1,317
  • 7
  • 18
  • What answer are you hoping to get? – evanb Dec 09 '14 at 21:53
  • Aren't you integrating the derivative of the arc-length? – Dr. belisarius Dec 09 '14 at 21:53
  • That's what it looks like to me. But it's not quite. There ought to be a chain-rule d^2y / dx^2 in the numerator if it were truly the arclength, unless I'm mistaken. – evanb Dec 09 '14 at 22:11
  • @evanb: Whoops, I typed in the wrong expression... my bad. But for the purposes of this question ignore the actual expression, I'm just trying to learn how to use Mathematica to do an implicit integral. I've changed it to something trivial now. – user541686 Dec 09 '14 at 22:37
  • Actually, the original integral can be done by a hyperbolic trig substitution. Pick f'[x] = Sinh[u]. – evanb Dec 09 '14 at 22:40
  • @evanb: Yeah sure but let's not go on a tangent (heh), I'm not trying to ask a math question. – user541686 Dec 09 '14 at 22:40
  • 1
    Oops, as I typed up my answer I got the sneaking feeling I've done this before: http://mathematica.stackexchange.com/questions/66494/integrate-full-derivative/66503#66503 – Michael E2 Dec 09 '14 at 22:50
  • @Mehrdad Let me know if the linked question in my previous comment seems like a duplicate. It certainly seems that way now, as the question is currently stated. – Michael E2 Dec 09 '14 at 22:51
  • Ahh I see, thanks! @MichaelE2: Yeah it is a duplicate. – user541686 Dec 09 '14 at 22:51
  • fyi, Maple can do this directly, with the option continuous given (may be M should be able to do this also). int(diff(y(z),z),z=x1..x2,continuous) gives -y(x1)+y(x2) – Nasser Dec 10 '14 at 04:42

1 Answers1

3

How about this?

f[x2] /. First @ DSolve[{f'[x] == y'[x], f[x1] == 0}, f, x]
(*
  -y[x1] + y[x2]
*)
Michael E2
  • 235,386
  • 17
  • 334
  • 747