Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    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.

  • #2
    Senior Coder
    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 "object-oriented" 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.

  • #3
    New to the CF scene
    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).

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    May 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jkd
    Do you need symbolic differentiation or just numeric?
    Unfortunately, I need symbolic.

    Quote Originally Posted by jkd
    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.
    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.

    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 Flash-based, 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.

  • #6
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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 n-ary tree...
    http://www.jasonkarldavis.com/math/test.xhtml

  • #7
    New to the CF scene
    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...for-Javascript

    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.

  • #8
    New to the CF scene
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •