# Higher order functions - how should they be defined?

#### seanos

I want to write a function that takes other functions as inputs. Specifically I want to define a function F that takes input 't' (time) and 2 distribution functions, D1 and D2, as inputs (each distribution function itself a function of 't').

For a simple example, if function F is the product of these distribution functions at time t then I could write:

F(t) = D1(t) * D2(t)

So far so good. But now, this is where I get stuck, how do I define another function whose definition includes several F functions each using different distribution functions?

To give an example, lets say I want to define a function G which is the difference between two F functions of different distribution functions. Could I write this:

G(t) = F(t, D1(t), D2(t)) - F(t, D2(t), D3(t)) where F(t, X(t), Y(t)) = X(t) * Y(t)

If not, what is a better way to write this?

#### HallsofIvy

It's not clear to me what you are asking. You are talking about a "composition" of functions, but what do want to do with it?

### The Physics Forums Way

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving