cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple integrals not calculating

SOLVED
Highlighted
Level 7

Multiple integrals not calculating

Hi all,

 

I'm working on on a sheet which calculates section forces and deflections in a cantilever beam based on a function for the load. There's multiple integrals involved:

  1. define q(z)
  2. V(z) = integrate q(z) over z = 0...z
  3. M(z) = integrate V(z)
  4. u(z) = double integration of M(z)

In my sheet this sort of looks as follows, where q is a ranged function, see the top left graph:PTC_forum_multiple_integrals.jpg

 

 

Steps 2 and 3 are easy for MathCAD to compute, but step 4 (bottom right graph) puts my computer in an endless loop of calculation.  MathCAD 15 also has it hard, but does come to a result after a while, where MathCAD Prime 4 is still calculating after about an hour.

 

 

I can understand that multiple integrations can be cumbersome for my computer, but in my opinion, this is what MathCAD should be good at? Am I doing something wrong somewhere, are there ways to get the last step working, or am I just asking too much of the software?

 

Thanks in advance for your advice!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Multiple integrals not calculating

It takes forever?  Yeah, been there!

 

Realize that when you integrate using a function that itself is an integral you're doing the first integration again for each step of the second.  And you're four levels deep.

 

What I have found that loses accuracy if you're not really careful but speeds the process is to fit a polynomial.  (Polynomials integrate very fast!)  Looking at your graphs, moment looks like a good candidate. 

 

Develop a vector (Z) along the length.  Create a second vector of moments at each location of Z, (Mz), by evaluating your function.  (Mz = MEd(Z)).  Then use Fn:=polyfit(Z, Mz,n) to fit an nth order polynomial to that data. ( Polyfit creates a function.)  You can plot the error Mz-Fn(Z),and adjust n to control errors.

 

Now, instead of integrating M(z), integrate Fn(z)--should be much faster.

8 REPLIES 8

Re: Multiple integrals not calculating

 

Re: Multiple integrals not calculating

Upload your worksheets (M15 as well as Prime 4).

 

 

Alan

Re: Multiple integrals not calculating

I agree fully with Alan: Upload your worksheet(s), do not post just a picture.

Other thatn that: It's usually NOT a good idea to have the very same variable in the integrand as on the borders of integration.Suggestion: change the 'z's of integrands to e.g. zeta's, that should solve most of your problem. In the double integral you are going to need zeta1 and zeta2 then.

And finally, if your Qk function is sufficiently simple, solve the whole problem purely symbolically first, ideally resulting in a closed expression for each of your functions. That will make calculations faster in the end.

 

Success!
Luc

Re: Multiple integrals not calculating

My apologies, here's the sheets...

 

I'll give the suggestion of the integrand borders a try!

Re: Multiple integrals not calculating

It takes forever?  Yeah, been there!

 

Realize that when you integrate using a function that itself is an integral you're doing the first integration again for each step of the second.  And you're four levels deep.

 

What I have found that loses accuracy if you're not really careful but speeds the process is to fit a polynomial.  (Polynomials integrate very fast!)  Looking at your graphs, moment looks like a good candidate. 

 

Develop a vector (Z) along the length.  Create a second vector of moments at each location of Z, (Mz), by evaluating your function.  (Mz = MEd(Z)).  Then use Fn:=polyfit(Z, Mz,n) to fit an nth order polynomial to that data. ( Polyfit creates a function.)  You can plot the error Mz-Fn(Z),and adjust n to control errors.

 

Now, instead of integrating M(z), integrate Fn(z)--should be much faster.

Re: Multiple integrals not calculating

Solve it symbolically  first, or do as Fred suggests: fit simpler functions to your integration results.

Some remarks (just looked at the alg-... "not include" file, because none of the files fully function in Prime express due to usage of include files and programming) :

- In your definition of q'p(z) you have a last line with an IF but no corresponding ELSE. Does that leave room for unaccounted-for situations?

- Below "achtergrondresponsefactor" (typisch Nederlands, om alles aan elkaar te schrijven) you define a function L(z) that in the ELSE part calls itself. That doesn't speed things up... Why not just return the 'THEN' expression with z replaced by zmin?

 

Success!
Luc

 

Re: Multiple integrals not calculating

Thanks Fred, that seems to do the trick indeed!

PTC_forum_multiple_integrals__polyfit.jpg

 

 

Haven't been able to fully verify the results, but the calculation time is more than acceptable, considering what's being calculated!

Re: Multiple integrals not calculating

Thanks, of course I will check out your suggestions for improvement of the included sheet as well! (as for the language comment: Dutchies will be Dutch right? Smiley Tongue)

 

Didn't get the part with the integrand borders working though, but that's probably my basic lack of understanding math Smiley Very Happy