Integrate a piecewise function (Second fundamental theorem of calculus)

조회 수: 86 (최근 30일)
totom
totom 2016년 12월 16일
편집: Karan Gill 2017년 10월 17일
I searched the forum but was not able to find a solution haw to integrate piecewise functions. The threads I found weren't clear either.
How can I integrate the following function for example?
F(x) = inntegral from 0 to x of f(t) dt
f(x) = x for 0 <= x <= 1
f(x) = x - 1 for 1 < x <= 2
Or is that even possible? Thank you!
  댓글 수: 1
James Tursa
James Tursa 2016년 12월 16일
What have you done so far? Why can't you just integrate each piece separately and combine appropriately?

댓글을 달려면 로그인하십시오.

답변 (2개)

Karan Gill
Karan Gill 2016년 12월 23일
편집: Karan Gill 2017년 10월 17일
>> syms x
>> f(x) = piecewise(0<=x<=1, x, 1<x<2, x-1)
f(x) =
piecewise(x in Dom::Interval([0], [1]), x, x in Dom::Interval(1, 2), x - 1)
Get the integral using int.
>> syms F(x)
>> F(x) = int(f(x),x,0,x)
F(x) =
intlib::intOverSet(piecewise(x in Dom::Interval([0], [1]), x, x in Dom::Interval(1, 2), x - 1), x, [0, x])
Those output constructs are ugly but it's still better than going into MuPAD. Now you can do things like evaluate F(x).
>> F(1)
ans =
1/2

Jan
Jan 2016년 12월 17일
편집: Jan 2016년 12월 17일
You have to integrate it in pieces. Whenever you try to integrate it in one piece, the discontinuity will conflict with the design of the integrators.
This soultion sounds trivial. Perhaps in the other threads you are talking of the users hesitated to post it. But sometimes trivial solutions are not obvious, when you are deeply involved in the problem.
Or I've overseen a detail. Then please explain this.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by