The way to integrate a differentiated function(微分した関数を積分する方法)

I would like to know the way to integrate a differentiated function.
Specifically, I want a calculation like this.
y=x^2+x+5
diff(y)=2x+1
integral(diff(y) ,0 ,1)=2
I tried some ways, but they were not success.
I show the ways I tried.
ex.1
>> y=@(x) x.^2+x+5
y =
function_handle with value:
@(x)x.^2+x+5
>> diff(y)
Undefined function 'diff' for input arguments of type 'function_handle'.
ex.2
>> syms x;
>> y=x.^2+x+5
y =
x^2 + x + 5
>> diff(y)
ans =
2*x + 1
>> yy=@(x) diff(y)
yy =
function_handle with value:
@(x)diff(y)
>> integral(yy,0,1)
Error using integralCalc/finalInputChecks (line 522)
Input function must return 'double' or 'single' values. Found 'sym'.
Error in integralCalc/iterateScalarValued (line 315)
finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Do you have any ways? Please teach me...
Thank you.

Réponses (1)

Daniel Pollard
Daniel Pollard le 15 Déc 2020

0 votes

Well the integral of a derivative is simply the function itself. For example:
y(x) = x^2 + x + 5
dy/dx = 2x + 1
integral(dy/dx) = x^2 + x + 5 + c
integral(dy/dx from 0 to 1) = y(1) - y(0).
In your case, you have already defined y(x), so you can just use that.

2 commentaires

Yoshiki Sato
Yoshiki Sato le 15 Déc 2020
Thank you for your support.
I know that you said.
Actually, I would like to use two differentiated functions, y1'(x) and y2'(x).
And, I want to integrate the function defined by y1'(x) * y2'(x) .
To explain simply, I used simple example.
Thank you.
I haven't used the symbolic toolbox before so this is getting a bit out of my knowledge. Do you know the functions beforehand, so maybe you could integrate y1'*y2' using integration by parts, or explicitely define the product in matlab and use a symbolic integration command?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by