Higher order functions - how should they be defined?

  • Context: Undergrad 
  • Thread starter Thread starter seanos
  • Start date Start date
  • Tags Tags
    Functions Higher order
Click For Summary
SUMMARY

The discussion centers on defining higher-order functions in programming, specifically a function F that takes time 't' and two distribution functions, D1 and D2, as inputs. The user successfully defines F as F(t) = D1(t) * D2(t) but struggles with creating another function G that computes the difference between two F functions with different distribution functions. The proposed definition G(t) = F(t, D1(t), D2(t)) - F(t, D2(t), D3(t)) is questioned, leading to a clarification on the concept of function composition.

PREREQUISITES
  • Understanding of higher-order functions in programming
  • Familiarity with function composition
  • Knowledge of distribution functions and their mathematical representation
  • Basic proficiency in a programming language that supports first-class functions
NEXT STEPS
  • Explore the concept of function composition in JavaScript or Python
  • Learn about higher-order functions in functional programming languages like Haskell
  • Investigate mathematical properties of distribution functions
  • Study examples of implementing higher-order functions in real-world applications
USEFUL FOR

Software developers, mathematicians, and data scientists interested in functional programming and the application of higher-order functions in mathematical modeling.

seanos
Messages
1
Reaction score
0
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, let's 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?

Thanks for reading this!
 
Mathematics news on Phys.org
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?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 5 ·
Replies
5
Views
1K