There are a couple of pre-defined vectors and numbers in R, e.g., pi
, letters
, LETTERS
, etc..
C
where each row contains all letters from A to Z. Do not use a loop!==
operator which row contains the number 100.C
to a 9 x 9 square matrix containing only the letters E, …, I and W, …, Z.E
with entries TRUE
and FALSE
. The entries should be TRUE
if the corresponding letter of the matrix C
appears before K
in the alphabet.Write a function f <- function(n)
which returns a vector for the integers 1,…,n with entries TRUE or FALSE for even or odd numbers, respectively.
is.integer()
or the %%
operator for testing if a number is odd or even (?is.integer
, help("%%")
).Given the ODE for the Verhulst model \[\dot{x} = f(x,\vec{p}) = p_1 x \left(1-\frac{x}{p_2}\right)\] find the points \(\bar{x}\) where \(\dot{\bar{x}} = 0\) numerically.
fg <- function(x,p)
returning the vector \(\big(f(x,\vec p), f'(x, \vec p)\big)\).newton <- function(x0,prec)
with initial value x0
and precision prec
. Stop the iterations when \(|x_{n+1} - x_n| <\) prec is reached.For an illustration of Newton’s method see: https://en.wikipedia.org/wiki/Newton's_method#/media/File:NewtonIteration_Ani.gif