0
$\begingroup$

I want to design a function that satisfies the following:

generally speaking, $f(x) = y$

$$f(5.51) = 1$$ $$f(95.31) = 200$$

How can I go about designing the function to satisfy these requirements?

  • 0
    Hmm, what kind of shapes would you like it to be? Is it convex/concave? Polynomial? Any symmetries? Or would you like to fit the data into certain functions? [Always hit ENTER...]2012-08-20
  • 3
    Next time please use TeX formatting as well as refraining from possibly offensive language.2012-08-20
  • 0
    Sure thing. I'd like this function to be exponential, or at least that general shape.2012-08-20
  • 0
    The trouble is, the two "rules" f(5.51) = 1 and f(95.31) = 200 are obviously useless when x is not 5.51 or 95.31. Do you want us to guess what y is when x = 5.5? There are too little data points to use [(non-linear) regression analysis](http://en.wikipedia.org/wiki/Regression_analysis#Nonlinear_regression).2012-08-20
  • 0
    I seem to be confusing people about the purpose of my question. Basically, I'm designing this function so I can visually lay out elements in a web form such that they are aesthetically pleasing as well as precisely fitting numerical requirements. Whether or not that knowledge will please or enrage you is beyond me.2012-08-20
  • 0
    @nbubis: If "brainfart" offends you, then you need to be less easily offended.2012-08-20

1 Answers 1

2

If you want a function of the form $f(x)=a e^{bx}$ then simply solve for $a$ and $b$ using your data points.

If you want a polynomial function of degree $n$ then you'll need $n+1$ data points. With two data points, you get a polynomial of degree 1 (at most).

  • 0
    Awesome. That's great. Unfortunately I can't vote this solution up because I don't have enough reputation. I'm also now wondering how could I do the same thing using a polynomial?2012-08-20
  • 0
    @Dan, I've edited my answer.2012-08-20
  • 0
    The last statement sounds good, y=mx+c will suffice here, (m,c are to be resolved from the given two conditions).2012-08-20
  • 0
    Ah, cool. Let's add $$f(40) = 10$$2012-08-20
  • 0
    I mentioned "the given two conditions". With n given conditions, we need n degree polynomial, right?2012-08-20
  • 0
    With 3 conditions, wouldn't that mean we need a 2 degree polynomial? And is non-linear regression analysis the general answer to this question?2012-08-20
  • 0
    @Dan: You *can* accept the answer, though (which will increase your reputation).2012-08-20
  • 0
    My question hasn't been fully answered yet, but sure, might as well.2012-08-20
  • 0
    @Dan $n$ data points can be exactly matched by a unique polynomial of degree no greater than $n-1$. Regression analysis can do different things, but it is **not** guaranteed that the resulting curve hits your data points -- or any of them at all. The act of finding a curve that goes through each point exactly is called *interpolation*; the act of finding a curve that gets really as close as possible to *all* data points is called *regression*. You need to provide more details on what you want; with three data points, one can fit an infinite number of curves through or near them.2012-08-20
  • 0
    Thanks, Ed. I ended up using exponential interpolation using my boundary points because I wanted them to be exact. The ones in the middle only had to be close.2012-08-20