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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

16-Pearl

## No roots today ?!

Hi MC folks,

I've got this data in which I'd like to find all roots by using the Match function. Problem is that only an incomplete subset of the roots is identified - see attached sheet.

Does anybody has a clue why this happens?

Cheers

Raiko

P.S. The attached sheet is in MC12 but the original has been made by MC15!

1 ACCEPTED SOLUTION

Accepted Solutions
17-Peridot
(To:Raiko)

Here's how I'd find the roots. It would be easy to interpolate, though I've just picked off the value nearest to zero (interpolating on an index number doesn't seem very sensible!)

Alan

29 REPLIES 29
1-Newbie
(To:Raiko)

Hi Raiko,

MC12 doesn't accept the "near" parameter but looks like you need to define what is "near" enough.

I've changed the TOL on your sheet & it finds what it thinks is zero in diminishing ranges.

regards

Andy

23-Emerald II
(To:Raiko)
 Raiko Milanovic wrote:Hi MC folks,I've got this data in which I'd like to find all roots by using the Match function. Problem is that only an incomplete subset of the roots is identified - see attached sheet.Does anybody has a clue why this happens?CheersRaikoP.S. The attached sheet is in MC12 but the original has been made by MC15!

As Andy says, 'near' isn't quite near enough. If you want to leave TOL alone, then you can use 'range' instead of near to set your criteria. However, it's not a particularly effective way of finding the roots (zero-crossing points) because there are quite a few points that are 'near' zero, but don't represent a root. I've attached a crude zero-crossing function to show the difference. I think Richard may have posted something better?

Stuart

5-Regular Member
(To:StuartBruff)
 I think Richard may have posted something better?

I have just been looking through the thread 'Peaks' where you and Richard posted a few nice worksheets, but that was more looking at the extreme values.

I though you had posted a zerocross over function before.

Once again this would require the user to change the TOL settings.

Mike

23-Emerald II
(To:MikeArmstrong)
 Mike Armstrong wrote:I think Richard may have posted something better?I have just been looking through the thread 'Peaks' where you and Richard posted a few nice worksheets, but that was more looking at the extreme values.I though you had posted a zerocross over function before.Once again this would require the user to change the TOL settings.Mike

Hi Mike,

Thanks for the memory jog. I may very well have posted variants of a zero crossing function before, but I have a memory like a ... one of those things that swims around in a wadjamacallit. Hence, I often find that it's quicker just to reinvent the wheel and let the circumstances dictate the quality of that wheel - normally (as in this case) a rough and ready function will do the essential job of looking at the principle.

Stuart

5-Regular Member
(To:StuartBruff)
 I may very well have posted variants of a zero crossing function before, but I have a memory like a ... one of those things that swims around in a wadjamacallit.

Mike

16-Pearl
(To:StuartBruff)

Hi Stuart,

thank you for the function. It doesn't find all zero points but it is not sensitive to TOL settings either.

Raiko

23-Emerald II
(To:Raiko)
 Raiko Milanovic wrote:Hi Stuart,thank you for the function. It doesn't find all zero points but it is not sensitive to TOL settings either. Raiko

