# Singular

 Page 1 of 1 [ 2 posts ]
 Print view | E-mail friend Previous topic | Next topic
Author Message
 Post subject: Symbolic computation in a procedurePosted: Mon Feb 20, 2017 11:52 am
Hi,

I am new to singular and have much more experience in mathematica and maple. One thing that separates singular from the other CAS I know is that indeterminates (I call them "symbols") have to be iniitated in a ring before doing any kind of algebra. Now suppose I create a procedure, in here it seems that singular does not care if the ring variables have not been defined. But what confuses me is that the following does not work

Code:
proc test123()
{
return v(1)*v(2);
}

ring A = 0,(v(1..2)),dp;
test123();

I'm not really sure how to use the ring variables in the procedure and the documentation does not make me any wiser. Any help would be appreciated. I am trying to ports most of my codes (algebraic geometry for kinematics) to singular because this gives me the opportunity to continue using a free CAS and distribute this to interested people (without requiring them to have maple) and I am slowly getting annoyed of maples slowness (commandline execution gets slower after every new version of maple and older maple are known to be difficult when operating system updates). I also like and feel more comfortable with the C/C++ structure of singular.

Top

 Post subject: Re: Symbolic computation in a procedurePosted: Mon Feb 20, 2017 3:18 pm

Joined: Wed Mar 03, 2010 5:08 pm
Posts: 106
Location: Germany, Münster
Almost any command in Singular needs to be called with (may be empty) parentheses.
The return command is not exception from this rule. So put the ( ), and it works as desired.
Code:
> proc test123()  {
return(v(1)*v(2));
}
> ring A = 0,(v(1..2)),dp;
> test123();
v(1)*v(2)

Hint: To make this proc independent of the names of the variables, write:
Code:
> proc test1234()  {
return(var(1)*var(2));
}
> ring rdp = 0,(x,y),dp;
> test1234();
xy

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 You can post new topics in this forumYou can reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 It is currently Mon Oct 15, 2018 11:01 pm
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group