Enjoy an ad free experience by logging in. Not a member yet? Register.

Results 1 to 8 of 8
Thread: Javascript Derivate Calculator

05042004, 06:27 PM #1
 Join Date
 May 2004
 Posts
 5
 Thanks
 0
 Thanked 0 Times in 0 Posts
Javascript Derivate Calculator
I've seen several Java or Perl Derivative Calculators online, but I can't seem to find any in JavaScript. Has anyone tried? I might need one in JavaScript (or Flash ActionScript) for a graphing tool I'm working on, and I don't want to reinvent the wheel if I can avoid it.
05042004, 08:18 PM
#2
 Join Date
 Feb 2004
 Posts
 1,206
 Thanks
 0
 Thanked 0 Times in 0 Posts
I haven't tried, and I've never looked either! I've never done too much "objectoriented" Javascript, but I did find the source code to the page you posted:
http://cs.jsu.edu/mcis/faculty/leathrum/Mathlets/src/
It's one of the links near the bottom. It might not be the easiest thing to convert as he's got a few different classes, as well as parser built in C. But it's probably doable.
If I had the time, I might even try to tackle it.
There are Derivative Calculators I've found on Google, but they expect numbers, not variables like the one you've posted (which is a cool one I must say!).
Good luck to anyone that tries it, and you should post it on the Post a Javascript forum as it could be useful to others.
Sadiq.
05042004, 08:24 PM
#3
 Join Date
 May 2004
 Posts
 5
 Thanks
 0
 Thanked 0 Times in 0 Posts
Hmm, thanks, mostly. It looks like it might be even more complex than I expected it to be. My guess is this won't happen soon (we probably need something that will process faster than this would process), but I'll keep thinking about it, and probably EVENTUALLY do it (I work at an educational technology company, so I'm sure we'll want a derivative calculator EVENTUALLY).
05042004, 08:50 PM
#4
Do you need symbolic differentiation or just numeric? Numeric is easy, for example you can use the common approximation
function diff(f) {
return function(x) { return (f(x+.00001)f(x))/.00001 };
}
And call it like:
function f(x) {
return x*x+2*x+1;
}
fprime = diff(f);
fprime(0.5); // about 1
You can adjust the 0.00001 to a smaller and smaller number to gain accuracy, in theory it becomes precisely correct at an infinitesimally small value close to zero (call it an epsilon). There are also parabolic interpolations you could use, etc.
Even symbolically, differentiation is not that difficult. With a knowledge of the sum, multiplication, power, chain rules, and the deriviatives of elementary functions, you can differentiate precisely any continuous function.
05042004, 08:55 PM
#5
 Join Date
 May 2004
 Posts
 5
 Thanks
 0
 Thanked 0 Times in 0 Posts
Unfortunately, I need symbolic.Originally Posted by jkd
I know it's not that difficult for ME to do it (or wasn't back when calculus was fresh in my mind), but I'm worried that it might be difficult to JavaScript to do it.Originally Posted by jkd
What I'm really hoping to do is to take an input function, find the second derivative, and use it to find inflection points for a graphing program (which will be Flashbased, but will either call this derivative function or include it translated to ActionScript). I'd probably eventually use the function in some other calculus educational products, as well.
05042004, 11:54 PM
#6
Parsing input into symbolic expressions really isn't that difficult in Javascript (that was what I was getting at). This was something I started a while ago for Alex Vincent, never quite finished it, but could easily be completed 100% with a quick replacement of the binary tree with an nary tree...
http://www.jasonkarldavis.com/math/test.xhtml
09232011, 04:27 PM
#7
 Join Date
 Sep 2011
 Posts
 2
 Thanks
 0
 Thanked 0 Times in 0 Posts
After going through some of the links here trying to find a tool to fit my own needs, I started a GitHub project to make a public symbolic math javascript library.
It's located here: https://github.com/jamesmclellan/Sym...forJavascript
And, hopefully, will not be going anywhere as long as GitHub is around.
Presently, it handles: addition, subtraction, multiplication, division, exponents, parentheticals, simple differentials (with and without product rule).
I would be very grateful for contributions to the baseline, if anyone would be so inclined.
09062013, 08:07 PM
#8
 Join Date
 Sep 2013
 Posts
 2
 Thanks
 0
 Thanked 0 Times in 0 Posts
I know this post is very old but I decided to give it go. I got as far as differentiation and algebraic parsing. I hope to wrap up integration and complex numbers soon. For something like an online plotter or calculator it should do just fine especially since I build in a javascript function exporter.
Take a look and give me some feedback. http://www.nerdamer.com/demo.
The source is at https://github.com/nerdamer/nerdamer...ifferentiation