Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Graph editor!

Author
Message
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Sep 2011 09:44 Edited at: 13th Sep 2011 10:59
I did this to learn about all the Java swing gui stuff. Uhh... this is my first complete java application, and I was wondering if you guys could report any bugs.

It's a pretty good editor. There's all of that fancy stuff like graph lines, zooming, panning, you name it!

Mostly it was just a learning exercise. For example, the main panel is an "equation editor" panel. The text boxes where you enter coordinates have to validate the text (to make sure you input a decimal number) and then call an update function on that panel, so that the graphics update. Plus, I decided to test my knowledge and make this whole thing multithreaded - mainly because I hate when an application's UI hangs up because of some calculation going on. The red line (the curve) is calculated in a separate thread than the rest of the stuff.

And then of course we get to the actual input. Accepted operators are:
+ - * / ^ ( ) log() cos() sin()
So an equation like:
(2*x^4+5)^(1/3)/(2+x)
gets parsed fine. If you see the green box next to the equation turn red, that means you entered something it doesn't like. (for example, you can't have negative numbers. Sorry. The best you can do is subtract from zero. "0-sin(x)" is valid while "-sin(x)" is not.)


check it out and tell me about any bugs! It *shouldn't* crash or get stuck up, but parsing the text is kinda hard and I may have missed an infinite loop somewhere.

http://www.neurofuzzydev.com/graphutil.html

screenz:
a function whose left limit approaches a sine curve, and whose right limit approaches an exponential function.



[edit]
also, it would be cool to hear ideas about new features I could add.

I want to keep adding to this as I need to use more GUI stuff. I was thinking about adding support for polar and parametric graphs first off, then moving on to adding variables. It would turn into an incredibly useful utility if you could type in "a*x+b", and have two adjustable sliders labeled a and b show up.

Besides that, there could be stuff like adding LaTeX rendering of equations, adding support for non-functions (the +- symbol, or having multiple functions), aand having cool things like bifurcation diagrams.

Eventually I might get daring enough to add numerical estimations of integrals and derivatives, along with sums, and a crapton of other notation, but that's far off.


Why does blue text appear every time you are near?

Attachments

Login to view attachments
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 12th Sep 2011 12:00
The is quite awesome Neuro Fuzzy. One thing I'd really like that I haven't seen any graphing software do is show where asymptotes are. If you are able to do this I'd be very appreciative.

Oh and if you divide by zero it doesn't throw up an error.

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 13th Sep 2011 01:37
Quote: "Oh and if you divide by zero it doesn't throw up an error"


What happens? Well, I suppose when you're running the equation for every point on the X axis, if you come across a division and the denominator is 0 you just add an asymptote line. I think...

"everyone forgets a semi-colon sometimes." - Phaelax
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 13th Sep 2011 05:40
Quote: "What happens?"

Nothing, the graph just doesn't display any lines, curves etc. Enter in the equation x/0, nothing happens.

Quote: "Well, I suppose when you're running the equation for every point on the X axis, if you come across a division and the denominator is 0 you just add an asymptote line. I think..."

That sounds right and for someone like Neuro Fuzzy who has been able to project 4D julia sets in 3D it shouldn't be too hard.

Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 13th Sep 2011 09:33
Nice one, that's pretty cool.

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 13th Sep 2011 11:09
Aha, I'm working on the asymptotes!

The thing is... it's not easy! I think once I get the numerical estimation of limits down, I can numerically estimate a function's derivative, and then use newton's method or some such thing to estimate the zeros of a function. I'd imagine there would need to be 10 or so calls of f(x) and f'(x) per derivative, and so for complicated functions this would be feasible if there were 10 or so asymptotes. I think the final curve rendering hing will look like this:

1st calculate the point cloud. eg, for every desired x value, calculate f(x).
Then do a first-pass rendering, like what my program is at now.
Then, calculate all the niceties - like asymptotes - so that graphs look nice any not like this. (along with providing dotted lines representing asymptotes. Ideally they'd be highlightable, and you could select them and view their close-to-exact x position.

Since the method for calculating asymptotes needs root-finding, I suppose root finding would be the next big thing.

Also, during all this I'd need to keep an eye out for indeterminate things, like 0/0.


Actually... I take that back... I can't imagine finding the zeros of the denominator would be efficient. What if someone wrote "(x^2+x+1)/(1/(1/(2+9*log(x)^2))+x)+1/x"? I'll have to have two separate methods for asymptotes and zeros.

Plus, there's always the case where some jerk inputs 1/cos(100*x) and asks to find all the asymptotes (but I'm keeping my program multithreaded, so if it can't calculate it all in a reasonable time period, the UI won't crash, and you won't have to restart the java VM/force quit firefox)


Why does blue text appear every time you are near?
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 13th Sep 2011 11:39
Quote: "Aha, I'm working on the asymptotes!
"

Thanks Neuro!

Quote: "The thing is... it's not easy!"

Yeah, I forgot about horizontal asymptotes and also when you have asymptotes which equal things like 4x^2.

Quote: "I can't imagine finding the zeros of the denominator would be efficient. What if someone wrote "(x^2+x+1)/(1/(1/(2+9*log(x)^2))+x)+1/x"? I'll have to have two separate methods"

That is a good point. I wouldn't know where to begin, besides x = 0 looking at that last bit.

Quote: "Plus, there's always the case where some jerk inputs 1/cos(100*x) and asks to find all the asymptotes "

I'll be right back...

Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 13th Sep 2011 13:12 Edited at: 13th Sep 2011 13:13
Good work! Far too educational for me.

Dark Frager
15
Years of Service
User Offline
Joined: 16th Mar 2010
Location: The Void.
Posted: 13th Sep 2011 20:05
Looks cool!

Quote: "+ - * / ^ ( ) log() cos() sin()
(2*x^4+5)^(1/3)/(2+x)"


lolwut?

[CENTER][/CENTER]

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 16th Sep 2011 01:54 Edited at: 16th Sep 2011 02:05
Quote: "lolwut?
"

huh? That would be this:


Anyways, I'm almost done rewriting the point storage system, so that points don't have to be recalculated (which will be extremely helpful once I get to hard-to-calculate functions, like sums and limits). I think I've come up with a method that would find all turning points and asymptotes in a graph, but I'll have to try it out.

Also, with the way it will work, if a function isn't able to be calculated by a computer at it's extreme points, the asymptotes may not show up at the correct positions. For example, if someone wanted to find the asymptotes of 1/x^30, they'd probably be out of luck, because a double floating point estimation of it's asymptote might break at about x=.005 (I actually think it might still work, but you get my point).

I also fixed two bugs. The first problem was that if you zoomed in too far, everything blew up, due to trying to generate a massive image representing one unit square (which, when you're zoomed in, can be huge). Another was just a quirk where the program cuts off the "*10^x" notation, so it just shows "9.81818181" when what it really means is "9.818181*10^20"

I'll probably be uploading the new version tomorrow.

After that I plan on adding support for a bunch more stuff. I'll update the applet page with an add list.


Why does blue text appear every time you are near?

Login to post a reply

Server time is: 2025-05-20 19:07:06
Your offset time is: 2025-05-20 19:07:06