Shop OBEX P1 Docs P2 Docs Learn Events
math help - linear and nonlinear functions combined? — Parallax Forums

math help - linear and nonlinear functions combined?

BitsBits Posts: 414
edited 2012-05-11 21:49 in General Discussion
So I am having a difficult time trying to fit a nonlinear function to a linear function. Here is what I think I know so far.

y = mx+b is a linear function we will call (a) and lets just state for simplistic sake that the slope (m) is 2 and B = 0

y = x^2 is a nonlinear function we will call (b)

How would I fit b to a. In other words how can I calculate a point on a graph for the function (b) from the function (a).
Below is my "not to scale" graph of the 2 functions I am trying to merge or show a relationship. Is this a differential equation, what can I google to obtain more clarity? Is this how the Steinhart equation was developed?

I know this can be done because I see it in my head and ill try to state it in words.

looks like the derivative of function (b) shares a point in the function (a)
Both functions share coordinates on the (x) and (y) axis

Hope this makes sice here...and this is what I truly see in my mind. Putting it in words might be rough, here goes.
If i were to take the slope of (a) and invert it I would have a new function that would mirror the original function (a) but track the other direction (in quad 2 and 4). Then replacing the (x) and (y) with this new function while tilting it at some angle i could calculate the function (b) from that?

Attachment not found.

If this can be answered then can I calculate 3, 4, 5 or more functions with respect to each other?

Thanks for helping.

