Hacker News new | past | comments | ask | show | jobs | submit login
Differentiating in Python (acooke.org)
3 points by andrewcooke on Feb 23, 2013 | hide | past | favorite | 3 comments



Not to disparage such a huge effort, but there are Python libraries for this sort of thing.

Code:

    from sympy import *

    var('x,y')

    for p in range(8):
      print('    %s' % str(diff(x**9+8,x,p)))
  
    print('')
 
    print('    %s' % str(integrate(y**x,x)))
Output:

    x**9 + 8
    9*x**8
    72*x**7
    504*x**6
    3024*x**5
    15120*x**4
    60480*x**3
    181440*x**2

    y**x/log(y)


nice, but was that around in 2004? anyway, it was written as an example for a coworker, who was going to implement it in a language whose name i have forgotten, but which was fortran 66 plus wrappers to c memory management, and which certainly didn't have suitable libraries...


> nice, but was that around in 2004?

The linked article is dated 2006, the first version of Sympy was written in 2007. Close, but no cigar. BTW Sympy is open source, so one could in principle port its routines to another language.

> ... written as an example for a coworker, who was going to implement it in a language whose name i have forgotten, but which was fortran 66 plus wrappers to c memory management ...

I have only one question -- why? Fortran is one of the most outdated languages one can choose for a modern project. And the sample Python code from the article would be painful to try to render in Fortran, in particular the string manipulations.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: