組み合わせる・順序も問題になる

  • f(x)の値を2乗したい
  • y=f(x), y^2
  • 二乗をg(x) = x^2とすると
  • g(f(x))
  • g,fを使って組合せやら順序を尽くせば
    • f(f(x)):sin(sin(x))
    • g(f(x)):(sin(x))^2,慣例で\sin^2(x)
    • f(g(x)):sin(x^2)
    • g(g(x)):(x^2)^2
  • x^2がそもそも書き方の慣例
  • \sin^2(x)+\cos^2(x)もfunction(x){sin(x)^2 + cos(x)^2}という引数xが1個の関数
  • \sin(x)もそもそも書き方の慣例
f <- function(x)sin(x)
nijyo <- function(x)x^2
f_shite_nijyo <- function(x){
 y <- f(x)
 nijyo(y)
}
f_shite_f <- function(x){
 y <- f(x)
 f(y)
}
nijyo_shite_f <- funtion(x){
 y <- nijyo(f)
 f(y)
}
nijyo_shite_nijyo <- function(x){
 y <- nijyo(x)
 nijyo(f)
}
x <- seq(from=0,to=10,length=100)
plot(f_shite_nijyo(x))
plot(f_shite_f(x))
plot(nijyo_shite_f(x))
plot(nijyo_shite_nijyo(x))