1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

What do these graphs mean?

  1. Jan 14, 2012 #1
    Holy...I have to retype my entire post *sigh* lovely.

    Ok, let's try a shorter version. I've had a question that my engineering cousin was unable to help me with (perhaps too busy). I'm a programmer first, and barely remember Calculus I so we're both on the same page.

    Let's start with y=x. If we subtract x from both sides, we get y-x=0. Ok, but let's generalize this. Let's recognize that y=x is the same as y=f(x), so we may rewrite y-f(x)=0. Ok, now generalizing further, let's say g(x,y)=y-f(x). There's a particular reason why I made this formulation (though I originally never bothered to formalize it to as much as I've done here).

    First off, a simple algorithm for graphing a 2D function might go something like this: you get the position of the current x position on the graph that you are, well, graphing, and run that through f(x), get the y value, and then plot a line from the last point to the new point, and repeat until you have graphed the whole curve.

    Now, being a programmer, a thought occurred to me: what if you went in reverse? What if you went pixel by pixel, and instead of calculating f(x), you use the x,y coordinates for that pixel and calculate g(x,y) as per two paragraphs above. So instead of, for example, calculating f(x)=x^2 for a particular x coordinate, you would instead calculate g(x,y)=y-x^2 for a point represented by a pixel on the image. The value that you get for g(x,y) would in turn be expressed as brightness on a grayscale "plot" of the graph. As far as I can tell, this really just amounts to a 3D plot of our standard 2D functions.

    So finaaaly, (just copied post) here's the question: what do the attached graphs mean exactly? The typical curve that we are used to would lie where the bright regions lie in these graphs. What's interesting to me is noting the nodes in the graphs, particularly the sin(x) and ln(x) curves. What really get's me is that in all the graphs, there're these "ghostly" shades under/side of the traditional curves. It is most clearly apparent in y=x^2, where you can see (if your brightness/contrast is high enough) a dark "shadow" looking thing under the parabola. Am I correct in thinking this has something to do with imaginary numbers? Either that, or it seems to almost be some sort of probability curve for the 2D function, as if f(x)=x^2 only shows the curve where there exists a 100% probability of a point existing on it. On the other hand, the 3d graphs perhaps show the full gradient of probabilities for every point on the functional grid?

    Well, I could keep going, but I'll wait for some feedback. I'll attach more in the next post, but for now, from left to right is the Gaussian y=e^-(x^2), y=ln(x), and y=x^2.)

    Attached Files:

  2. jcsd
  3. Jan 14, 2012 #2
    I've attached some additional graphs.

    From left to right: y=1/x, y=sin(x), y=csc(x).

    The horizontal white line through the center of some of these is just a programming error.

    Attached Files:

  4. Jan 14, 2012 #3

    Stephen Tashi

    User Avatar
    Science Advisor

    I don't understand how you implemented the grayscale. For example, y - x^2 gets larger as (x,y) increases vertically above the point (x,x^2) and it becomes more negative when (x,y) goes further below the point (x,x^2). But are your graphs brighter nearer the point (x,x^2) ? And I only see a gradual change in color on one side of the graphs.
  5. Jan 14, 2012 #4
    First of all these are some nice looking pictures and I would dearly like to know exactly what they are all about.

    I assume white means it' s zero and black means it' s quit a high number. Is this corrrect?

    Also I don' t see a horizontal white line but I see a vertical white line and it' s exaclty where the asymptotes for the functions are !!! So at those point g(x,y) can' t be calculated (since f(x) isn' t defined), so it's not you' re programming skills that caused the error but the function actually misbehaves at those points.

    What my first thought is, looking at the definition of how you made these, that the whiter an area in the picture the smaller the difference between y and f(x). So in some way then you ould say moving (strethcing) the actual graph through these areas makes a smaller difference with the actual graph then dragging them through the others.

    For instance for sin(x) if you drag the parts that are above zero below zero it's a bigger difference then draggin them further above zero.

    This is a bit of an intuition, not very rigourus. Maybe this could have some application in numerical analysis so it could even be there is some approxiamtion scheme that uses pictures like these.
  6. Jan 15, 2012 #5
    To be frank, I don't really understand what you mean about y - x^2 getting larger as (x,y) increases vertically, but otherwise that is a very good question because implementing the actual grayscale was not trivial; I just didn't want to extend the OP to the outer limits ;) (I understood it eventually; response in last paragraph)

    The problem is, while you can have an infinitely scrollable view of a graph's two dimensions, when you're trying to show the 3rd dimension purely by color or in this case in complete grayscale, you have to fit all possible values that coordinates in this dimension can take on and artificially represent them in 256 scales of values. So it is a fairly artificial process and there's no singular solution to the problem.

    I opted for a falloff function with global normalization. By falloff function I mean the same Gaussian function pictured in the first graph. Values that fall within a certain range are maintained by the bell curve, and others falloff to get rid of unnecessary information. Global normalization prevents extreme values, near asymptotes for example, from destroying the clarity of the rest of the graph. The Gaussian function does the normalizing all by itself.

    So, to answer your (correct) suspicions, the left graph below is what the y=x^2 graph looks like without the falloff function. In fact, to show you just how artificial the process of turning it into a 3D representation can be, I can use a different falloff function such as y=sin(x*pi)/x and get the center image. Or I can simply use sin(x) as a falloff function, giving the rightmost image.

    Attached Files:

  7. Jan 15, 2012 #6
    Thanks for the like! And it's the other way around, white means the number is high, as in if it's pure white just think the actual curve would be going through that region. And I don't think the vertical white lines are really showing asymptotes since if they were, the csc(x) image would show repeating of the lines for every asymptote, not just the one in the center.

    Apparently, sometimes it takes asking others what something is for you to find the answer yourself. Anyway, I think I just answered my own question while responding to Stephen: the weirdness in these graphs seems to be coming entirely from the falloff functions. In my attempt to actually bring clarity to the graph, I had to tamper with the actual numbers in it. And this introduced some sort of anomalies that wouldn't be there if they weren't used.

    You can't have both a readable graph following this method and an accurate one it seems.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook