Message Boards Message Boards

GROUPS:

Integrate from InterpolatingFunction?

Posted 14 days ago
160 Views
|
5 Replies
|
1 Total Likes
|

Hi All,

Given the following data below:- (data points at increments of {1,2,3,4,5,6,7,8,9,10...etc } I have plotted the data as blue points. (Almost linear, but not...) I have also plotted to g = Interpolation[data] as a line through the data... My question - I am trying to calculate the definite Integral to represent the Volume of a right squared pyramid from height 15 to 60 for example . The x axis being the height of the pyramid & the slope plotted being half of the cross section of the pyramid along 1/2 side of the square base. I have setup a bestFitLine function to give approx value guidance. But I really want to get the pyramid volume from the actual (uneven) data points / interpolation.

In[1]:= data = {1.2010674083676476`, 1.4610596766655415`, 
   1.6961372700361923`, 1.9184860674104527`, 2.132494637438493`, 
   2.3403777349216415`, 2.5434607491172385`, 2.7426285002921538`, 
   2.9385199513793783`, 3.1316244697300593`, 3.322334014583465`, 
   3.5109733543607615`, 3.6978183572141328`, 3.883107474330874`, 
   4.067049224023154`, 4.249827238220414`, 4.431603766561531`, 
   4.6125221801690985`, 4.792708823563339`, 4.972274451728503`, 
   5.151315417828051`, 5.329914725543849`, 5.508143020159319`, 
   5.686059561839028`, 5.863713201765801`, 6.041143366150418`, 
   6.2183810432789945`, 6.395449763257905`, 6.57236655769515`, 
   6.749142886197359`, 6.925785517542216`, 7.1022973552487505`, 
   7.278678199637739`, 7.454925441030723`, 7.631034681224503`, 
   7.807000282628627`, 7.982815846373875`, 8.158474622252527`, 
   8.333969854531446`, 8.509295068502324`, 8.684444303131702`, 
   8.85941229539189`, 9.03419462184462`, 9.208787802865604`, 
   9.383189374589788`, 9.557397933267952`, 9.731413156292543`, 
   9.90523580370352`, 10.078867703545864`, 10.25231172403398`, 
   10.425571735093747`, 10.598652561505094`, 10.771559929557819`, 
   10.94430040885976`, 11.116881350696419`, 11.289310824131494`, 
   11.46159755085488`, 11.633750839625161`, 11.805780521014597`, 
   11.977696883043432`, 12.149510608185144`, 12.321232712132687`, 
   12.492874484636884`, 12.664447432659893`, 12.835963226028221`, 
   13.007433645719672`, 13.17887053487611`, 13.350285752597737`, 
   13.521691130544323`, 13.693098432343339`, 13.864519315783989`, 
   14.035965297758807`, 14.207447721900595`, 14.37897772885137`, 
   14.550566229091388`, 14.722223878249748`, 14.893961054813387`, 
   15.065787840147776`, 15.237714000740603`, 15.409748972578276`, 
   15.581901847564591`, 15.75418136189079`, 15.926595886266563`, 
   16.0991534179222`, 16.271861574292842`, 16.444727588296836`, 
   16.61775830512115`, 16.79096018042811`, 16.96433927989891`, 
   17.137901280030547`, 17.311651470104557`, 17.48559475524697`, 
   17.659735660500854`, 17.834078335834207`, 18.008626562007777`, 
   18.183383757229233`, 18.35835298452189`, 18.533536959738324`, 
   18.708938060151258`, 18.884558333556175`, 19.060399507822524`, 
   19.236463000832632`, 19.4127499307499`, 19.589261126560302`, 
   19.76599713883387`, 19.94295825065534`, 20.120144488675827`, 
   20.29755563424022`, 20.4751912345474`, 20.653050613803487`, 
   20.831132884330703`, 21.00943695759741`, 21.18796155513734`, 
   21.36670521932895`, 21.545666324008142`, 21.724843084890374`, 
   21.904233569780544`, 22.083835708551472`, 22.263647302874112`, 
   22.443666035684856`, 22.623889480377454`, 22.804315109709016`, 
   22.984940304411634`, 23.16576236150283`, 23.346778502289833`, 
   23.527985880064236`, 23.70938158748511`, 23.890962663649997`, 
   24.072726100854435`, 24.2546688510419`, 24.436787831947047`, 
   24.619079932936078`, 24.80154202054889`, 24.98417094374854`, 
   25.166963538884048`, 25.349916634373205`, 25.53302705511266`, 
   25.716291626622777`};

   g = Interpolation[data]

bestFitLine[x_] := 1.413481098702441` + 0.1753779788405405` x

See attached file = "Question - Integrate from InterpolatingFunction - 3rd Octo 2018.nb" for plotted lines & data. And required result.

Please could anyone show me the correct coding for an interpolating function from the data to give accurate volume of pyramid at any point along the x / height domain.

Many thanks for your help & attention. Best regards, Lea...

Attachments:
5 Replies

Lea,

Put a N[...] around your integral and you will get a numerical result.

N[Integrate[(2*g[x])^2, {x, 15, 60}]]

to get

12,618.9

Regards,

Neil

Posted 14 days ago

Perfect... Many thanks Neil.

What about

In[150]:= g1 = Fit[data, {1, x}, x]
Integrate[(2 g1)^2, {x, 15, 60}]

Out[150]= 1.41348 + 0.175378 x

Out[151]= 12425.9

?

With FindFormula:

DATA = Table[{j, data[[j]]}, {j, 1, Length[data]}];
fit = FindFormula[DATA, x, 1, PerformanceGoal -> "Quality", SpecificityGoal -> 30, TimeConstraint -> 60, RandomSeeding -> 20]
NIntegrate[(2*fit)^2, {x, 15, 60}, WorkingPrecision -> 16]

(* 12618.90594297225 *)
Posted 10 days ago

Hi Hans & Mariusz, Many thanks for both of your suggestions. Best regards, Lea...

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract