ab wrote:
>
> Hello.
> I had a break from work on this problem, but I still intend to do what I
> have planned.
>
> To warm up, here is a question about Fricas substitution mechanism.
>
> Suppose I have a following expression
>
> )clear completely
> e := exp( sqrt(-1) * a + sqrt(-1) * b )
>
> And I want to substitue a + b -> c.
I wonder why you do not use "obvious" eval:
(19) -> eval(e, a = c - b)
+---+
c\|- 1
(19) %e
Type: Expression(Integer)
'a' is a kernel and 'eval' will reliably replace it by whatever
value you want. Then colletion of common term will cancel
redundant terms containing 'b'.
>
> In a straightforward solution, sqrt(-1) disappears
>
> r := rule a + b == c
> s := r( e )
>
> (3) ->
> c
> (3) %e
> Type:
> Expression(Integer)
This rule transforms _any_ sum of two things into 'c'
> This can be fixed by the following rule
>
> r := rule ( %x*'a + %x*'b == %x*c )
> s := r( e )
>
> (5) ->
> +---+
> c\|- 1
> (5) %e
> Type:
> Expression(Integer)
>
> But for a more complicated expression it fails:
>
> e := exp( ( sqrt(-1) * a + sqrt(-1) * b ) * cos( t ) )
> s := r( e )
>
> (7) ->
> +---+
> (b + a)\|- 1 cos(t)
> (7) %e
> Type:
> Expression(Integer)
Well, there are many ways in which your pattern may
potentially match an expressiom. Trying all ways
would lead to exponential number of combinations.
For bigger patterns this would be too expensive
and FriCAS does not try. Your patterns is sum
of products, if FriCAS gets match for first
product it assumes that it will work for the
second. But apparently in this case this this
tactic misses match.
>
> Even the following rule doesn't lead to the desired answer:
>
> r := rule ( (b + a) * sqrt(-1) * cos( t ) == c * sqrt(-1) * cos( t ) )
> s := r( e )
This can not match: your expression is a sum, while pattern
you wrote is a product. More precisely, for expressions
FriCAS automatically applies distributive law, so your
expression is expanded into sum of products. But for
pattern distributive law does not hold, so your pattern
is a product. In FriCAS product will never match
a sum. In more detail: FriCAS expression is a quotient of
sums of products. Each product contains kernels and
coefficient from base ring. The relevant expression.
that is
e1 := ( sqrt(-1) * a + sqrt(-1) * b ) * cos( t )
is a trivial quotient (with denominator 1). Numerator
of this quotient is a sum of two products.
> Now, in my problem, there are operators instead of variables.
>
> A := operator 'A
> e := exp( ( sqrt(-1) * A(a) + sqrt(-1) * A(b) ) )
>
> And I want to substitue A(a) + A(b) -> A(c).
> In this case, a straightforward attemp fails:
>
> r :=3D rule A(a) + A(b) =3D=3D A(c)
> s :=3D r( e )
>
> (13) -> r( e )
> +---+ +---+
> \|- 1 A(b) + \|- 1 A(a)
> (13) %e
> Type:=20
> Expression(Integer)
>
> The following rule works fine though
>
> r := rule sqrt(-1) * A(a) + sqrt(-1) * A(b) == sqrt(-1) * A(c)
> s := r( e )
>
> (15) -> r( e )
>
> +---+
> \|- 1 A(c)
> (15) %e
> Type:=20
> Expression(Integer)
>
> Unfortunately, if the expression becomes slightly more complicated, it
> fails too:
>
> e := exp( ( sqrt(-1) * A(a) + sqrt(-1) * A(b) ) * cos( t ) )
> s := r( e )
That is clear: you must match the whole sum and your pattern
will not do.
>
> Again, a more complicated rule doesn't help:
>
> r := rule ( ( sqrt(-1) * A(a) + sqrt(-1) * A(b) ) * cos(t) == sqrt(-1 ) *
> A(c) * cos(t) )
Again, you are trying to match produt which can not work.
I think you need rule like:
r := rule d*A('a) + d*A('b) == d*A(c)
For some reason it does not work on your more complicated example,
but it goes in right direction:
- it matches a sum
- tick before 'a' and 'b' signal that we want literal match here
- variable 'd' should match other parts of a product.
--
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.