Message Boards Message Boards

GROUPS:

[✓] Define a complicated function?

Posted 1 year ago
792 Views
|
2 Replies
|
1 Total Likes
|

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

2 Replies

Andras,

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

Regards

Neil

Dear Neil,

Thank you very much for the quick answer :-)

best regards Andras

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract