MATLAB: Struggling with integration.

integration

How would I integrate this equation in matlab? V=∫pi*(R1+R2-sqrt(R2^2-x^2))^2 dx with limits -0.5D and 0.5D.
I have V, R2, and a height, D.
R1 is an unknown which I have to solve for.
What I've tried so far.
syms r1 r2 d x;
f= (pi()*(r1+r2-sqrt(r2^2-x^2))^2)
F = int(f, x)
G= int(F,r2)
a=int(F, x,0.5,-0.5)

Best Answer

Hi,
I understand that you have the values of 'R2', 'V' and 'D', and you have to solve the equation, 'V=∫pi*(R1+R2-sqrt(R2^2-x^2))^2 dx' to find the value of 'R1'.
Take a look at the following code which shows how to solve for 'R1'. The values of 'R2', 'V' and 'D' are assumptions I made.
syms x R1
R2=3;
D=4;
V=25;
f = pi*(R1+R2-sqrt(R2^2-x^2))^2;
fint = int(f,x,[-0.5*D 0.5*D]);
eqn=V-fint==0;
sol_R1=vpa(solve(eqn,R1));
For additional information on the functions used, have a look at the following links:
Related Question