Jose Guzman ha scritto:
> Hi everybody,
>
> I am pretty new to symbolic math and Sage but I love it!!!!.
>
> I am trying create a function which returns an tangent line at a given 
> point (xpoint) in a function f(x) already known as follows:
>
> var('x')
> f(x): x**2
>
> def tangent(xpoint):
>
> def secant(xpoint):
>     # function of the form f(x) = a + bx
>     df = f.differentiate(x)
>     m = df(xpoint) # slope is the derivative of the function in that point
>     a = f(xpoint) - m*(xpoint) # coordinate
>    
>     return g(x) = a + m*x
>
>   

sage: def secant(xpoint):
....:     df = f.differentiate(x)
....:     m = df(xpoint)
....:     a = f(xpoint) - m*(xpoint)
....:     g(x) = a + m*x
....:     return g

The trick is to define the function, and the, make the return of the 
"abstract" function.

sage: secant(2)
x |--> 4*x - 4
sage: secant(2)(2)
4
sage: secant(2)(3)
8


>
> I guess I am doing something essentially wrong from the pythonic point 
> of view, but I cannot figure out how to create this function to call it 
> later in a interactive cell with @interact.
>   
I don't really understand neither ;)

> Thank you very much for your help, and my apologizes in advance if the 
> question is too trivial.
>   
Bah ! You allows me to post *my* trivial questions ;)



Have a good night
Laurent

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to