Numerical integration of a long symbolic expression with definite limits
4 views (last 30 days)
Show older comments
I want to numerically integrate a long symbolic expression with definite limits without using the symbolic integration function (int) because it is very slow. A sample example (for short expression) would be
syms t a b c
y=a*sin(t)+(b*cos(2*t)+c*sin(3*t))^2
I want to integrate y with respect to t from 0 to pi. The result should be a symbolic expression in a , b, c.
Again, I don't want to use int function
7 Comments
Walter Roberson
on 9 Apr 2020
Edited: Walter Roberson
on 9 Apr 2020
?
The result of int(y) would not have any trignometric expressios left in it, just combinations of a, b, c, pi, and fractions. a appears up to a^10, b appears up to b^20, c appears up to c^20. You can extract the coefficients using coeff()
You can expand() y and work term by term, using children(), extract the symbolic coefficient multipliers, do numeric integration on the sin()^n*cos()^m part, multiply by the symbolic parts, record, and later sum() all the results. It is not clear this would be any more useful than using int(y) or int(vpa(expand(y)))
Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!