Hi Francois,
On Mon, 14 Sep 2009 13:55:33 +0200
Francois Maltey <[email protected]> wrote:
>
> Hello,
>
> I don't find usual trigonometric transform in sage :
>
> expand (sin (2*x)) == 2*sin(x)*cos(x)
sage: t = sin (2*x)
sage: t.tri<tab>
t.trig_expand t.trig_simplify
sage: t.trig_expand()
2*sin(x)*cos(x)
> combine (cos(a)^2) == 1/2 + cos(2*a)/2
The trig_expand() function doesn't seem to do this, trig_simplify()
let's you go back though.
sage: var('a')
a
sage: v = 1/2 + cos(2*a)/2
sage: v
1/2*cos(2*a) + 1/2
sage: v.trig_simplify()
cos(a)^2
> rewrite (sin(a), exp) == (exp(i*a)-exp(-i*a)) / (2*i)
ATM, there is no general framework to rewrite expressions
systematically in terms of exp, tan, or gamma functions. I have some
utility functions I wrote long ago. I will try to clean them up and
submit a patch this week.
For now, you can do this manually:
sage: z = sin(a)
sage: w = SR.wild()
sage: z.subs(sin(w) == (exp(i*w)-exp(-i*w)) / (2*i) )
1/2*I*e^(-I*a) - 1/2*I*e^(I*a)
> I can use maxima("expand (sin(a+b))") or fricas ("...") calls but not
> the inner sage system.
This can also be done with the trig_expand() function.
sage: var('b')
b
sage: sin(a+b).trig_expand()
sin(a)*cos(b) + sin(b)*cos(a)
> Is there such functions in sage ?
> What sage files can I read if I want to understand how sage compute
> similar algorithms.
Sage calls maxima to do the expansions and simplifications above. If
someone makes a list of transforms each function is supposed to apply,
these could easily be implemented in Sage directly (making it much
faster).
For the time being, you can look at the documentation for subs(),
find(), and match() functions on symbolic expressions to see what Sage
can do for pattern matching. E.g.,
sage: x.find?
< will show the documentation of the find method on x >
There are also quite a few functions for simplify and expand:
sage: x.simpl<tab>
x.simplify x.simplify_log x.simplify_trig
x.simplify_exp x.simplify_radical
x.simplify_full x.simplify_rational
sage: x.expa<tab>
x.expand x.expand_rational x.expand_trig
Cheers,
Burcin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---