a.a.letterbox wrote:
> 
> I want to reproduce analytical calculations from an attached pdf-file with 
> FriCAS.
> 
> The calculations look rather lengthy, but I do not want (yet) FriCAS to 
> perform them fully automatically.
> Rather, I'd like to reproduce each step manually in an interactive regime.
> This should be doable, since it doesn't require anything beyond basic 
> substitution capabilities and arithmetics.
> 
> My first goal is to reproduce everything in a text regime.
> Then I want to do the same using TeXmacs for nice formatting.
> Finally I need to output the resulting equation into C or Fortran, or some 
> other form, suitable for numerical computation.
> 
> So far, my progress was rather limited.
> 
> The first thing to do is to define eq.(1) inside FriCAS.
> For this it is necessary do define eqs (3) and (6).
> Eq. (3) can be represented by ( see also 'laser_e2e_on_h.input' attached )
> 
> E := operator 'E
> xi := operator 'xi
> alpha := operator 'alpha
> volkov_wave(r, p, t) == _
>   exp( %i * ( p * r - alpha(p) * cos( omg * t ) - E(p) * t - xi(t) ) )
> 
> Most of the time I'm not interested in exact expressions for E, xi and 
> alpha, so I just define them as operators.
> However, an attempt to evaluate a complex conjugate 
> 
>   conjugate( volkov_wave(r,p,t) )
> 
> leads to an error. Presumably, I should tell FriCAS, that E, xi and alpha 
> are not just operators but Complex-valued functions. 
> How do I do this?

Currently FriCAS can compute conjugate only if expression is explicitely
in rectangular form (more procisely of type Complex(something)).
You can convert expression to this form using 'complexForm', but
AFAICS you do not want this (this will spoil further calculations).
In your case one possibility is to use operator to represent
conjugation.  My impression is that you apply conjugation only
to exponentials with imaginary arguments, then ad-hoc function
to negate exponent my do:

my_conj(x) == (k := x::Kernel(Expression(Complex(Integer))); _
  is?(k, exp) => operator(k)(-first(argument(k))); error "not exp")

(21) -> my_conj(volkov_wave(r_0, p_s, t))                                  
   Compiling function my_conj with type Expression(Complex(Integer))
       -> Expression(Complex(Integer)) 

           %i alpha(p_s)cos(omg t) + %i xi(t) + %i t E(p_s) - %i p_s r_0
   (21)  %e
                                           Type: Expression(Complex(Integer))

> Another couple of questions concern exponents manipulation.
> By default FriCAS performs multiplication in exponents of the form exp( %i 
> (a + b) ), resulting in exp( %i * a + %i * b ).
> In my case
> 
> (10) -> volkov_wave( r, p ,t )
>            - %i alpha(p)cos(omg t) - %i xi(t) - %i t E(p) + %i p r
> (10)  %e
> 
> How do I suppress that?

Probably it is better to live with it.  If you really want then
use 'paren' like below:

(13) -> %i*paren(a+b)

   (13)  %i(b + a)
                                           Type: Expression(Complex(Integer))

However, 'paren' suppresses any evaluation between what is in parens
and outside, so you may get:

(14) -> paren(a+b) - (a + b)

   (14)  (b + a) - b - a
                                                    Type: Expression(Integer)

> 
> Another thing I need is to gather similar factors in exponents.
> Namely, how do I transform this
> 
> (12) ->   volkov_wave(r_0, p_s, t) * volkov_wave(r_1, p_e, t)
> 
>    (12)
>        - %i alpha(p_s)cos(omg t) - %i xi(t) - %i t E(p_s) + %i p_s r_0
>      %e
>   *
>        - %i alpha(p_e)cos(omg t) - %i xi(t) - %i t E(p_e) + %i p_e r_1
>      %e
> 
> into this
> 
>    (12)
>        - %i ( ( alpha(p_s) + alpha(p_e) ) cos(omg t) + 2 * xi(t) + ( E(p_s) 
> + E(p_e) ) t - ( p_s r_0 + p_e r_1 ) )
>      %e

(8) -> simplify(volkov_wave(r_0, p_s, t) * volkov_wave(r_1, p_e, t))

   (8)
     %e
  ^
       (- %i alpha(p_s) - %i alpha(p_e))cos(omg t) - 2%i xi(t) - %i t E(p_s)
     + 
       - %i t E(p_e) + %i p_e r_1 + %i p_s r_0
                                           Type: Expression(Complex(Integer))

'simplify' is doing several things, you may prefer 'simplifyExp'
which is doing just this.

> Finally, one more question. 
> How do I define delayed integration necessary for eq (1)?
> My first idea was to use quote. Something like 'integrate( s_matrix_subint, 
> t ). But then, how do I unquote s_matrix_subint inside?
> Another idea is to define integration as an operator
>   I := operator 'I
>   s_matrix := I( s_matrix_subint )
> But this is probably not the best approach too.

FriCAS uses 'integral' to produce unevaluated integrals.  FriCAS
currently can not represent unevaluated integrals with infinite
integration limits, so all one can do is to fake them using
symbol as a limit, like:

(25) -> integral(volkov_wave(r_0, p_s, t), t=-inf..inf)

   (25)
      inf
    ++      - %i alpha(p_s)cos(omg t) - %i xi(t) - %i t E(p_s) + %i p_s r_0
    |     %e                                                               dt
   ++
   - inf
                                           Type: Expression(Complex(Integer))

Once you create such an integral FriCAS will make no attempt to
evaluate it.  It is possible to use 'eval' function to perform
operations on integrals, like:

(48) -> eval(integral(sin(x), x), 'integral, l +-> first(l))
   There are 3 exposed and 4 unexposed library operations named first 
      having 1 argument(s) but none was determined to be applicable. 
      Use HyperDoc Browse, or issue
                              )display op first
      to learn more about the available operations. Perhaps 
      package-calling the operation or using coercions on the arguments
      will allow you to apply the operation.

   (48)  sin(%B)
                                                    Type: Expression(Integer)

However, FriCAS here is a bit picky about types of involved object.
Above l is a list of expression (arguments to "integral"), 
'+->' creates anonymous function, first takes the first element
from the list.  In this case I was able to skip declaring types,
but in general I would have to declare types of argument and
return value from the function and take care of coercing
arguments to proper types.  So it is getting heavy.  Also,
evaluating integral in such way depends on internal representation
of unevaluated integrals...

I admit that in similar situations I just keep integrand in a variable,
and give it to 'integrate' when needed.  Similarly, when I do
not want evaluation I just keep intermediate results in variables.
I use unevaluated expression when I expect some simplifiction
(for example defivative of unevaluated indefinite interal gives
back integrand).


-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to