Search code examples
matlabintegral

Is my equation too complex for matlab to integrate?


I have a code that needs to evaluate the arc length equation below:

syms x

a = 10; b = 10; c = 10; d = 10;

fun = 4*a*x^3+3*b*x^2+2*c*x+d

int((1+(fun)^2)^.5)

but all that returns is below:

ans = int(((40*x^3 + 30*x^2 + 20*x + 10)^2 + 1)^(1/2), x)

Why wont matlab evaluate this integral? I added a line under to check if it would evaulate int(x) and it returned the desired result.


Solution

  • Problems involving square roots of functions may be tricky to intgrate. I am not sure whether the integral exists or not, but it if you look up the integral of a second order polynomial you will see that this one is already quite a mess. What you would have, would you expand the function inside the square root, would be a ninth order polynomial. If this integral actually would exist it may be too complex to calculate.

    Anyway, if you think about it, would anyone really become any wiser by finding the analytical solution of this? If that is not the case a numerical solution should be sufficient.

    EDIT

    As thewaywewalk said in the comment, a general rule to calculate these kinds of integrals would be valuable, but to know the primitive function to the particular integral would probably be overkill (if a solution could be found).

    Instead define the function as an anonymous function

    fun = @(x) sqrt((4*a*x.^3+3*b*x.^2+2*c*x+d).^2+1);
    

    and use integral to evaluate the function between some range, eg

    integral(fun,0,100);
    

    for evaluating the function in the closed interval [0,100].