Hi all,

So I made this really basic graphing calculator that draws the form of whatever equation you give it (ex. it can draw a cubic function with axis lines). It almost works perfectly and exactly how I wanted, except for the fact that, for certain x values (and these vary with whatever the “step” variable is set to), the line will randomly jump to the origin and back, making an extremely ugly streak across the graph:

Parabola. (The annoying lines are in purple)

I have literally zero clue why this happens. All I’ve been able to deduce is that they only happen in the positive X side of the graph. Other than that, I have literally no clue.

As for the code, it uses a kind of confusing method that ensures that the screen is always encompassing the graph, so it is a bit long and I would need to include all of it (~100 lines). I can reply with it upon request, but I feel like that would be a gray area with the pasting code rule of this forum. I will however give the part that actually draws the line:

```
for (int i = 0; i < data.length - 1; i++) {
``````
line(data[i][0] * pixelSizeX,
height - data[i][1] * pixelSizeY,
data[i + 1][0] * pixelSizeX,
height - data[i + 1][1] * pixelSizeY);
```

`} `

where `data`

is the 2d array with all the points, and `pixelSizeX`

& `pixelSizeY`

are the relative amount of units that each pixel is worth in their respective axes. (so for example with a `pixelSizeX`

of 2, each pixel is worth 2 units in the X axis) Also, index 0 of the 2nd array in the 2d array is the X, and index 1 is the Y.

Any insight as to how this would happen? Again, I can give you the full code if needed.

P.S. I already added a bit that prints every point on the graph, none of them are a random (0, 0) so these lines shouldn’t realistically appear, as they aren’t in the dataset that is generated; meaning that this must happen in the piece of code above when actually drawing them. I also understand and am sorry that this is sloppy and/or not the ideal way of doing it.