cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Defining a function involving previously defined f

OwenHughes
1-Visitor

Defining a function involving previously defined f

I want to define a function in stages, using functions that I already have defined. I cannot work out how to enter those previously defined functions on the right hand side of the new function. I have tried using just the function names, and also tried including their arguments. Neither choice seems to work.
4 REPLIES 4

If you don't get 14 help, "Save as 11".

jmG
RichardJ
19-Tanzanite
(To:OwenHughes)

It's not just a case of what you have on the right, it's also a case of what you have on the left. On the right you need the function(s), with arguments. On the left you need to include the arguments to the functions on the right but not, usually, the function name. For example

f(x):sin(x)
g(x):cos(x)

F(a,b,c):f(a)+g(b)+c+5

Note that the arguments on the left and right in a function definition only have any meaning within that definition. So the x in f(x) and the x in g(x) are not the same x, and have no relationship to any variable in the worksheet that might be called x. If you have a variable name on the right that's not in the argument list it assumes it's a predefined variable.

It is possible to pass the function name as an argument, but you would only do that if you wished to change the actual function, rather than just the arguments to the function. For example,

f(x):if(x>0,sin,cos)

returns a function, not a value. If x is greater than 0 the function is sin, if it's less than or equal to zero it's cos.

Richard

The defining (RHS) expression for a function is an expression, to be evaluated. Yu can use previously defined functions the same way you use built in functions and operators, providing the function name and the argument list. If the fuction has been previously defined, and youe new function is to always use that previous definition the previously defined function is not an argument and should not appear in the argument list.

Here you are attempting to multiply a function name (D11) by some expression, and that doesn't work. You need the value of the function, which is the function name applied to suitable arguments.
__________________
� � � � Tom Gutman

>I want to define a function in stages, using functions that I already have defined.< You mean like cooking soup ? If not the simple general case at left, maybe the recursive case at right. Can't tell more w/o actually looking at the work sheet.



jmG

Announcements

Top Tags