# NOT RUN {
# The numerical value of f[1]g[1,1] + f[2]g[1,0]g[0,1], that is the coefficient of x1x2 in
# f(g1(x1,x2),g2(x1,x2))) output of MFB(c(1,1),1) when
# f[1] = 5 and f[2] = 10
# g[0,1]=3, g[1,0]=6, g[1,1]=9
e_MFB(c(1,1),1, c(5,10), c(3,6,9))
# Same as the previous example, with a string of assignments as third input parameter
e_MFB(c(1,1),1, "f[1]=5, f[2]=10, g[0,1]=3, g[1,0]=6, g[1,1]=9")
# Use the boolean parameter to verify the assignments to the coefficients of "f" and "g",
# that is f[1]=5, f[2]=10, g[0,1]=3, g[1,0]=6, g[1,1]=9
e_MFB(c(1,1),1, c(5,10), c(3,6,9), TRUE)
# To recover which coefficients are involved in the Faa di Bruno's formula, run the function
# without any assignment. The error message recalls which coefficients are necessary, that is
# e_MFB(c(1,1),1)
# Error in e_MFB(c(1, 1), 1) :
# The third parameter must contain the 2 values of f: f[1] f[2].
# The fourth parameter must contain the 3 values of g: g[0,1] g[1,0] g[1,1]
# Syntax to correctly assign values to the coefficients of "f" and "g" when the functions
# become more complex.
# 1) run e_MFB(c(1,1),2) and get the errors with the indication of the involved coefficients
# of "f" and "g", that is
# The third parameter must contain the 5 values of f:
# f[0,1] f[0,2] f[1,0] f[1,1] f[2,0]
# The fourth parameter must contain the 6 values of g:
# g1[0,1] g1[1,0] g1[1,1] g2[0,1] g2[1,0] g2[1,1]"
# 2) initialize f[0,1] f[0,2] f[1,0] f[1,1] f[2,0] with the first 5 natural numbers and do
# the same for g1[0,1] g1[1,0] g1[1,1] g2[0,1] g2[1,0] g2[1,1], that is
# e_MFB(c(1,1),2, c(1:5), c(1:6), TRUE)
# 3) trought the boolean value TRUE, recover the string f[0,1]=1, f[0,2]=2, f[1,0]=3, f[1,1]=4,
# f[2,0]=5, g1[0,1]=1, g1[1,0]=2, g1[1,1]=3, g2[0,1]=4, g2[1,0]=5, g2[1,1]=6
# 4) copy and past the string as input in place of " ... " when run e_MFB(c(1,1),1," ... ")
# 5) change the assignments if necessary
cfVal<-"f[0,1]=2, f[0,2]=5, f[1,0]=13, f[1,1]=-4, f[2,0]=0"
cgVal<-"g1[0,1]=-2.1, g1[1,0]=2,g1[1,1]=3.1, g2[0,1]=5, g2[1,0]=0, g2[1,1]=6.1"
cVal<-paste0(cfVal,",",cgVal)
e_MFB(c(1,1),2,cVal)
# }
Run the code above in your browser using DataLab