Abs: Difference between revisions

From ASCEND
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:abs}}
{{DISPLAYTITLE:abs}}
{{missing}}
 
The '''abs''' function in ASCEND returns the absolute value of its argument. This function should be used with caution in models because, being a non-smooth function, it can damage the convergence of many of the Newton-based solver algorithms, such as [[QRSlv]].
 
== Useful tricks with <tt>abs</tt> ==
 
Using the <tt>abs</tt> function, it is possible to create makeshift <tt>min</tt> and <tt>max</tt> functions using ASCEND relations. For example,
 
<source lang=a4c>
a,b IS_A factor;
max IS_A factor;
max = a + ((b-a) + abs(b-a))/2;
</source>
 
[[Category:Syntax]]
[[Category:Syntax]]

Revision as of 12:09, 15 August 2010


The abs function in ASCEND returns the absolute value of its argument. This function should be used with caution in models because, being a non-smooth function, it can damage the convergence of many of the Newton-based solver algorithms, such as QRSlv.

Useful tricks with abs

Using the abs function, it is possible to create makeshift min and max functions using ASCEND relations. For example,

a,b IS_A factor;
max IS_A factor;
max = a + ((b-a) + abs(b-a))/2;