Hi Ahmed,
I understand that you want to plot the curves f(x)= x/sqrt((x^2)+1), y=x/2 and determine the area between the curves.
To plot the curves you can use “fplot” function. Please refer the following code snippet.
fplot(@(x) x/sqrt((x^2)+1),[-4 4],'r')
hold on
fplot(@(x) x/2,[-4 4],'b')
To find the area between the curves:
Find the x coordinates of intersection points. Please refer to the following code snippet.
syms x
eqn = x/sqrt((x^2)+1)==x/2;
X=solve(eqn,x)
The x coordinates of intersection points are -1.7321, 0, 1.7321. Integrate y= x/sqrt((x^2)+1)- x/2 over [0,1.7321] and y= x/2- x/sqrt((x^2)+1) over [-1.7321,0] . As the graph is symmetric about origin, it is sufficient if you obtain one half of area and multiply it by 2. Please refer to the following code snippet
fun= @(x) ((x/sqrt((x.^(2))+1))-(x/2));
area1=integral(fun,0,1.732);
area=2*area1
Please refer to the following MATLAB documentations and MATLAB answers for better understanding and other methods to calculate area between two curves:
- https://www.mathworks.com/help/matlab/ref/fplot.html
- https://www.mathworks.com/help/symbolic/sym.solve.html
- https://www.mathworks.com/help/matlab/ref/integral.html
- https://www.mathworks.com/matlabcentral/answers/15550-how-to-create-a-matlab-program-computing-area-between-2-curves
- https://www.mathworks.com/matlabcentral/answers/427905-how-can-i-calculate-the-area-between-two-curves?s_tid=answers_rc1-1_p1_Topic