Message Boards Message Boards

[✓] Define a complicated function?

GROUPS:

Dear Community,

I have a fairly complicated function with several input variables. I can not define the function in one single line, because it does a lot of things finaly resulting in one single number. How can I enter it into Mathematica? I find only simple, 1 line functions in books, and in the documentation center. I mean something like this e.g.:

longfun[    a_  ,  b_  ,  c_  ,  d_  ,  e_   ] :=
fac1 = 2*a + 3*b
fac2 = 4*d + 5*e - 2*a + 3*c
fac3 = Sqrt[fac1] + 3.487*fac2 + 2.2*e ;

and longfun should be finally equal to fac1 + fac2 - 4.5*fac3.

tx in advance, best regards Andras

POSTED BY: Andras Gilicz
Answer
2 months ago

Andras,

Look at Module[]. You define local variables and separate lines with semicolons. The last item is returned as the answer.

Regards

Neil

POSTED BY: Neil Singer
Answer
2 months ago

Dear Neil,

Thank you very much for the quick answer :-)

best regards Andras

POSTED BY: Andras Gilicz
Answer
2 months ago

Group Abstract Group Abstract