On Jan 16, 2008 8:14 PM, Ondrej Certik <[EMAIL PROTECTED]> wrote: > On Jan 16, 2008 7:00 PM, David Joyner <[EMAIL PROTECTED]> wrote: > > > > Hi: > > > > I don't remember this topic coming up before but at some point > > it must be faced since it arises in Calculus 1. AFAIK, SAGE has no routines > > for > > (1) computing the "implicit derivative" y' if y is defined implicitly > > by F(x,y)=0, > > (2) plotting (x,y) subject to F(x,y)=0. > > > > (1): This is easy for SAGE to compute: y' = - F_x(x,y)/F_y(x,y). > > The problem is that it just isn't implemented yet to my knowledge. > > How should this be implemented? implicit_derivative(F(x,y),x) or something?? > > Suggestions? > > Is there a need for a special function? I would suggest to use regular > differentiation means. > > For inspiration, I just tried this in sympy: > > In [1]: g = Function("g") > > In [2]: f(g(x), x) > Out[2]: f(g(x), x) > > In [3]: e=f(g(x), x) > > In [4]: e > Out[4]: f(g(x), x) > > In [7]: e.args > Out[7]: (g(x), x) > > In [8]: e.diff(x) > Out[8]: > d d d > ─────(f(g(x), x))*──(g(x)) + ──(f(g(x), x)) > dg(x) dx dx > > In [9]: Basic.set_repr_level(1) > Out[9]: 2 > > In [10]: e.diff(x) > Out[10]: D(f(g(x), x), g(x))*D(g(x), x) + D(f(g(x), x), x) > > > (you need to use fixed width fonts to see [8], otherwise you'll just see a > mess) > But I am not satisfied with the output, especially with > > D(f(g(x), x), x) > > since it is not clear if it means the total derivative, or just with > respect to the second parameter. Or do you mean something like this: > > In [4]: e=f(x)**2+f(x)*x**3-3*f(x) > > In [5]: e.diff(x) > Out[5]: > d 3 d d 2 > - 3*──(f(x)) + x *──(f(x)) + 2*f(x)*──(f(x)) + 3*x *f(x) > dx dx dx > > In [6]: Basic.set_repr_level(1) > Out[6]: 2 > > In [7]: e.diff(x) > Out[7]: -3*D(f(x), x) + x**3*D(f(x), x) + 2*f(x)*D(f(x), x) + 3*x**2*f(x) > > In [9]: solve(e.diff(x).subs(f(x).diff(x), y) == 0, [y]) > Out[9]: [3*x**2/(3 - x**3 - 2*f(x))*f(x)] > > in [7] I differentiate the implicit definition of f(x), in [9] I solve > for the D(f(x), x) by substituting it for "y" and solving for y. > > I cannot now figure out how to do this in Sage, but I am not sure what > the best interface to all of this is. But I think the less functions > (idioms) one needs to remember to do any calculus stuff in Sage, the > better.
To make myself more clear, I'd suggest: def implicit_derivative(eq, f) x = f.args[0] return solve(eq.diff(x), f) or something like this. At least the goal of the calculus in Sage should be to support this imho. Ondrej --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---