axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] choose the better expand


From: Francois Maltey
Subject: Re: [Axiom-developer] choose the better expand
Date: 01 Apr 2006 18:46:45 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

Dear Martin, 

Thanks for your friendly mails.

The aim of my first steps in axiom is to have the three minimal functions
expand, rewrite and combine for elementary functions. 
Simplifications come after !

/////////////////////////////////////////////////////////////////////

So expand : expand ! 
I ask for me if I do only one expand (Expr) 
or expand (Expr, "sincos") with one parameter and
   expand (Expr, ["sincos", ...) with many parameters. Do you have an idea ?

rewrite has an aim : 
  rewrite (sin (4*x), "tan") computes (tan (2*x)/(1+tan (2*x)^2)

combine (2*(cos x)^2, "sincos") finds cos (2*x)+1

Axiom has some of theses functions but there are a lot of name to retain.
So I try to give a single access to theses transformations.

/////////////////////////////////////////////////////////////////////

Now where I'm locked : 

How can I produce sin a cosh b + %i cos a sinh b
after expand (sin (a+%i*b)) in the interpreter ?

So sin (a+%i*b) is of type Expression ... Complex ... 

My manip.spad have now this main function kerexpand, 
I add functions expandsin and so, 
add auxilary functions expandsinp for product, and sinnx for sin (n*x)
The function fctCtoN transforms c in R in n in Integer

    kerexpand k ==
      nullary?(op := operator k) => k::F
      is?(op, POWER) => expandpow k
      arg := first argument k
      is?(op, "sec"::Symbol) => inv expand cos arg
      is?(op, "csc"::Symbol) => inv expand sin arg
      is?(op, "log"::Symbol) =>
         exlog(numer(x := expand arg)) - exlog denom x
      is?(op, "exp"::Symbol) => expandexp arg 
      is?(op, "sin"::Symbol) => expandsin arg 
      is?(op, "cos"::Symbol) => expandcos arg
      is?(op, "tan"::Symbol) => expandtan arg
      is?(op, "cot"::Symbol) => expandcot arg
      is?(op, "sinh"::Symbol) => expandsinh arg 
      is?(op, "cosh"::Symbol) => expandcosh arg
      is?(op, "tanh"::Symbol) => expandtanh arg
      is?(op, "coth"::Symbol) => expandcoth arg
      op [expand x for x in argument k]$List(F)

    expandsin arg ==                                   -- for ...plus...
--    If arg is complex AND imag arg ~=0 I want to expand trig with sin, sinh
--      and so
      null variables arg => sin arg 
      num := numer arg 
      den := denom arg
      a := leadingMonomial num
      c := leadingCoefficient a 
      b := reductum num / den
      b ^= 0 => 
          expandsinp (c,a,den) * expandcos b _
        + expandcosp (c,a,den) * expand sin b
      expandsinp (c,a,den)

    fctCtoN c ==       -- it's not so easy to obtain n in Integer from c in R
      n : Integer := 1 
      if R has retractIfCan : R -> Union(Integer,"failed")
        then 
          n1 := (retractIfCan c)@Union(Integer,"failed")
          if n1 case Integer then n := n1::Integer
      n

    expandsinp (c, a, den) ==                 -- for product with an unknow c 
      n := fctCtoN c
      if n = 1 
        then sin (a/den)
        else
          sinnx (n, (a::F) / (n::R::F * den::F))

    sinnx (n,x) ==                                   -- the well-know formula 
      n<0  => -sinnx (-n, x)
      imag(complex(sin(x),cos(x))$CF**n)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]