Errors compiling itovsn3

9 views
Skip to first unread message

Leon Baum

unread,
Sep 3, 2011, 3:34:46 PM9/3/11
to FriCAS - computer algebra system
Hello,

I am trying to compile Wilfrid Kendall's itovsn3 code found here:
http://axiom.newsynthesis.org/mathaction/SymbolicItoCalculus

I am running into two errors with the ito.spad file, but because the
code is old and I am new to axiom, I'm not sure whether the problems
are with the code itself or with fricas.



1) The first error is from the function:

smooth!(op:BOP):Union(BOP,"failed")==
assert(op,"ito")

where BOP ==> BasicOperator

Error:

(|assert| |op| | << ito >> |)
****** level 2 ******
$x:= ito
$m:= (Symbol)
$f:=
((((|op| # #) (< #) (<= #) (= #) ...)))

>> Apparent user error:
Cannot coerce ito
of mode ito
to mode (Union ito (Symbol))


I can get it to compile by using "ito"::Symbol, but why isn't the
conversion automatic?
From the command line, assert(operator(foo), "bar") works.



2) The second error is from the function:

d(X:EXR):SDR ==
0 = height X => 0$SDR
f := numerator X
g := denominator X
df := ItoDPoly(numer f)
dg := ItoDPoly(numer g)
(g*df - f*dg)/g**2 - df*dg/g**2 + f*dg**2/g**3

where R is of type Join(OrderedSet, IntegralDomain)
and EXR ==> Expression(R)
and SDR ==> StochasticDifferential(R)

Error:

(SEQ
(LET #1=#:G696
(= 0 (|height| X)))
(|exit| 1
(IF #1#
(|elt| (|StochasticDifferential| R) 0)
(SEQ
(LET |f|
(|numerator| X))
(LET |g|
(|denominator| X))
(LET |df|
(|ItoDPoly| (|numer| |f|)))
(LET |dg|
(|ItoDPoly| (|numer| |g|)))
(|exit| 1
(+
(- (/ (- (* |g| |df|) (* |f| |dg|)) (** | << g >> | 2))
(/ (* |df| |dg|) (** |g| 2)))
(/ (* |f| (** |dg| 2)) (** |g| 3))))))))
****** level 10 ******
$x:= g
$m:= (StochasticDifferential R)
$f:=
((((|dg| #) (|df| #) (|g| #) (|f| #) ...)))

>> Apparent user error:
Cannot coerce g
of mode (Expression R)
to mode (StochasticDifferential R)


I am not sure how to fix this one. Any ideas?

Thanks,
Leon

Leon Baum

unread,
Sep 4, 2011, 10:33:53 PM9/4/11
to FriCAS - computer algebra system
Just to update: Tim Daly sent me an email saying the itovsn3 code
compiles fine in Axiom, so the errors must be related to changes in
FriCAS.

Are these changes intentional or just a bug? I'm using FriCAS 1.1.3
with SBCL 1.0.50, btw.

Waldek Hebisch

unread,
Sep 14, 2011, 3:14:02 PM9/14/11
to fricas...@googlegroups.com


There were changes in FriCAS and the code needs to be updated:

1) In FriCAS operator properties are Symbols. So

assert(op,"ito")

should be changed to

assert(op, 'ito)

Similarly

has?(op,"ito")

should be changed to

has?(op, 'ito)


2) FriCAS algebra uses '^' for exponentiation. So

g**2

should be changed to

g^2

and similarly for other uses of '**'.

The two changes fix problems you observed. For newest FriCAS you
also need to change:


setSmooth:={
'exp,'log,'sin,'cos,'tan,
'cot,'sec,'csc,'asin,'acos,'atan,
'acot,'asec,'acsc,'sinh,'cosh,'tanh,
'coth,'sech,'csch,'asinh,'acosh,'atanh,
'acoth,'asech,'acsch,'Gamma
}::Set Symbol

to

setSmooth:= set([
'exp,'log,'sin,'cos,'tan,
'cot,'sec,'csc,'asin,'acos,'atan,
'acot,'asec,'acsc,'sinh,'cosh,'tanh,
'coth,'sech,'csch,'asinh,'acosh,'atanh,
'acoth,'asech,'acsch,'Gamma
])$Set(Symbol)

This is beacause newest FriCAS does not allow to use { and } to
denote sets -- the idea is that braces for sets where used very
rarely and we want to free braces for other puroses. Also,
this change removes one of disagreements between interpreter and
Spad compiler -- already in Axiom time interpreter did not
accept braces for sets.

Note that FriCAS interpreter language is slightly different than
Spad compiler language. In particular interpreter automatically
coerces a String to a Symbol, but Spad compiler needs explicit
coercion (or better just a Symbol). Also, for compatibility
with old code currently FriCAS interpreter allows '**' as
exponentiation and converts it to '^', but Spad compiler
treats '**' and '^' as distinct.

--
Waldek Hebisch
heb...@math.uni.wroc.pl

Leon Baum

unread,
Sep 17, 2011, 8:45:51 PM9/17/11
to FriCAS - computer algebra system
Thanks! I uploaded a patch to the mathaction wiki.

For future reference, are all of the syntax differences between Axiom
and FriCAS documented anywhere?

Waldek Hebisch

unread,
Oct 8, 2011, 10:30:45 AM10/8/11
to fricas...@googlegroups.com

I added a page to HyperDoc version of Axiom book listing
differences.

--
Waldek Hebisch
heb...@math.uni.wroc.pl

Reply all
Reply to author
Forward
0 new messages