Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives.
Usually when we check whether two double values equal or not, we would check whether they're close enough or not. This is due to possible information loss of double values stored in computer. However, in R we can directly use
==to check whether two objects (including double values) equal or not. This is because for double values, R will automatically check whether they are close or not instead of checking whether they are equal like other languages do.
optimizecan be used to find the minimum and maximum value of a function. By default these two functions find the minimum value. But we can use control=list(fnscale=-1) in optim and maximum=T in optimize to find the maximum value. Surely there are some difference between these functions. First we give an original value of the parameter for the function
optimwhile we give an interval of the parameter for the function
optimize. Second and also most important, the function
optimizecan only do the optimization over one variable while the function
optimcan do the optimization over multiple variables. However, when we use
optimto do optimization over multiple variables, we must put these variables into a single vector.
We can use function
unirootto find the roots of a given function, and we can use function
optimizeto find the maximum or minimum value of a function.