Alasdair McAndrew? writes: I'd be grateful for a little help here! (Then I'll see if I can use the z-transform to solve some difference equations.) Ref:On 29 May 2007 14:21:26 +0200 Martin Rubey wrote: It seems that you hit a bug, but fortunately, there is an easy workaround. The problem is with rules of the form: rule ...a...b... | p(a,b) == ... It seems that in this case, the predicate p is never tested, who knows why? The workaround is to use the "suchThat" function. fricas Expr ==> Expression Integer Type: Void
fricas zt:=operator 'zt
Type: BasicOperator?
fricas ztransrules := ruleset([ _ suchThat(rule zt(a^n,
Type: Ruleset(Integer,
We only need to use a rules to handle the case of a^n, sin and cos, but similar rules could be written for the rest or we can do the same thing by common recursive methods: fricas ztrans(f:Expr, Type: Void
On Tue, 29 May 2007 09:19:42 +1000 Alasdair McAndrew? wrote: 1) The commands: fricas ztrans(2+3^n, fricas Compiling function ztrans with type (Expression(Integer),
Type: Expression(Integer)
fricas --should return the result: 2*z/(z-1) + z/(z-3)
Type: Fraction(Polynomial(Integer))
fricas ztrans(0,
Type: Expression(Integer)
fricas --should return the result: 0
Type: NonNegativeInteger?
fricas ztrans((-1)^n,
Type: Expression(Integer)
fricas --should return the result: z/(z+1)
Type: Fraction(Polynomial(Integer))
fricas ztrans(1,
Type: Expression(Integer)
fricas --should return the result: z/(z-1)
Type: Fraction(Polynomial(Integer))
fricas ztrans(n,
Type: Expression(Integer)
fricas --should return the result: z/(z-1)^2
Type: Fraction(Polynomial(Integer))
fricas ztrans(n^2,
Type: Expression(Integer)
fricas --should return the result: z*(z+1)/(z-1)^3
Type: Fraction(Polynomial(Integer))
fricas ztrans(n^3,
Type: Expression(Integer)
fricas --should return the result: z*(z^2+4*z+1)/(z-1)^4
Type: Fraction(Polynomial(Integer))
fricas ztrans(b^n,
Type: Expression(Integer)
fricas --should return the result: z/(z-b)
Type: Fraction(Polynomial(Integer))
fricas ztrans(cos(b*n),
Type: Expression(Integer)
fricas --should return the result: z*(z-cos(b))/(1-2*z*cos(b)+z^2)
Type: Expression(Integer)
fricas ztrans(sin(b*n),
Type: Expression(Integer)
fricas --should return the result: z*sin(b)/(1-2*z*cos(b)+z^2)
Type: Expression(Integer)
2) How do I force answers to be returned in factored form? fricas ( x+->factor(numer(x))/factor(denom(x)) ) ztrans(2+3^n,
Type: Fraction(Factored(SparseMultivariatePolynomial?(Integer,
Bill Page wrote: Reduce does z-transforms http://www.uni-koeln.de/REDUCE/3.6/doc/ztrans/ztrans.html
Inverse z-transforms
|