On Sep 13, 5:16 pm, Sand Wraith <[EMAIL PROTECTED]> wrote:
> Hello,
>
> tell please, how to access spline like function? for example i have:
>
> p=list();
> p.append([1,1]);
> p.append([2,1.5]);
> p.append([3,2]);
> p.append([4,0]);
> s=spline(p)
>
> and i can get value of s in any point: s(1) or s(3) etc.
>
> so, i want to use this spline like function:
> g(x)=s(x)+1;

Currently, you can't do s(x) with x a symbolic variable.  As I suspect
you are noticing by now, Sage's symbolic capabilities are not as
consistent or fully developed as they might be.  I hope this situation
gets better.  Are you familiar with lambda functions?  If not, read up
on them in any general python reference.

sage: g = lambda x: s(x) + 1
sage: g(3.2)
2.7919999999999998

> or
> def g(x):
>      return s(x)*sin(x);

sage: g = lambda x: s(x)*sin(x)
sage: g(3.2)
-0.104606465022223

> or for example what should i do to integrate s?

sage: numerical_integral(s,0,4)
(5.0416667546732121, 4.5217882014708456e-06)
sage: numerical_integral(g,0,4)
(2.3596454927315831, 2.0291503505937003e-07)
sage: numerical_integral(lambda x: s(x)*sin(x), 0, 4)
(2.3596454927315831, 2.0291503505937003e-07)

If you're wondering what the second element of the answer is, I
recommend executing "numerical_integral?".

Regards,

JM
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to