Solving an equation with integral with one variable
Mostrar comentarios más antiguos
Hi, how can I calculate the following equation involving an integral in matlab?
C + Integral_{-4}_{4} e^(x^2)*x^2 dx = 1
where -4 and 4 are the lower and upper limit, and C is the unknown constant.
Thanks!
Respuesta aceptada
Más respuestas (1)
Star Strider
el 10 de Ag. de 2017
Editada: Star Strider
el 10 de Ag. de 2017
If I understand correctly what you want to do, this works:
f = @(x) exp(x.^2) .* x.^2;
Cs = fzero(@(C) C + integral(f, -4, 4) - 1, 1)
Cs =
-3.4395e+07
Or more simply, since ‘C’ is a constant:
C = 1 - integral(f, -4, 4)
C =
-3.4395e+07
If you are using R2011b or earlier, use quad instead of integral:
C = 1 - quad(f, -4, 4)
The result is the same:
C =
-34395040.4474417
here using format long g.
2 comentarios
Sergio Manzetti
el 11 de Ag. de 2017
Star Strider
el 11 de Ag. de 2017
Not to my knowledge.
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!