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

14-Alexandrite

## Defining a Curve

Hello to all,

I am interested to know if it is possible to mathmatically define a curve as a function. i.e. if I have an xy plot which I have created a curve for i.e. a polyfit or similar. Is it then possible to get MathCAD to define that plot as a function of x? i.e. if I have a polyfit line (which I understand to essentialy be an extrapolation of the xy plots themselves) can this polyfit line be defined as a function i.e. y(x)?

Thanks,

Andy

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:awibroe)

Here is a sheet in Prime 3.0 format.

Hope it helps.

To use the function without the data availabe you would copy simply the "coeffs" vector (set Prime to show more decimals for better precision) and assign it a variable "coeffs" which you then can use for the function definition as shown.

25 REPLIES 25
24-Ruby III
(To:awibroe)

The regress function returns coefficients of the polinomal for the approximation!

14-Alexandrite
(To:ValeryOchkov)

Any advice on how that works?

23-Emerald III
(To:awibroe)

Here you go:

Next, see what happens if you change the value of order..

Success!
Luc

14-Alexandrite
(To:LucMeekes)

Not sure this is quite what I am after.

Say for example I have a series of data and I fit a curve to this as in the attached. What I am now interested in doing is expressing the produced curve as a function of x so that I could not plot the curve without the need to reproduce the data and could simply plot the function. Is this possible?

23-Emerald III
(To:awibroe)

That is why you use the regress function. It provides the coefficients of the polynome:

you can write myf(x)=a*x^2+b*x+c with a=-0.357, b=1.643 and c=2.

Sucess!
Luc

14-Alexandrite
(To:LucMeekes)

Any chance you can show me how that might work in my example?

24-Ruby III
(To:awibroe)

@awibroe wrote:

Any chance you can show me how that might work in my example?

14-Alexandrite
(To:ValeryOchkov)

19-Tanzanite
(To:awibroe)

@awibroe wrote:

Say for example I have a series of data and I fit a curve to this as in the attached. What I am now interested in doing is expressing the produced curve as a function of x so that I could not plot the curve without the need to reproduce the data and could simply plot the function. Is this possible?

Not using polyfit, no. Use polyfitc instead (which replaces regress) to return the coefficients of the polynomial, then use the coefficients to define a function.

14-Alexandrite
(To:RichardJ)

Richard,

Can you show me an example?

A

24-Ruby III
(To:awibroe)

@awibroe wrote:

Can you show me an example?

14-Alexandrite
(To:ValeryOchkov)

I am not sure I am explaining myself. In this outcome you are not left with a function that you could then take to a different worksheet and input to recreate the same curve. here, whilst you have y(x) you have had to define this yourself as opposed to this being derived and is dependant on the other information in the worksheet.

23-Emerald I
(To:ValeryOchkov)

Or

14-Alexandrite
(To:Fred_Kohlhepp)

Hi Fred,

Good to hear from you. In the example above I see that here you are given the coefficients of y in terms of x (or at least that is what I think has happened). How easy is this to take and put into a function that could be reporduced in a different mathcad file?

Cheers,

Andy

19-Tanzanite
(To:awibroe)

18-Opal
(To:RichardJ)

In addition to what Richard has shown, you can also symbolically evaluate the equation poly(x).  This will show you the exact equation being plotted.

Edit: example

14-Alexandrite
(To:RichardJ)

I only have MC Prime 3 any chance you can save in an older file format? I am not seeing how you have created x-1 under the Sigma notation.

18-Opal
(To:awibroe)

@awibroe wrote:

I only have MC Prime 3 any chance you can save in an older file format? I am not seeing how you have created x-1 under the Sigma notation.

It's not possible to back-save to older version in Prime.

What x-1 are you talking about?  I'm not seeing x-1 in any of the examples given.

24-Ruby V
(To:awibroe)

Here is a sheet in Prime 3.0 format.

Hope it helps.

To use the function without the data availabe you would copy simply the "coeffs" vector (set Prime to show more decimals for better precision) and assign it a variable "coeffs" which you then can use for the function definition as shown.

14-Alexandrite
(To:Werner_E)

Thanks everyone I think I have what I was after now! Thanks for taking the time!.

14-Alexandrite
(To:awibroe)

Just leading on from this I have been playing with this again with the most simple of excercised i.e. x=y in the attached. This does work (providing the coefficients are accurate enough i.e. have enough decimals) but I was looking to see if MC can tell you what function the line/ curve is. i.e. in this case you would expect the result x=y or y(x)=x. I guess this is not acheiveble?

19-Tanzanite
(To:awibroe)

No, Mathcad cannot do that. Neither can any other software. There are an infinite number of curves that would fit any data to within acceptable tolerances, so without other information it is not possible to know what "the" curve is.

24-Ruby V
(To:awibroe)

@awibroe wrote:

Just leading on from this I have been playing with this again with the most simple of excercised i.e. x=y in the attached.

I can't see any attachment.

I was looking to see if MC can tell you what function the line/ curve is. i.e. in this case you would expect the result x=y or y(x)=x. I guess this is not acheiveble?

Your guess is correct. As Richard already explained, thats a mission impossible.

When you see this, what would you think, the equation of the underlying function is?

Perhaps we have here a linear process with a few inaccurate measurement results?

Lets reveal the secret - I used the function equation seen in the picture

You may say, that the straight line above wasn't a perfect match anyway - thats correct.

But here are two perfect matches - all six points lie exactly on the curves.

Here we have y=sin(x):

And here is a polynomial of sixth order:

And there sure is an infinite number of other function which include those six points perfectly.

So what should Mathcad return? 🙂

19-Tanzanite
(To:Werner_E)

An interesting, although somewhat irrelevant, thing about the number of possible curves in space is that although there is an infinite number of them, and there is also an infinite number of rational numbers, it can be proven that there are more possible curves in space than there are rational numbers. It can also be proven that although there is an infinite number of integers, there are more rational numbers (this is in fact quite easy to prove). aleph two, aleph one, and aleph zero

23-Emerald I
(To:awibroe)

I intentionally duplicated Val's number to illustrate that polyfitc and regress will create the same numbers.  Richard showed that you can "cut them out," and copy them from one worksheet to another, and the same function definition (from Val or Richard) will develop the polynomial as a function.

Announcements
Top Tags