Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Direct Integration Problem - MathCAD

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
09:31 AM

09-09-2019
09:31 AM

Hello All,

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.

I have tried changing TOL to ridiculous values like 1E-50, with no luck.

Any assistance would be greatly appreciated.

Many thanks and kind regards

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
10:07 AM

09-09-2019
10:07 AM

utot works ok as it is for me!

The uvol integral works by using an overbar.

See attached.

Alan

NB I removed the ridiculously low value of TOL.

13 REPLIES 13

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
09:56 AM

09-09-2019
09:56 AM

Re: Direct Integration Problem - MathCAD

I'm not sure what the problem is, but a b-spline works (at least in prime).

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
05:38 PM

09-09-2019
05:38 PM

Re: Direct Integration Problem - MathCAD

Hi Alex, Thanks for the response, much appreciated, although Cspline appears to be working now

Cheers

Cheers

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
10:07 AM

09-09-2019
10:07 AM

utot works ok as it is for me!

The uvol integral works by using an overbar.

See attached.

Alan

NB I removed the ridiculously low value of TOL.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
05:37 PM

09-09-2019
05:37 PM

Re: Direct Integration Problem - MathCAD

Hi Alan,

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...

Thanks for the overbar vectorisation tip - I had missed that detail from the online help example!

Cheers

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...

Thanks for the overbar vectorisation tip - I had missed that detail from the online help example!

Cheers

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
11:18 AM

09-09-2019
11:18 AM

Re: Direct Integration Problem - MathCAD

Without seeing your worksheet...

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?

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.

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...

Success!

Luc

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
05:34 PM

09-09-2019
05:34 PM

Re: Direct Integration Problem - MathCAD

Hi Luc,

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.

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.

If you know a different way using the vectors directly I’d love to know!

Cheers

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.

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.

If you know a different way using the vectors directly I’d love to know!

Cheers

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2019
06:20 PM

09-09-2019
06:20 PM

Re: Direct Integration Problem - MathCAD

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.

Setting the value of TOL to lower values (10^-4 or lower, as you did) __increases__ the chance of the integral NOT converging!

Your approach with U.vol works without vectorization if you use an undefined variable (quickplot) or a range as argument:

As to the trapezoid rule - here is an approach using your raw data:

Worksheet in MC15 format attached.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-10-2019
02:29 PM

09-10-2019
02:29 PM

Re: Direct Integration Problem - MathCAD

This is what I'm talking about.

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.

Now you choose the best approximation.

Success!

Luc

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-10-2019
04:18 PM

09-10-2019
04:18 PM

Re: Direct Integration Problem - MathCAD

I agree that its more elegant to replace the for-loop by the summation operator:

We should not assume that the X-values are equidistant.

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.

Other datasets might have bigger differences, though.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-10-2019
04:48 PM

09-10-2019
04:48 PM

Re: Direct Integration Problem - MathCAD

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.

Apart from the spline interpolation Lucs methods work best if the values in abscissa vector X are (nearly, mostly) equidistant.

Worksheet in MC11 format (so Luc can make his own tries with the original data) attached.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-11-2019
03:12 AM

09-11-2019
03:12 AM

Re: Direct Integration Problem - MathCAD

Thanks hugely for the help to all of you guys, it's much appreciated - lots of learning tips and useful knowledge for the future.

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!

Most of the time I end up eventually solving my own problems in MathCAD, just not in an elegant or particularly mathematically efficient way.....

Cheers again

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-11-2019
01:39 PM

09-11-2019
01:39 PM

Re: Direct Integration Problem - MathCAD

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-11-2019
02:09 PM

09-11-2019
02:09 PM

Re: Direct Integration Problem - MathCAD

@LucMeekes wrote:

Hmm, here a 8388 x 2 matrix is defined, obviously using "Insert-Data-Table".

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).