Solve integrals with Matlab
Show older comments
Hey guys i am working on a calculus problem and it requires me to use analytical solution, trapezoidal numerical integration, simpson's rule, lobatto quadrature and global adaptive quadrature. I keep getting errors and i have no idea what i am doing incorrect. Could someone help me write the code for this? Thanks.
Problem: f(x)= integral sign(5+1/sqrt(1-x^2)). Upper bound of integral sign is 1/2 and lower bound of integral sign is 0.
% Integrating using different commands
x=0:0.1:1/2;
y=(5+1/sqrt(1-x^2));
format long
% Analytical Solution
A0=(5+1/sqrt(1-x^2))
% Trapezoidal Numerical Integration
A1= trapz(x,y)
% Simpson's Rule
A2= quad('sqrt(1-x^2'x(1),x(end))
% Lobatto Quadrature
A3=quadl('sqrt(1-x^2'x(1),x(end))
% Global Adaptive Quadrature
A4=integral(intfun,x(1),x(end))
Accepted Answer
More Answers (2)
mohamed adel
on 26 May 2020
0 votes
∫_3^5▒〖1/√(x^2-4) dx〗
Sara
on 19 Mar 2024
0 votes
P(a,b)=1/√2π ∫_a^b▒〖e^((-x^2)/2) dx〗
Categories
Find more on Numerical Integration and Differential Equations 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!