Message Boards Message Boards

0
|
5829 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

[?] Define a complicated function?

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
2 Replies

Dear Neil,

Thank you very much for the quick answer :-)

best regards Andras

POSTED BY: Andras Gilicz

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
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