Integral Approximation Equation Using Loop

Write a Matlab function that approximates the integral of the equation [y =(√x) – x^2] from x= 0 to 1. Sub-divide the domain into N equal-width rectangles to approximate the integral. What is the approximate integral using N = 5, N = 50, and N = 200? Print the code.
Can anyone help me? I am so confused!

回答 (2 件)

J Chen
J Chen 2019 年 9 月 12 日

0 投票

Generate a vector x=[0 1/N 2/N ... 1]. Calculate corresponding y for each element of x. Use the trapezoid rule to add all the y's. The sum is the aprroximation of the integral.
David Hill
David Hill 2019 年 9 月 12 日

0 投票

Sounds like standard definition of integrating where the width of the rectangles is eventually reduced to nothing.
n=5;
x=1/n:1/n:1;
area=sum((sqrt(x)-x.^2)*1/n);%problem does not say what to use as the height of the rectangle
change n to other values to get the other answers for create a loop.

カテゴリ

ヘルプ センター および File ExchangeVerification, Validation, and Test についてさらに検索

製品

質問済み:

2019 年 9 月 12 日

回答済み:

2019 年 9 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by