3
$\begingroup$

This question already has an answer here:

(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)$.

$\endgroup$

marked as duplicate by Michael E2, Dr. belisarius, Öskå, Bob Hanlon, Yves Klett Dec 10 '14 at 7:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ What answer are you hoping to get? $\endgroup$ – evanb Dec 9 '14 at 21:53
  • $\begingroup$ Aren't you integrating the derivative of the arc-length? $\endgroup$ – Dr. belisarius Dec 9 '14 at 21:53
  • $\begingroup$ 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. $\endgroup$ – evanb Dec 9 '14 at 22:11
  • $\begingroup$ @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. $\endgroup$ – Mehrdad Dec 9 '14 at 22:37
  • 1
    $\begingroup$ Oops, as I typed up my answer I got the sneaking feeling I've done this before: mathematica.stackexchange.com/questions/66494/… $\endgroup$ – Michael E2 Dec 9 '14 at 22:50
3
$\begingroup$

How about this?

f[x2] /. First @ DSolve[{f'[x] == y'[x], f[x1] == 0}, f, x]
(*
  -y[x1] + y[x2]
*)
$\endgroup$

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