Register to reply 
How to create a simple mathematical model! 
Share this thread: 
#1
Dec1012, 12:02 PM

P: 44

Hello,
I am really not very good with math... over the years, I totally lost it. But today, it caught up with me... LOL! I hope someone can help me. In my spare time I am fiddling around with proximity sensors. I have a proximity sensor that accepts 135 steps. Therefore, when I am at step 135, the sensor is able to detect an object 0 inches away. When I am down at step 0, the sensor is able to detect an object at 135" away which is the maximum distance. So as you can see the higher the steps, the shorter the distance an object can be detected by the sensor.The lower the steps the further the object can be detected by the sensor. The problem is that the relation is not linear, its exponential???? Therefore I need to make a relation between the number of steps and inches. Please view attachment for an example of the curve set by the steps vs the distance! Here are some definite coordinates that I measured: (0, 120) (10,75) (35,40) (70,15) My question is, how can I develop a mathematical model (formula) so that just by looking at a step value I would be able to calculate the respective distance without looking at the graph? Thank you all for your help. 


#2
Dec1012, 02:39 PM

P: 907

The graph that you have drawn looks like a rescaled circle (i.e. an oval or ellipse) with vertical and horizontal tangents at (0,120) and (135,0) respectively.
If one hypothesizes that the center is at (135,120) and that the distance metric in the x direction is scaled down by a factor of 120/135 then a possible equation is: (120/135 (x135))^2 + (y120)^2 = 120^2 You are probably better served by starting with a physical rationale for a curve of a particular form, parameterizing that curve in terms of several numbers and then performing a regression to see what set of parameters makes the resulting curve best fit your measurements. 


#3
Dec1012, 06:47 PM

P: 44

hi jbriggs444,
I am wondering how you picked this formula. I tested it and it works... okay, I just picked this curve at random. I simply wanted to see how one would create a mathematical model. But by what u are saying, every type of curve has its unique characteristics. I will come back with the actual curve the sensor actually produces. thanks so much for your help! 


#4
Dec1112, 07:13 AM

P: 907

How to create a simple mathematical model!
I picked the curve type by eyeballing it. It looked like a circle tangent to the x and y axes and centered at (135,120).
Of course, that's impossible. But it could be a slightly flattened circle. The formula for a circle centered at (i,j) of radius r is (xi)^2 + (yi)^2 = r^2 A circle centered of radius 120 centered at (120,120) is then (x120)^2 + (y120)^2 = 120^2 Scale up the x axis by a factor of 135/120 and this becomes (120/135 (x135))^2 + (y120)^2 = 120^2 Now, by my count you are fitting a curve to seven data points: (0,120), (10,75), (35, 40), (70,15), (135,0), an assumption that the slope is infinite at (0,120) and an assumption that the slope is zero at (135,0). There are infinitely many curves that fit those seven data points. If you can pick a particular family of curves there will be a family member that best fits the data. The trick is picking the right family. If you pick the wrong family of curves you can wind up with something like "epicycles". That was an attempt to model planetary motion as circles within circles within circles. Add enough layers and enough parameters and you can always fit the observed data. But switch to using ellipses as the model and you can fit the data with only a couple of parameters. One measure of a good model is one that can fit the observed data with a minimum number of adjustable parameters. 


#5
Dec1112, 12:53 PM

P: 44

Hello jbriggs444,
Okay, I have not had the time to really look at your last post yet... But I will do so as soon as I can. In the meantime I have remeasured the values from the sensor and you may view the actual values in the new attachment below. Now my question is, in which category of curves does something like this fall in!!! I would have to modify your equation a little I suppose... Please take a look at it and let me know if I can still use your equation!!! Tonight, when I get home, I will reread everything and try to figure it out... But I still need your help, because I am sure I will have some relative questions! Thank you so much r 


#6
Dec1112, 06:15 PM

P: 44

a little confused about the math. in the following link what is x and y values???
(x9)^ + (y6)^ = 100 ??? http://www.mathwarehouse.com/geometr...facircle.php by visual analyses I know x should be 8 and y should be 0. but if h and k are the x/y coordinates of the center of the circle what does x and y values mean??? confused? 


#7
Dec1112, 07:20 PM

HW Helper
P: 929