Comments

  • kwinnkwinn Posts: 8,697
    edited 2012-05-05 16:50
    It sounds like you are looking for the value of y at the point(s) where mx + b = x^2. Is this correct?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-05 17:14
    Is the fact (a) is the derivative of (b) just a coincidence or is it part of the reason you think there's a way to fit one function to the other?
  • BitsBits Posts: 414
    edited 2012-05-05 20:31
    Good questions so lets conceptualize things. My thoughts are that if I have 2 functions one being linear (a) and the other a non linear (b) that perhaps I could use function (a) to calibrate function (b). I use the word calibrate because it seem to me that this is how a temperature sensor that is nonlinear, can be made linear. By the way lets treat the functions as analog or random so, the derivative would just be a coincidence; unless its a property that I/we am not aware of currently.

    I see in my minds eye that if I could have an "equation" to solve what I am looking for then perhaps I would then not have to limit myself to just 2 functions and begin expanding upward to 3, or better 10 functions. All these functions will have some interwoven relationship that could be exploited.
  • kwinnkwinn Posts: 8,697
    edited 2012-05-05 22:17
    Perhaps you need to look at a polynomial function. They are frequently used for calibrating instruments and can be used for both linear and non linear calibrations. For example an optical emission spectrometer used to analyze metals uses a polynomial function in the form below to convert the current signal from the photomultiplier tubes to the concentration of that particular element in the sample.

    y = a + bx + cx^2 + dx^3

    where x is the signal measured, a is the offset, and b, c, and d are calibration factors derived by measuring samples of known composition. Once values for a, b, c, and d have been determined x (the signal) is plugged in to the equation to determine y ( the concentration). For linear response only a and b (offset and slope) are used so c and d are zero.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-05 22:41
    There are lots of logarithmic relationships in nature. A logarithmic curve can be converted to a straight line by taking the logarithm of the function. In the good old days there was logarithmic graph paper. By plotting data of a logarithmic nature on "log paper" a straight line would be produced.

    In another from of spectrometry, transmittance is converted to absorbance by a logarithmic equation.


    A = -logT

    The concentration of many solutions have a linear relationship with the absorbance.
  • Mike GMike G Posts: 2,702
    edited 2012-05-05 23:29
    Sounds like transform analysis homework.
  • kwinnkwinn Posts: 8,697
    edited 2012-05-05 23:31
    Good point Duane. There are a multitude of choices for calibration curves. Some are much better choices for a particular application than others. In Radio Immuno Assays there were instruments that let you choose from multiple curve fit algorithms such as linear, polynomial, quadratic, log, log/linear, log/log, etc. No such thing as a universal curve fit algorithm. Spectroscopy is an excellent example of that. The three most common modes (Spark, ICP, and Atomic Absorption) each have different requirements for calibration curve equations.
  • BitsBits Posts: 414
    edited 2012-05-06 08:25
    Darn. I must be putting it in words incorrectly. Sorry but I think I miss lead you all. Here in a little while ill draw up some pictures to see if that will help me explain what I am after. Hold tight
  • Mike GMike G Posts: 2,702
    edited 2012-05-06 09:01
    The integral of DC state is a ramp function. The integral of a ramp function is a exponential function.

    So, yes the functions can be related if one function feeds into another. For example, given two integrator circuits. The first circuit gets DC input. The output is a ramp. Feed the ramp into the next integrator and the output is an exponential curve. The output is a function of the input - transform analysis - waveform analysis - Calculus - Laplace transforms - Fourier analysis .
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-05-06 09:37
    Mike G wrote:
    The integral of a ramp function is a exponential function.
    No, it's a quadratic:
    ∫(ax + b)dx = 1/2 ax2 + bx + C

    -Phil
  • Mike GMike G Posts: 2,702
    edited 2012-05-06 11:14
    Given a step function of 10

    e2 = ∫e1(t)dt = ∫10dt = 10t for t>0
    e3 = ∫e2(t)dt = ∫10tdt = 5t^2 for t>0

    I get the what cha' mean in Bits case.
  • kwinnkwinn Posts: 8,697
    edited 2012-05-07 16:12
    @Bits

    I am a bit curious about what you are trying to accomplish with multiple equations. Any progress with those pictures or did the posts that came after answer your question?
  • BitsBits Posts: 414
    edited 2012-05-08 12:48
    Kwinn I am still working on them, sorry for the delay. My life is getting in the way of my life :)
  • BitsBits Posts: 414
    edited 2012-05-08 13:34
    So here is what I am thinking. Sorry for the crude pictures but you should be able to make this out.

    If we have a basic plot of 2 functions (green) is linear and (pink) is non-linear. The black is the X and
    Y axis keep this in mind.


    Attachment not found.






















    Then we take the linear function (green) and calculating the angle with respect to X and Y (black lines).






    Attachment not found.





















    We could show the relationship between the linear and non linear functions.





    Attachment not found.





















    Now the X becomes the Green line and its inverse (the green lines inverse slope that is) would be Y (i did not put it in this picture sorry).

    Then the nonlinear function could be calculated simply by add or subtracting the angle.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-05-08 13:47
    Sorry, but this still isn't getting me, at least, any closer to understanding what you are trying to do. Perhaps you could give us a concrete example. For instance you mentioned something earlier about temperature. Are you trying to compute temperature from a non-linear thermistor resistance curve? IOW, given a plot of resistance vs. temperature, how do you compute the temperature, given the resistance? Am I close?

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2012-05-08 17:16
    Like Phil I am no closer to understanding what you are trying to do. A concrete example would be great.

    In your first post you have 2 equations for y. Lets call them y1 and y2 as shown below.
    y1 = mx+b is a linear function we will call (a) and lets just state for simplistic sake that the slope (m) is 2 and B = 0

    y2 = x^2 is a nonlinear function we will call (b)


    How are y1 and y2 or the two equations related?
  • BitsBits Posts: 414
    edited 2012-05-08 19:57
    kwinn wrote: »
    Like Phil I am no closer to understanding what you are trying to do. A concrete example would be great.

    In your first post you have 2 equations for y. Lets call them y1 and y2 as shown below.
    y1 = mx+b is a linear function we will call (a) and lets just state for simplistic sake that the slope (m) is 2 and B = 0

    y2 = x^2 is a nonlinear function we will call (b)


    How are y1 and y2 or the two equations related?

    Well in my mind they are related only because they both share the same X and Y system. It should not matter what the numbers are derived from, in other words y1 and y2 are just functions picked from thin air. They don't represent anything yet. I suppose y1 could be a linear value that represents a temperature and y2 could be a sensor that changes with respect to temperature, but lets not confine the functions to this. What I am after is the mechanics to this relationship not necessarily what the functions are.

    Phil and others bear with me please, back post 15.

    I have 2 functions as Kwinn mentions we should remain calling them y1 and y2, Both y1 and y2 are represented using one plot with 2 dimensions X and Y as in picture 1. Now if I know a point on y1 shouldn't I be able to obtain the respected point on y2?

    So say I want to know the value on y2 at X=4 and Y=4 but all I know is the slope on y1. Can i derive this based off of y1 alone?

    My attack would be to tilt the X and Y axis literally (picture 3) until y1 is now horizontal then given the angle that it took to make y1 horizontal I could apply this to the function y2 and solve to find the point. Is this making since or has my writing remained still scrambled?
  • Mike GMike G Posts: 2,702
    edited 2012-05-08 20:17
    Now if I know a point on y1 shouldn't I be able to obtain the respected point on y2?
    It is possible but the functions must be related. y2 = F(x) * y1.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-08 20:22
    Do you want a third equation (y3) such that:

    y1 + y3 = y2 ?

    If so:

    y3 = y2 - y1

    I doubt this is what you're after, but I still don't understand what you're asking.

    You say you don't want to restrict the method to one set of functions, but I think an example with a set of functions would help us understand what you're after.
  • BitsBits Posts: 414
    edited 2012-05-08 20:24
    Mike G

    Are not the functions related simply because they share the same plot and the same dimensions within that plot? I say definitively.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-05-08 20:36
    Bits,

    What is your ultimate objective (i.e. application)? We're having difficulty, because you're using terminology that's not in any usual and familiar mathematical lexicon. If you could just just lay out for us what your application is, we would be much better able to help.

    -Phil
  • BitsBits Posts: 414
    edited 2012-05-08 22:10
    Phil

    I am laying it out for you all lol. I simply want to know how to obtain a point from one function by using a completely different point from another different function.

    This is not for work or homework its a fundamental tool that i want to be able to use in electronics and for mind experiments or physics (I am still looking for the inverse of a gravity wave.) :)

    Ill try the math tomorrow.
  • kwinnkwinn Posts: 8,697
    edited 2012-05-08 22:41
    Well in my mind they are related only because they both share the same X and Y system. It should not matter what the numbers are derived from, in other words y1 and y2 are just functions picked from thin air. They don't represent anything yet. I suppose y1 could be a linear value that represents a temperature and y2 could be a sensor that changes with respect to temperature, but lets not confine the functions to this. What I am after is the mechanics to this relationship not necessarily what the functions are.

    The fact that the numeric ranges of the functions overlap does not necessarily mean that they are related in any way. While y1 and y2 share the same y values, and the y value from one function could be used to calculate the corresponding x value for the other function that does not always mean there is a true relationship between them beyond that overlap.
    Phil and others bear with me please, back post 15:

    “Then the nonlinear function could be calculated simply by add or subtracting the angle.”

    No, I can't see how that could be. If there is a relationship between them the calculation would be more involved than adding or subtracting an angle, and would be different for each relationship.

    I have 2 functions as Kwinn mentions we should remain calling them y1 and y2, Both y1 and y2 are represented using one plot with 2 dimensions X and Y as in picture 1. Now if I know a point on y1 shouldn't I be able to obtain the respected point on y2?*

    Of course you can. Any point on the y axis is the same for both functions. Knowing the y value lets you calculate the x value for both functions.
    So say I want to know the value on y2 at X=4 and Y=4 but all I know is the slope on y1. Can i derive this based off of y1 alone?*

    Yes. See previous answer.
    My attack would be to tilt the X and Y axis literally (picture 3) until y1 is now horizontal then given the angle that it took to make y1 horizontal I could apply this to the function y2 and solve to find the point. Is this making since or has my writing remained still scrambled?

    Why go to the trouble? Once you know x for one function you can calculate y. Once you know y for one function you can calculate x for the other. This works well when calculating y for the linear function but not so well for the non linear function. That function could have multiple y results for each x input so which one do you use if you are going from the non linear to the linear function.
  • Heater.Heater. Posts: 21,230
    edited 2012-05-08 22:53
    Bits,
    Are not the functions related simply because they share the same plot and the same dimensions within that plot?

    No.
    I simply want to know how to obtain a point from one function by using a completely different point from another different function.

    If there were such a technique the implication would be that we only ever need one function from which everything else can be calculated!

    As far as I know that has not been discovered yet and if you find it there is a Fields medal waiting for you.
  • David BDavid B Posts: 592
    edited 2012-05-09 08:56
    I think you cannot do what you seem to be trying to do because given a function and a set of X values, that function only gives the Y values for its function.

    The reason that another function is called another function is that it makes its own different set of Y values for the same set of X values.

    If, given a set of X values, the first function gave you the Y values for the second function, then they would be the same function.

    If you do math to change the first function until it yields the results for the second function then you basically have converted the first function into the second function, so you might as well just use the second function to start with.

    But - if what you want to do is to approximate the results of the second function using simplified math, then that is an entirely different story. There are approximation methods that can use simplified math to get close to the result of a complicated function, if that's what you want.
  • BitsBits Posts: 414
    edited 2012-05-11 06:09
    Thank you everyone for the help.

    It appears that what I was after is here. It kind of bummed me out thought since I thought I was going to invent a new math. lol
  • kwinnkwinn Posts: 8,697
    edited 2012-05-11 21:49
    Sorry you missed your chance at math fame.

    The functions you were trying to explain are interesting by themselves and used quite often in the calibration of instruments to perform the conversion of the measured signals to the calibrated output in the desired units.
Sign In or Register to comment.