What causes the anomalies in these graphs and how can they be avoided?

  • Thread starter hddd123456789
  • Start date
  • Tags
    Graphs Mean
In summary, the conversation discusses a method of graphing 2D functions using a grayscale representation, and the possible implications and applications of this method. The method involves calculating g(x,y)=y-f(x) for a given function, and using the resulting value as a measure of brightness in the grayscale graph. The conversation also touches on the challenges and limitations of this method and proposes potential applications in numerical analysis.
  • #1
hddd123456789
92
0
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.)
 

Attachments

  • e^-(x^2).jpg
    e^-(x^2).jpg
    2.1 KB · Views: 421
  • ln(x).jpg
    ln(x).jpg
    2 KB · Views: 479
  • x^2.jpg
    x^2.jpg
    2.3 KB · Views: 395
Mathematics news on Phys.org
  • #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.
 

Attachments

  • 1-divided-by-x.jpg
    1-divided-by-x.jpg
    3 KB · Views: 469
  • sin(x).jpg
    sin(x).jpg
    3.5 KB · Views: 466
  • csc(x).jpg
    csc(x).jpg
    3.9 KB · Views: 438
  • #3
hddd123456789 said:
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.

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.
 
  • #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 exactly 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.
 
  • #5
Stephen Tashi said:
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.

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.
 

Attachments

  • x^2-no-falloff.jpg
    x^2-no-falloff.jpg
    1.1 KB · Views: 444
  • x^2-with-fallof-sin(x times pi) divided by x.jpg
    x^2-with-fallof-sin(x times pi) divided by x.jpg
    8.1 KB · Views: 504
  • x^2-with-fallof-sin(x).jpg
    x^2-with-fallof-sin(x).jpg
    8.1 KB · Views: 485
  • #6
conquest said:
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 exactly 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.

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.
 

Related to What causes the anomalies in these graphs and how can they be avoided?

1. What is the purpose of these graphs?

The purpose of these graphs is to visually represent data in order to better understand patterns, trends, and relationships between variables.

2. How do I interpret the data in these graphs?

To interpret the data in these graphs, look at the labels on the axes to determine what is being measured. Then, look at the data points or bars to see the values or proportions for each category. Pay attention to the scale of the axes and any key or legend provided to understand the magnitude of the data.

3. What type of graph should I use for my data?

The type of graph to use depends on the type of data being presented. Line graphs are useful for showing trends over time, bar graphs are good for comparing categorical data, and scatter plots can show relationships between two variables. It is important to choose the right type of graph to accurately represent the data.

4. How can I make my graphs more visually appealing?

To make your graphs more visually appealing, consider using colors and fonts that are easy to read and visually appealing. Use appropriate labels and titles to clearly communicate the information. Make sure the graph is not too cluttered and that the data points or bars are easy to distinguish.

5. Can I draw conclusions from these graphs?

Yes, you can draw conclusions from these graphs, but it is important to consider the limitations of the data and any potential biases. Make sure to also consider any other relevant information and use statistical analysis to support your conclusions.

Similar threads

Replies
20
Views
2K
Replies
17
Views
2K
Replies
8
Views
1K
Replies
3
Views
3K
  • General Math
Replies
7
Views
1K
  • General Math
Replies
3
Views
1K
Replies
1
Views
923
  • General Math
Replies
5
Views
2K
Replies
2
Views
1K
  • General Math
Replies
1
Views
851
Back
Top