You have a classic curve fitting situation. You have a number of data points and want to know the 'best' equation that represents the data points. The best way to do this is to already know the type/family of equation, ideally based on the physics of the problem. Otherwise, there is very little basis to choose the equation/model except by looking at the data and making intelligent guesses based on the shape. That's exactly what jbriggs444 did. The example data you provided looked like a circle. In the second case, it's not clear that a circle is an appropriate model (my guess is no). Choosing a model isn't trivial. There are curve fitting programs out there (google searches would find them) that will check a variety of equation types and determine the best fit among the equations it tries, but that may or may not provide a satisfactory result.
The second most important thing is to understand why you want a model of the data points. Is it for integration, interpolation, extrapolation, or something else? I'm guessing it is either for interpolation (i.e. reading between existing points) or extrapolation (i.e. predicting values outside the range of data you have). If you want to extrapolate, you need to be careful because extrapolation is highly dependent on the model you use. Interpolation is much safer and is far less dependent on the model used. If you really have no idea what kind of model to use based on the physics, the easiest is to use a polynomial, based on the data you show. You can either fit a polynomial to exactly go through each point (could give strange results if the data doesn't fit very well), or a least squares fit of some sort with a low order polynomial. You could also fit cubic splines through all of the points. As jbriggs444 already stated, there are actually infinitely many functions that could be used to fit the data. If all you want to do is interpolate, it's probably safe to find a curve fitting program on the web and try low order polynomial (2nd or 3rd order) least squares fitting. If you want to extrapolate, I'd try very hard to find a relation from the physics of the problem. Otherwise you'll likely be disappointed in the result. P.S. the last plot you posted is missing 150 on the vertical axis. 


#8
Dec1212, 11:40 AM

P: 44




#9
Dec1212, 12:14 PM

P: 44

x^ + 2ax + a^ Please view better curve attachment. After all the vertex seems to be (38, 130)! In school I remember doing soooo many of these completing the square, polynomials, quadratics and so forth... But like many students we were always given an equation and asked to solve for 'x'. Now, in my case here, I have to work backwards in providing that equation!!! or mathematical model... and this is what confuses me!!!! Thank you for all help! 


#10
Dec1412, 11:31 AM

HW Helper
P: 929




#11
Dec1412, 11:51 AM

P: 44

I have Excel 2010 and it has curve fitting functions that are straightforward to use:
I have excel... under which menu??? I don't know if learning matrix, transpose, inverse, solving a set of linear equations would be easier to do then have excel do it for me.... Telling someone to use excel to do this is still quite complicated... Excel asks to select a function out of a hundred or so functions... still not easy to do!!! 


#12
Dec1612, 03:57 AM

P: 17

simpComp, these are the instructions of fitting a line in Excel 2010:
First fill two columns with both your observation values. Then, select both columns and go to InsertScatter and click the first type. Now you need to fit a line on those points: Click the graph and go to Chart Layout and select the type that has a "fx" symbol. You got a linear fitting by default. To change it, you need to click the line, then right click and go to Format Trendline... There you can choose the line that fits best to your data. 


#13
Dec1612, 03:13 PM

HW Helper
PF Gold
P: 2,786

EDIT: See the next posting, that no use of any matrix nor linear algebra were necessary.
My thoughts are that the shape is part of either an ellipse or a circle, and you could form your system of equations from whichever points you wish and use a graphing Calculator to solve the system (as a matrix) for the unknown constants or coefficients. EDIT AGAIN: Part of those thoughts are not needed. 


#14
Dec1612, 08:50 PM

HW Helper
PF Gold
P: 2,786

SimpComp,
Your original graph really looks like an ellipse portion. You can use simple information about a repositioned ellipse to find all the values you need for the standard ellipse equation. Refer to almost any Intermediate Algebra book. You have a point (0, 120) and you expect a point (135, 0). You see how they may be tangent to the x and y axes. Your long ellipse axis is the horizontal one, so a=135, and b=120. If you look where the tangency points are directed from, the tangency lines perpendicular to these tangency points should meet at the center of the ellipse, at (135, 120), your (h, k). Standard Ellipse, moved to center (h, k): ((xh)/a)^2 + ((yk)/b)^2 =1 Fitting to your graph: ((x135)/135)^2 + ((y120)/120)^2 = 1 I tried testing some of your points against this model, and the results are good. (10, 75): ~0.998 (35,40): ~0.993 (75, 15): ~1.04 Notice that Linear Algebra was not needed for this elliptical fit. 


#15
Dec1612, 09:08 PM

P: 44

Thanks! So, I followed your instructions and I got the following graph as shown in the attachment showing the Excel spreadsheet. So it seems that the million dollar equation that I have been searching for is: y = 0.026x^2 + 1.928x + 90.96 I was off with the middle sign trying to do it as: y = ax^2  bx + c ???? How is one supposed to know that the middle sign would be a "+" instead of a ""?? Any how, based on my other attachment, the calculated values from Excel's equation seems to be a little off. I did it for two coordinates and in each one the answer is off by approximately 1.5?? Is this normal??? Is it because of truncated precision in the decimal numbers... If so is there a way to increase this precision? Also, in the graph generated by Excel, what is R2? Thanks for your help!!!! Also, thank you all for your help, it is much appreciated! 


Register to reply 
Related Discussions  
Is it possible to create an earthquake model  Earth  6  
COMSOL example model results do not match with Mathematical Model  General Physics  1  
A mathematical model for this simple problem?  Calculus & Beyond Homework  4  
Mathematical Model of a Wind Tunnel Model  Aerospace Engineering  1  
How Do you create a ball n stick model?  Biology, Chemistry & Other Homework  5 