Programmer Guide/Command Reference/EVAL/log: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
m (1 revision: Initial import) |
No edit summary |
||
Line 19: | Line 19: | ||
Logarithm to base <var>b</var> | Logarithm to base <var>b</var> | ||
{{DISPLAYTITLE:log, ln, ld}} | |||
Compute the logarithm of the argument ''x'' element by element. | |||
;Usage: '''<code>log(<var>x</var> , <var>b</var></code>''' | |||
:'''<code>log(<var>x</var>)</code>''' ... common logarithm (base 10) | |||
:'''<code>ln(<var>x</var>)</code>''' ... natural logarithm (base e); alias: <code>log(''x'','''e''')</code> | |||
:'''<code>ld(<var>x</var>)</code>''' ... logarithm to the base 2; alias: <code>log(''x'','''2''')</code> | |||
:;<var>x</var>a scalar, vector or matrix; all elements must be greater than 0 | |||
:;<var>b</var>the base of the logarithm; must be a positive number | |||
;Result: The result ''r'' has the same type as ''x'' and contains the logarithm of ''x'' to the specified base ''b'', computed element by element. | |||
;See also: [[Programmer_Guide/Command_Reference/EVAL/npow2|npow2]], [[Programmer_Guide/Command_Reference/EVAL/exp|exp]] | |||
;Note: For the inverse function the [[Programmer_Guide/Command_Reference/EVAL#Operators|operater ''^'']] can be used; e.g.: 10^''x'', e^''x'', ... | |||
Example: | |||
<pre> | |||
#a := eval vv(1,2,3,4,5) | |||
#b := eval init(5,2,0) | |||
#c := eval vmcol($#a, $#b, $#a) | |||
// -> $#c is a matrix with 4 rows and 5 columns: | |||
// $#c[*,*] = $#a, #c[1,*] = $#b[*,0], $#c[2,*] = $#b[*,1], $#c[3,*] = $#a | |||
</pre> | |||
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] |
Revision as of 13:29, 6 April 2011
Contents
log
Logarithm
Usage:
log(x)
Function:
Common logarithm (b=10)
Usage:
log(x, b)
Function:
Logarithm to base b
Warning: Display title "log, ln, ld" overrides earlier display title "log". Compute the logarithm of the argument x element by element.
- Usage
log(x , b
log(x)
... common logarithm (base 10)ln(x)
... natural logarithm (base e); alias:log(x,e)
ld(x)
... logarithm to the base 2; alias:log(x,2)
- xa scalar, vector or matrix; all elements must be greater than 0
- bthe base of the logarithm; must be a positive number
- Result
- The result r has the same type as x and contains the logarithm of x to the specified base b, computed element by element.
- See also
- npow2, exp
- Note
- For the inverse function the operater ^ can be used; e.g.: 10^x, e^x, ...
Example:
#a := eval vv(1,2,3,4,5) #b := eval init(5,2,0) #c := eval vmcol($#a, $#b, $#a) // -> $#c is a matrix with 4 rows and 5 columns: // $#c[*,*] = $#a, #c[1,*] = $#b[*,0], $#c[2,*] = $#b[*,1], $#c[3,*] = $#a