Ahmad Kamal Elyan
Ahmad Kamal Elyan

Reputation: 11

how to call a multiple function within a multiple one by mathematica?

I have defined a multiple function before and i want to call it within another multiple function by Mathematica software.

enter image description here

Upvotes: 0

Views: 663

Answers (2)

Alan
Alan

Reputation: 9620

You must decide what is known ahead of time and what is known only when the function h is called. For example, you propose

    f[a_,b_] := a+b*a^2
    g[c_,d_] := (c/d)+d*5
    h[x_,y_] := x[a,b] +y[c,d]

This only makes sens if {a,b,c,d} are known outside of the functions. That may simply be the opposite of what you want. That is, you may want to define h in terms of known functions but unknown parameter values. E.g.,

    f[a_,b_] := a+b*a^2
    g[c_,d_] := (c/d)+d*5
    h[a_,b_,c_,d_] := f[a,b] +g[c,d]

Finally, you may want to define h in terms of unknown functions as well as unknown parameter values. E.g.,

    h[a_,b_,c_,d_,f1_,f2_] := f1[a,b] + f2[c,d]

Upvotes: 0

Rohit Namjoshi
Rohit Namjoshi

Reputation: 679

Just pass the function name as an argument.

f[a_, b_] := a*b;
g[c_, d_, e_] := c*e[c, d];

g[3, 5, f]
(* 45 *)

Upvotes: 1

Related Questions