Integration using symbolic, how about the constant?
57 views (last 30 days)
I have som trouble to understand how the int function is used.
I want to solve the integration constant myself. But matlab gives a constant in the int step.
This line gives
-(g*(2*cos(t*w) + t*w + 2))/(2*w)
Which is wrong in my opinion. The solution is -(g*(2*cos(t*w) + t*w ))/(2*w) + C
Which means that C have already been calculated (C=-g/w). How can I prevent matlab from calculating C? So i can add C by myself.
(I understand that i can add the same constant v=int(a,t)+g/w. But then i need to calculate the constant first..)
This is my code:
syms t g w c1
Raunak Gupta on 9 Nov 2020
From the documentation of int, you can see it is clearly mentioned that constant of integration is not returned since the constant can be represented in any way and it can lead to huge complexity if expanding the expression. Since constant of integration in this case returned can be something else if the expression changes to some other form, it is not included in the outputs. If you want to represent the constant of integration you can add it in result as a symbolic variable.
syms x C1
f (x) = x;
g = int (f, x) + C1;
From this too you can estimate the C1.
For the comment I can tell that constant of integration that is returned is not universal and can change if you give the expression differently.
If numerical computation is required, definite integral can be used by providing the limits which will give full answer correctly.
Hope this helps!