noun
Mathematical function; a relation between a set of inputs and a set of permissible outputs.
この関数のグラフを描いてください。
Please draw the graph of this function.
二次関数は中学で習います
Quadratic functions are learned in junior high school.
noun
In programming, a named section of a program that performs a specific task.
この関数は引数を二つ取ります。
This function takes two arguments.
エラーが出たので、関数の定義を見直してください。
An error occurred, so please review the function definition.
機能 refers to a function in the sense of a capability or role of a system or organ, while 関数 is strictly a mathematical or programming function.
From Chinese 函數/函数 (hánshù), literally 'box number', a calque of English 'function'. The kanji 関 (connection) replaced 函 (box) in modern Japanese usage.