>
> 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.
>
>
Yeah! That was it! Now I can call it with @interact
>
>> 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 ;)
>
Sorry, what I meant is that now I can call the function secant(x) with
the @interact method of Sage. This present a menu that the user can
easily control.
for example in a cell of a notebook (assuming f(x) and tangent(x) are
already defined)
@interact
def plot_example(xtangent = (2,(2..10)) ):
lpar = plot(f,-1,100) # plot the function f(x) = x**2
lsec = plot(tangent(xtangent),rgbcolor='red',-1,100) # plot
tangen(x) = a + bx
figure = (lpar + lsec)
figure.show(xmin=0,xmax=100,ymin=-1,ymax=100)
in this example the values xsecant are chosen by the user in a menu, and
plotted accordingly in the figure. I will add my worksheet to the wiki
(in the Sage days 13 there is a nice project to introduce Sage for
undergraduate students, which would be very valuable for the Sage
beginner too)
Once again, thank you very much for your help!
Jose.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---