0
|
3583 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Defining modules and module function

Posted 10 years ago
 Define a module and module function, mF, that calculate the maximum of xand y, and then find the maximum of the values (34/9, 674/689).
7 Replies
Sort By:
Posted 10 years ago
 mF[x, y] := Module[{x0 = x, y0 = y}, If[x0 > y0, x0, y0]];ended up doing it like as show above
Posted 10 years ago
 Ok cheers it was suggested to me to do that but forget it Thanks
Posted 10 years ago
 Am i right in thinking I have to create internal variables and use those instead of comparing x and y directly, if so how?
Posted 10 years ago
 You do not need to create extra variables. Why copy the input arguments to another variables in order to compare them? Waste of memory and CPU time since they will not be changed. You need to make a copy only if you want to modify the input argument inside the Module.
Posted 10 years ago
 Thanks but i believe i needed to use an IF function which confuses me ???
Posted 10 years ago
 I updated it to use If
Posted 10 years ago
 define the Module mF[x_, y_] := Module[{}, Max[x, y]]; Use it to find the max mF[34/9, 674/687] (*34/9*) To use If use this: mF[x_, y_] := Module[{}, If[x > y, x, y]] mF[34/9, 674/687] (*34/9*) 
Community posts can be styled and formatted using the Markdown syntax.