4th order Polynomail starting at a desired Point

  • Thread starter Thread starter mrmonk7663
  • Start date Start date
  • Tags Tags
    Point
mrmonk7663
Messages
8
Reaction score
0
Hello. I need some help. I am not a math wizard by any means, but I find myself in need of math right now. I have a set of X and Y Values. My X values are from 0-5 (128 values between 0 and 5)and my Y values are from datalogs. So basically, I have datalogs of information corresponding to the Y data. I use the data log to plug in the Y data. I graph the X and Y Data, and then I run a 4th order polynomial against the graph. This works well for what I am using it for, with one exception. In the first few cells the polynomial returns negative numbers.

So...My question is this. How can I force the polynomial to start at a given X value...so that when X is whatever Y will be 0? I have heard that what I need is Lagrange multipliers...but I have no clue how to use that. I need to find a way to do this in an EXCEL spreadsheet if possible. Weighting the data at the desired starting point will NOT yield the results I want. If you can help, please do. I can provide a base set of X and Y Values as well if it helps clarify things. I also have the Matlab program, and I see it has many polynomial functions in it...but unfortunately I don't know how to use the program...and even if I did, I need this to work in Microsoft Excel.

Sorry if my post is scattered or lacks full details. Until 3 weeks ago, I didn't know what a polynomial was :)
 
Physics news on Phys.org
Anyone? I really need help with this. It has a project dead in the water until I can get it worked out. Thanks!
 
You say that the X:s lie in the interval [0,5]. Do you want to fit a 4th degree polynomial to the data such that the polynomial is nonnegative on all the entire interval [0,5], or is just in the left endpoint 0 (or some other particular point) that Y-value is required to be negative?
 
Even more basic, why do you specifically need a fourth order polynomial? What type of data are you collecting?
In general, the higher the order of the polynomial used for the data fit, the more likely your fit will have some undesirable oscillations, like what you are experiencing.
 
  • Like
Likes 1 person
Ok. What I am doing is generating a mass air flow sensor curve. So My X axis is 0-5V. My ECU has 128 hardcoded voltage points for the X-Axis. My Y Axis is the grams per second of air. The ECU obviously has 128 points that correspond to the voltages for the grams per second of air.

I have a datalog of 20,000 lines that provide a given g/s of air at a voltage point. Currently my spreadsheet calculates the deviation of this data based off the Air Fuel Ratio, and corrects the g/s at a given voltage in order to achieve the target AFR.

So, the data is evaluated, the corrected Y values are found, the corrected Y data is plotted agains the Voltage range, and a 4th order polynomial is used in order to get the best fit within that curve.

4th order is widely used for this type of work. 3rd order I have used as well, and while the results are slightly different, it is less than 1 percent difference at any given point on my curve.

My data logs can not capture data below around .43 volts as the engine idle prevents me from seeing the lower air flow voltages (startup voltages during cranking and the time that the car starts from 0 rpm to idle) Because of the lack of recorded data below .43 voltages,there is nothing to anchor the curve. I have tried artificially adding weight to the low end and it skewed the high end data.

I have a known good starting X value where Y=0 that was obtained from the manufacturer. Given that information, I would like to force the curve to start at that known good X value with y=o at that point, so that I can see what the overall effect on the curve will be.

Using the data as is with the 4th order polynomial gives working results, but I believe it would be better if I could force the curve to start where I wanted via Lagrange Multipliers. I hope that makes sense. The data the polynomial calculates for the areas where I have datalogs is very accurate. The low end of the curve is the problem, because it is skewing the top end of the curve (also where no data has been datalogged) By anchoring the low end we hope to get a better resultant curve on the top end.

I am posting a spreadsheet with the XY data. Currently, the values that you see 0 for the Y range were actually returned as negative results (which is normal of maf curves, except the ECU can not read negatives so they are converted to 0s.)

So to recap, given a range of XY data points, I need to force the polynomial to begin at a desired X value having y=0 at that point.

Thanks
 

Attachments

mrmonk7663 said:
I have a known good starting X value where Y=0 that was obtained from the manufacturer. Given that information, I would like to force the curve to start at that known good X value with y=o at that point, so that I can see what the overall effect on the curve will be.
Then why don't you just add this X-value with Y-value 0 as an extra data point?
 
That doesn't work. I have already tried that. The curve starts positive from the get go that way, and that is incorrect. I need the curve to return its first positive value at a specified point.
 
So what you want is a 4th degree polynomial which has the same (positive) value att two given points?
 
No. If you look at the excel sheet you will see the 0-5v X values. You will also see the y values. I want the polynomial to start at .27v and equal 0 there. .31 I want to be the first positive number based off of the datalogs. All of the other calculations from the polynomial will be based off the datalogs as well. I just need the polynomial to start at .27v and have y=0 there. I have been told the only way to do that correctly is with Lagrange multipliers.

Erland said:
So what you want is a 4th degree polynomial which has the same (positive) value att two given points?
 
  • #10
Here is the pdf file per PM request.
 

Attachments

  • #11
Thank's for the file. But I can't figure out what to do. You mentioned Lagrange multipliers, and the only way I can get this advice to make sense is something like this:

Use Lagrange multipliers to minimize ##f(a,b,c,d,e)=\sum_{i=1}^n(ax_i^4+bx_i^3+cx_i^2+dx_i+e-y_i)^2## (as a function of ##a,b,c,d,e##), subject to the constraint ##ax_k^4+bx_k^3+cx_k^2+dx_k+e-y_k=0##, where ##(x_k,y_k)## is the first data point with ##y_k>0##.

This gives the 4th degree polynomial ##P(x)=ax^4+bx^3+cx^2+dx+e## which best fits data in the least square sense, with the constraint that ##P(x_k)=y_k##. This gives no guarantee that ##P(x)\ge 0## for ##x<x_k##, though.
 
Last edited:
  • #12
The original poster joined to ask a question I have been trying to figure out the answer to. To break the question down simply and give an example at the same time:

I have derived a polynomial equation of best fit using least squares.

f(y) = 0.0564x^4 + -0.7879x^3 + 12.3231x^2 + -21.5043x + 11.79753

Due to the nature of how the Mass AirFlow (MAF) Sensor in a vehicle works, we only use positive x and y values. x = Sensor Voltage (Ranging from 0 to 5) y = Mass Airflow measured in grams per second. On a vehicle/sensor specific basis the positive values of the curve must begin at a specific sensor voltage.

Using the function above i would like to derive a new 4th order polynomial equation with the curve passing through x = .31 y = 0

I can then use the resulting function to determine y (airflow) at each given x (voltage) in my 0 to 5 range. Any negative or positive values from 0 to .30 volts can easily be ignored, however I need y to = 0 at .31

Thank you in advance for your help.
 
  • #13
Any help would be appreciated more than words can express!
 
  • #15
No I thought it was the same as the multipliers honestly. I'll get my buddy darkproximity to have a look at it and see what he thinks. Thanks.
 
  • #16
Lagrange interpolation is hardly meaningful here. It gives a 4th degree polynomial only if there is only 5 data points.
 
  • #17
Subtract the offset from your x data, then fit a curve containing only terms x, x^2, x^3, x^4 (i.e. no constant term). Since all the terms are zero at x=0 it automatically goes through y=0.
 
Back
Top