topic Direct Integration Problem - MathCAD in PTC Mathcad
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625854#M187108
<P>Hello All,</P>
<P> </P>
<P>I am having a bit of trouble with direct integration on the attached sheet. I have a data set provided in Excel format which I have converted to matrix/vector form and then to function form using cubic spline interpolation. Unfortunately I am having trouble integrating the resulting function in x and am receiving a "This calculation does not converge to a solution" error message.</P>
<P> </P>
<P>I have tried changing TOL to ridiculous values like 1E-50, with no luck.</P>
<P> </P>
<P>Any assistance would be greatly appreciated.</P>
<P> </P>
<P>Many thanks and kind regards</P>Mon, 09 Sep 2019 13:31:29 GMTAATaylor2019-09-09T13:31:29ZDirect Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625854#M187108
<P>Hello All,</P>
<P> </P>
<P>I am having a bit of trouble with direct integration on the attached sheet. I have a data set provided in Excel format which I have converted to matrix/vector form and then to function form using cubic spline interpolation. Unfortunately I am having trouble integrating the resulting function in x and am receiving a "This calculation does not converge to a solution" error message.</P>
<P> </P>
<P>I have tried changing TOL to ridiculous values like 1E-50, with no luck.</P>
<P> </P>
<P>Any assistance would be greatly appreciated.</P>
<P> </P>
<P>Many thanks and kind regards</P>Mon, 09 Sep 2019 13:31:29 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625854#M187108AATaylor2019-09-09T13:31:29ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625861#M187109
<P>I'm not sure what the problem is, but a b-spline works (at least in prime).</P>
<P> </P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2019-09-09_8-54-41.png" style="width: 530px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/19182i5EB352B3719B4151/image-size/large?v=v2&px=999" role="button" title="2019-09-09_8-54-41.png" alt="2019-09-09_8-54-41.png" /></span></P>Mon, 09 Sep 2019 13:56:17 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625861#M187109DJF2019-09-09T13:56:17ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625864#M187110
<P>utot works ok as it is for me!</P>
<P> </P>
<P>The uvol integral works by using an overbar.</P>
<P> </P>
<P>See attached.</P>
<P> </P>
<P>Alan</P>
<P> </P>
<P>NB I removed the ridiculously low value of TOL.</P>
<P> </P>Mon, 09 Sep 2019 14:09:15 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625864#M187110AlanStevens2019-09-09T14:09:15ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625882#M187112
<P>Without seeing your worksheet...</P>
<P>Why do you think that creating a spline from a data vector and integrating along that spline would give you a better (more accurate?) result than just summing all data points?</P>
<P>A spline is no more than a nice curve along your data points and, unless there is other/prior knowledge about the system that creates the data points, you cannot add accuracy by creating a spline.</P>
<P> </P>
<P>Assuming that Alan solved the problem, and you now know the result of integration: compare that with simply adding up the data points. Then decide if creating the spline is worth all the trouble...</P>
<P> </P>
<P>Success!<BR />Luc</P>Mon, 09 Sep 2019 15:18:57 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625882#M187112LucMeekes2019-09-09T15:18:57ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625929#M187116
Hi Luc,<BR /><BR />I’m not sure what you mean by summing all the data points? Surely just adding the stress values would not be the same as calculating the area? Are you referring to a summation of trapezoidal areas? I have done a crude method of that in the worksheet.<BR /><BR />The basic answer to your question is that the method I used is the easiest way I know to find the area under a curve in mathcad. <BR /><BR />If you know a different way using the vectors directly I’d love to know!<BR /><BR />Cheers<BR />Mon, 09 Sep 2019 21:34:20 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625929#M187116AATaylor2019-09-09T21:34:20ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625930#M187117
Hi Alan, <BR /><BR />I’m not sure what has happened but it now works for me too! Annoyingly I wasted about 2 hours fiddling with the sheet without any obvious remedy before giving up and posting here...<BR /><BR />Thanks for the overbar vectorisation tip - I had missed that detail from the online help example!<BR /><BR />Cheers<BR />Mon, 09 Sep 2019 21:37:20 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625930#M187117AATaylor2019-09-09T21:37:20ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625931#M187118
Hi Alex, Thanks for the response, much appreciated, although Cspline appears to be working now<BR /><BR />Cheers<BR />Mon, 09 Sep 2019 21:38:20 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625931#M187118AATaylor2019-09-09T21:38:20ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625939#M187119
<P>You are wondering why in Alan's sheet the integral utot works now for you? The reason is that he disabled your TOL setting and so the default TOL=10^-3 is valid now.</P>
<P>Setting the value of TOL to lower values (10^-4 or lower, as you did) <U>increases</U> the chance of the integral NOT converging!</P>
<P>Your approach with U.vol works without vectorization if you use an undefined variable (quickplot) or a range as argument:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B1.png" style="width: 302px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/19196iCABBD61F4151A9AC/image-dimensions/302x233?v=v2" width="302" height="233" role="button" title="B1.png" alt="B1.png" /></span></P>
<P>As to the trapezoid rule - here is an approach using your raw data:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B2.png" style="width: 327px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/19195i8E6A5AD78ACEBB32/image-dimensions/327x179?v=v2" width="327" height="179" role="button" title="B2.png" alt="B2.png" /></span></P>
<P>Worksheet in MC15 format attached.</P>
<P> </P>Mon, 09 Sep 2019 22:24:48 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/625939#M187119Werner_E2019-09-09T22:24:48ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626098#M187132
<P>This is what I'm talking about.</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LM_20190910_IntegrateVector0.png" style="width: 626px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/19218iE2438976EBEC92DA/image-size/large?v=v2&px=999" role="button" title="LM_20190910_IntegrateVector0.png" alt="LM_20190910_IntegrateVector0.png" /></span></P>
<P>Note that the definition of integration is nothing else than summing vertical bars of infinitesimally small width, and height equal to the function value at the (ordinate) mid point of each bar.</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LM_20190910_IntegrateVector1.png" style="width: 663px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/19219i14E8D983F376ED20/image-size/large?v=v2&px=999" role="button" title="LM_20190910_IntegrateVector1.png" alt="LM_20190910_IntegrateVector1.png" /></span></P>
<P>Now you choose the best approximation.</P>
<P> </P>
<P>Success!<BR />Luc</P>Tue, 10 Sep 2019 18:29:16 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626098#M187132LucMeekes2019-09-10T18:29:16ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626117#M187134
<P>I agree that its more elegant to replace the for-loop by the summation operator:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B.png" style="width: 338px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/19223i7064C871960CCDD4/image-dimensions/338x216?v=v2" width="338" height="216" role="button" title="B.png" alt="B.png" /></span></P>
<P><LI-USER uid="14826"></LI-USER> </P>
<P>We should not assume that the X-values are equidistant.</P>
<P>In case of the data in the sheet, most x-values are 10^-4 but just very few have the distance 2*2^10^-4.</P>
<P>Other datasets <SPAN class="tlid-translation translation"><SPAN class="" title=""> might have bigger differences, though.</SPAN></SPAN></P>
<P> </P>Tue, 10 Sep 2019 20:30:27 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626117#M187134Werner_E2019-09-10T20:30:27ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626123#M187135
<P>Out of curiosity I implemented the different integration methods Luc had shown as functions and compared their results to the result of the trapezoid integration.</P>
<P>Apart from the spline interpolation Lucs methods work best if the values in abscissa vector X are (nearly, mostly) equidistant.</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="B.png" style="width: 561px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/19236iD615F6AF2093EFF0/image-dimensions/561x338?v=v2" width="561" height="338" role="button" title="B.png" alt="B.png" /></span></P>
<P>Worksheet in MC11 format (so Luc can make his own tries with the original data) attached.</P>Wed, 11 Sep 2019 08:51:46 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626123#M187135Werner_E2019-09-11T08:51:46ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626155#M187137
<P>Thanks hugely for the help to all of you guys, it's much appreciated - lots of learning tips and useful knowledge for the future.</P>
<P> </P>
<P>I understand the maths and engineering behind what I'm trying to do with MathCAD, but have never really been strong in the programming / logic loop mindset. One day I think I'll have it nailed the approach in my mind and then when I come back a few months later to solve a similar problem I've forgotten it again. It's a good thing that this community is here to help!</P>
<P> </P>
<P>Most of the time I end up eventually solving my own problems in MathCAD, just not in an elegant or particularly mathematically efficient way.....</P>
<P> </P>
<P>Cheers again</P>Wed, 11 Sep 2019 07:12:20 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626155#M187137AATaylor2019-09-11T07:12:20ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626312#M187139
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="WE_20190910_Int_Problem.png" style="width: 677px;"><img src="https://community.ptc.com/t5/image/serverpage/image-id/19256i7AF7E96C34B5D2B2/image-size/large?v=v2&px=999" role="button" title="WE_20190910_Int_Problem.png" alt="WE_20190910_Int_Problem.png" /></span></P>
<P><img id="smileysad" class="emoticon emoticon-smileysad" src="https://community.ptc.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /></P>Wed, 11 Sep 2019 17:40:01 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626312#M187139LucMeekes2019-09-11T17:40:01ZRe: Direct Integration Problem - MathCAD
https://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626318#M187140
<BLOCKQUOTE><HR /><LI-USER uid="14826"></LI-USER> wrote:<BR />
<P> </P>
<P><img id="smileysad" class="emoticon emoticon-smileysad" src="https://community.ptc.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /></P>
<HR /></BLOCKQUOTE>
<P>Hmm, here a 8388 x 2 matrix is defined, obviously using "Insert-Data-Table".</P>
<P>Looks like this convenient feature which enables to include huge data in the worksheet by copy and paste is not available in MC11!? Can't remember as its too long ago that I used MC11 (and unfortunately missed to register the software for a virtual machine).</P>Wed, 11 Sep 2019 18:09:50 GMThttps://community.ptc.com/t5/PTC-Mathcad/Direct-Integration-Problem-MathCAD/m-p/626318#M187140Werner_E2019-09-11T18:09:50Z