Which ones did it miss, Raiko? Did you update j (and hence Q) for the new values? I've had a quick glance and plotted the zerocross results against Y, but can't see anything obvious (I am, however, working on a requirements spreadsheet at the same time, so I'm probably not paying too much attention - I do hate it when work gets in the way of play! 🙂 ).

I've added a minor variant of zerocross that picks index of the element nearer to zero.

Stuart

19-Tanzanite
(To:MikeArmstrong)
 I have just been looking through the thread 'Peaks' where you and Richard posted a few nice worksheets, but that was more looking at the extreme values.

That could be easily adapted to find the zero crossings. Take the absolute value of the data, and the zero crossings will be minima. If there are also other minima (although in the case there aren't) they could usually be eliminated by thresholding the results. Since Alan's solution is much simpler and works I think I'll save myself the effort though!

3-Visitor
(To:Raiko)

Mathcad's help says "near" finds the closest point, but it isn't acting that way, it finds all points in a range.

Rather than chante tol, if you divide by 10, you find multiple values near every corssing, zoom in to see th points.

Do you want to find actual data points, or interpolated roots?

5-Regular Member
(To:wayne)
 Mathcad's help says "near" finds the closest point, but it isn't acting that way, it finds all points in a range.

Good spot Wayne,

The description of near is;

• "near" - returns the value closest to z

Have a look at the attached worksheet. The functions have built in vectorization and therefore return the matching criteria for all values of z which are within the specified TOL.

Mike

Hello Mike,

that's exactly what I thought. I was hoping for some background routine within Match that would sort out the "closer" from the less closer data points, but MC doesn't behave like that.

Raiko

5-Regular Member
(To:Raiko)
 Hello Mike,that's exactly what I thought. I was hoping for some background routine within Match that would sort out the "closer" from the less closer data points, but MC doesn't behave like that.

The only way around that is like Stuart suggested use the "range" instead of the "near". I still don't see the big issue changing the TOL though.

Mike

Mike,

changing TOL isn't exactly a hard task but it produces false positives in some cases. I had to use fraction powers in TOL in order to get a decent match.

Raiko

3-Visitor
(To:Raiko)

Raiko,

Sorry, in my last post I suggested dividing by 10,

Of course I meant multiply by 10 or 100 or 1000, instead of changing TOL (or perhaps in addition to)

Also, is there an expected error range in the data, is so, any point that comes within the error of the 0 line could be said to be a root, so in fact the roots are acutally ranges themselves? Which is why I asked if you want to deal directly with the data or with a curve fit. You could fit that data really well with a Fourier analysis.

16-Pearl
(To:wayne)

Hello Wayne,

the data in the spreadsheet is already smoothed. I figuered it might be way easier to work on that.

Cheers

Raiko

23-Emerald II
(To:MikeArmstrong)
 Mike Armstrong wrote:Hello Mike,that's exactly what I thought. I was hoping for some background routine within Match that would sort out the "closer" from the less closer data points, but MC doesn't behave like that.The only way around that is like Stuart suggested use the "range" instead of the "near". I still don't see the big issue changing the TOL though.Mike

Just to be clear, I said that "range" would be better than "near" for bounding data values. However, I also said that a zero-crossing routine would be the preferred option as proximity doesn't guarantee a crossing. Furthermore, it will miss zero-crossing pairs that lie outside of the bounds (ie, large differential).

The zero-crossing function that I cobbled together does detect all of the crossing points - as zeros are the goal, it also includes any zero-valued points that the curve moves to or away from, even if the curve is single-sided. It won't pick up long sequences of zeros.

I've rechecked and it seems to pick up all of the zeros - I don't understand why Raiko said it didn't. I notice that there is a mistake in my second posted worksheet as it doesn't include the mod operator around the values when checking for nearest-to-zero ... one of these days I am going to learn to save before I post 😞

Stuart

5-Regular Member
(To:StuartBruff)
 one of these days I am going to learn to save before I post 😞

Just ask!!!!!! I have most of sheets saved (one's worth saving that is) posted on the forum in the last couple of years.

Mike

23-Emerald II
(To:MikeArmstrong)
 Mike Armstrong wrote: one of these days I am going to learn to save before I post 😞Just ask!!!!!! I have most of sheets saved (one's worth saving that is) posted on the forum in the last couple of years. Mike

Sorry, Mike. What I meant was my deplorable habit of posting a worksheet without having saved the latest update ... ] Still, now I have access to M15, I'll have a look at Alan's worksheet. (I've only got M13 at work and my home usage is adversely affected by the fact that Officer Commanding Household usually has other things she wants me to do before I can play).

Stuart

5-Regular Member
(To:StuartBruff)
 my home usage is adversely affected by the fact that Officer Commanding Household usually has other things she wants me to do before I can play).

Remember the saying........

All work and no play......

Mike

16-Pearl
(To:StuartBruff)

Stuart,

everywhere the same sad story. There must be a reason why evil alien overlords are depicted as sexy women 😉

Have a nice weekend

Raiko

I just logged the documentation issue for Mathcad 15 and Mathcad Prime 1.0.

Mona

5-Regular Member
(To:mzeftel)

Cheers Mona,

Mike

16-Pearl
(To:wayne)

Hello Wayne,

do I understand you correctly that you're proposing to find the two nearest points to zero (one positive the other negative) and then interpolate in order to find the crossing point?

This would be fine. Do you know of a function or routine which manages that?

Raiko

17-Peridot
(To:Raiko)

Here's how I'd find the roots. It would be easy to interpolate, though I've just picked off the value nearest to zero (interpolating on an index number doesn't seem very sensible!)

Alan

16-Pearl
(To:AlanStevens)

Thank you Alan, you made my day

Such an easy way to determine them. Wonder why I didn't come up with this 😉

Cheers

Raiko

3-Visitor
(To:Raiko)

Raiko,

Alan's method is way too simple, we can't have that.

By interpolation, I was really getting to what you doing with the data, do you need to fit meaured deta and find those roots or do you really want the data point that is closest to zero.

If you wanted interpolated data between the nearest point above and below, I suppose a simple modification of Alan's program would work.

17-Peridot
(To:wayne)
 Wayne Reid wrote:Raiko,Alan's method is way too simple, we can't have that.

If you are looking for complications I should, perhaps, note that, strictly, my method detects crossing points - it won't pick up a maximum or minimum that just touches zero!

Alan

Message was edited by: AlanStevens On second thoughts, it will if one of the two data points is exactly zero, but not if the zero lies between two small positive or two small negative values.

5-Regular Member
(To:AlanStevens)
 If you are looking for complications I should, perhaps, note that, strictly, my method detects crossing points - it won't pick up a maximum or minimum that just touches zero!AlanMessage was edited by: AlanStevens On second thoughts, it will if one of the two data points is exactly zero, but not if the zero lies between two small positive or two small negative values.

I am missing the point here?

I thought that was the original request????

Mike

5-Regular Member
(To:wayne)
 Alan's method is way too simple, we can't have that.

Simple is always good, well for me it is.

Mike

Announcements
Top Tags