slow loop in calculation of definite integral

slow loop in calculation of definite integral - slow loop - Messages

#1 Posted: 8/25/2024 2:53:50 AM
Laurent Fournier

Laurent Fournier

9 likes in 66 posts.

Group: User

Hello, I need to calculate 2 successive integrals in order to obtain the deflection of a beam with variable depth

To derive algebraically the integral is too tough for me.

The in-built integral in Smath doesn't work twice (We can integrate a function only once) and Andrey has explained in the forum that it is a limitation of this in-built feature.

I did the following:
1) define the beam depth D(x) as a function of x
2) calculate the beam inertia I(x)=D(x)^3/12 x width
3) define the bending moment M(x) as a function of x (textbook formula)
4) calculate the second derivative of the deflection by the formula: D2(x)=M(x)/I(x)/E (E is the elastic modulus)
5) calculate the slope function, D1(x) by integration of D2(x) using Smath Studio in-built feature
6) digitise the slope function over a number of points: I obtain 2 vectors, X and Y
7) define the slope function slope(x) using linterp(X,Y,x) built-in feature
8) find the deflection function D(x) by integration of the digitised slope function slope(x)

My worksheet is extremely slow. 50 points take 10 minutes or so.

Then I tried a second process, digitising every step right from the beginning. This is quicker but it still takes 1 minute for 50 points.

I find this problem puzzling because when I integrate twice another function, like sin(x), also using the same digitised process right from the beginning, it can calculate 500 points in 1 second!

This looks like I am not able to "decouple" the digitised function from the original one, as if Smath was still calculating everything from the beginning, passing through the "digitisation barrier"...

I am attaching 2 files, the one with the fully digitised integration process for the cantilever beam with variable depth, and the one with the same process applied on a simple sin(x) function.

I feel there must be a way to make this work. I need this deflection calculation for calculating rammed earth piers under seismic action.

Any advice would be welcome!
Thanks
Laurent

deflection of a cantilever with variable depth.sm (28 KiB) downloaded 57 time(s).
digitizing and integrating a.sm (33 KiB) downloaded 60 time(s).
#2 Posted: 8/25/2024 2:31:05 PM
Laurent Fournier

Laurent Fournier

9 likes in 66 posts.

Group: User

Finally I may use geogebra: I can double integrate 500 points and geogebra still remains interactive!

Most of my projects I use both softwares in parallel: One model to cross-check my errors in the other one!

But Smath Studio has superior conceptual communication capabilities. You can document and communicate your work to others in a much more clear and comprehensive manner in Smath Studio.

double integral a.zip (31 KiB) downloaded 62 time(s).
#3 Posted: 8/25/2024 5:52:31 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Hi. "line" prevents the inmediate evaluation, thus, the expressions are evaluated every time that they are needed. You can see that in this (very old) post. One solution is using eval, and another is putting 1*line( ... ), like in the attached.

deflection of a cantilever with variable depth.sm (29 KiB) downloaded 72 time(s).
digitizing and integrating a.sm (34 KiB) downloaded 69 time(s).

Best regards.
Alvaro.
1 users liked this post
Laurent Fournier 8/25/2024 6:01:00 PM
#4 Posted: 8/25/2024 6:01:37 PM
Laurent Fournier

Laurent Fournier

9 likes in 66 posts.

Group: User

Fantastic!
Thank you so much, Alvaro!
  • New Posts New Posts
  • No New Posts No New Posts