Numerical integration of a long symbolic expression with definite limits

3 vues (au cours des 30 derniers jours)
Mohammed
Mohammed le 9 Avr 2020
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 commentaires
Walter Roberson
Walter Roberson le 9 Avr 2020
Modifié(e) : Walter Roberson le 9 Avr 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)))
Mohammed
Mohammed le 9 Avr 2020
I am responding to Torsten question

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by