On Sat, 24 Jul 2010 11:03:45 -0700
Jason Grout <[email protected]> wrote:

> On 7/24/10 4:38 AM, Renato wrote:
> > Hi, this seems very basic, but I wasn't able to figure it out.
> > Let's say I have a function:
> >
> > sage: f(t)
> > -4*(5*sqrt(2)*cos(1/2*sqrt(2)*sqrt(5)) -
> > 2*sqrt(5)*sin(1/2*sqrt(2)*sqrt(5)))*sin(1/2*sqrt(5)*t)/(sqrt(5)*sin(1/2*sqrt(2)*sqrt(5))^2
> > + sqrt(5)*cos(1/2*sqrt(2)*sqrt(5))^2) +
> > 4*(5*sqrt(2)*sin(1/2*sqrt(2)*sqrt(5)) +
> > 2*sqrt(5)*cos(1/2*sqrt(2)*sqrt(5)))*cos(1/2*sqrt(5)*t)/(sqrt(5)*sin(1/2*sqrt(2)*sqrt(5))^2
> > + sqrt(5)*cos(1/2*sqrt(2)*sqrt(5))^2) - 8
> >
> > how do I tell sage to evaluate numerically everything but sin(),
> > cos() and t? I.e. I know this function is in the form
> >
> > f(t) = a*sin(b*t) + c*cos(d*t)
> >
> > can I tell sage to put it in this form, evaluating numerically a,b,c
> > and d?
> >
> > kind regards
> > renato
> >
> 
> 
> It looks like there is also a -8 at the end:

ah yes, you're right.

> sage: f(t)=-4*(5*sqrt(2)*cos(1/2*sqrt(2)*sqrt(5)) 
> -2*sqrt(5)*sin(1/2*sqrt(2)*sqrt(5)))*sin(1/2*sqrt(5)*t)/(sqrt(5)*sin(1/2*sqrt(2)*sqrt(5))^2+
>  
> sqrt(5)*cos(1/2*sqrt(2)*sqrt(5))^2) 
> +4*(5*sqrt(2)*sin(1/2*sqrt(2)*sqrt(5)) 
> +2*sqrt(5)*cos(1/2*sqrt(2)*sqrt(5)))*cos(1/2*sqrt(5)*t)/(sqrt(5)*sin(1/2*sqrt(2)*sqrt(5))^2+
>  
> sqrt(5)*cos(1/2*sqrt(2)*sqrt(5))^2) - 8
> 
> sage: f.subs_expr(sqrt(5)==sqrt(5).n(),sqrt(2)==sqrt(2).n())
> t |--> 8.13039327042996*sin(1.11803398874989*t) + 
> 12.5656955743861*cos(1.11803398874989*t) - 8
> 
> Basically, I used subs_expr to subsititute in numeric values for the 
> square roots.

thanks :)

> Question to the community at large:
> 
> It seems like f.n() should do the above (evaluate what it can 
> numerically, leave the variables alone). But this doesn't work:

yes it would be nice indeed to have a more general way of doing this.

regards
renato

-- 
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
URL: http://www.sagemath.org

Reply via email to