14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

224 Programming Methods Chapter 8<br />

Additional Numeric Operators<br />

Figure 8.3 Example of an Encrypted Data Table Script<br />

Additional Numeric Operators<br />

Derivatives<br />

JSL also offers several categories of operations that do not make much sense in the context of the formula<br />

editor: matrix operations and numeric derivatives of functions. Algebraic derivatives are also available.<br />

The basic arithmetic operators can also be used with matrix arguments for matrix-wise addition,<br />

subtraction, and so on. Matrices also have a few special operators for elementwise multiplication and<br />

division, concatenation, and indexing. See the chapter “Matrices” on page 137 in the “Data Structures”<br />

chapter, for details.<br />

JSL has three internal operators (not all available in the calculator) for taking derivatives.<br />

Derivative takes the first derivative of an expression with respect to names you specify in the second<br />

argument. A single name might be entered as this second argument; or multiple values can be specified in a<br />

list, in other words, surrounded by braces.<br />

Note: Derivative is also available as an editing command inside the formula editor (calculator), located<br />

on the drop-down list in the top center of the formula editor (above the keypad). To use it, highlight a single<br />

variable in the expression (to designate which variable the derivative should be taken with respect to), then<br />

select the Derivative command from the menu. The whole formula is replaced by its derivative with respect<br />

to the highlighted name.<br />

In scripts, the easiest way to use the function is with a single name. In this example, we first show the<br />

mathematical notation and then the JSL equivalent.<br />

For fx () x 3<br />

d 3<br />

= , the first derivative is f ’(x) or x = 3x 2 .<br />

dx<br />

result = derivative(x^3, x); show(result);<br />

result = 3 * x ^ 2<br />

If you want an efficient expression to take the derivative with respect to several variables, then the variables<br />

are specified in a list. The result is a list containing a threaded version of the original expression, followed by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!