如何集成一个复杂的功能?

How to integrate a complicated function?

一段时间以来,我一直试图弄清楚这个积分,但一直没有成功。我试过进行符号积分,但我被它击退了,所以我假设没有那样的解决方案。我已经决定用定积分来解决它,但仍然不断出错:

clear
clc

x = 1;
y = 1;
z = 1;
R = 2;

b =@(theta) y.*cos(theta)/((x-R.*cos(theta)).^2+y.^2+(z - 
            R.*sin(theta)).^2).^(3/2)

integral(b,1,2)

我当前的错误是:

Error using integralCalc/finalInputChecks (line 515)
Output of the function must be the same size as the input. If FUN is an array-valued
integrand, set the 'ArrayValued' option to true.

Error in integralCalc/iterateScalarValued (line 315)
                finalInputChecks(x,fx);

Error in integralCalc/vadapt (line 132)
            [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);

Error in integralCalc (line 75)
        [q,errbnd] = vadapt(@AtoBInvTransform,interval);

Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);

任何帮助将不胜感激!

您需要将第一个学期的除号从 / 更改为 ./ 以确保您正在做 element-wise division and not matrix right division:

b = @(theta) y.*cos(theta)./((x-R.*cos(theta)).^2+y.^2+(z - ...
             R.*sin(theta)).^2).^(3/2);
integral(b,1,2)

ans =

   0.055781612354862