SUNY Geneseo Department of Mathematics
Wednesday, September 9
Math 230 01
Fall 2015
Prof. Doug Baldwin
help
command for functionslog
for natural logarithm, log10
for base 10>> a = 3; b = 4;
>> sqrt( a^2 + b^2 )
ans =
5
>> sqrt( sin(pi/3) )
ans =
0.9306
>> % log x + log y = log (xy)
>> log(17) + log(34)
ans =
6.3596
>> log( 17*34 )
ans =
6.3596
>> floor( 3.4 ) % floor rounds down
ans =
3
>> floor( 3 )
ans =
3
>> floor( 3.9 )
ans =
3
>> ceil( 3.2 ) % ceil rounds up
ans =
4
>> round( 3.2 ) % round rounds to nearest
ans =
3
>> round( 3.8 )
ans =
4
>> round(3.5)
ans =
4
>> factorial( 5 ) % compute factorials
ans =
120
>> help log
log Natural logarithm.
log(X) is the natural logarithm of the elements of X.
Complex results are produced if X is not positive.
See also log1p, log2, log10, exp, logm, reallog.
Other functions named log
Reference page in Help browser
doc log
>> log( 3, 27 )
{Error using log
Too many input arguments.}
>> % Despite documentation to the contrary, specifying the base for a logarithm doesn’t seem to work
>> log(27) / log(3)
ans =
3.0000
>> help nthroot
nthroot Real n-th root of real numbers.
nthroot(X, N) returns the real Nth root of the elements of X.
Both X and N must be real, and if X is negative, N must be an odd integer.
Class support for inputs X, N:
float: double, single
See also power.
Reference page in Help browser
doc nthroot
>> c = 3;
>> 4ac
4ac
|
{Error: Unexpected MATLAB expression.
}
>> % Remember the asterisk when multiplying
>> 4*a*c
ans =
36