# Questions tagged [function-construction]

For questions on writing functions (pure or using Set/SetDelayed) for any purpose, including the features that may be incorporated in those functions, such as options, patterns and conditions.

1,730 questions
Filter by
Sorted by
Tagged with
241 views

### How to define a function whose parameter have a list with default-value

As we know,we can define a function with default-value like this: fun1[x_, n_: 1, a_: 2, b_: 3] := x + n + a + b In:= fun1 Out= 10 But in my ...
427 views

404 views

### How to implement a formal expectation operator over an unknown distribution?

I need to do some simplification of an expression involving averages over a stochastic variable (in order to verify a long analytical calculation). The easiest way to do that, I figured, were if I ...
147 views

### How to make Orthogonalize simplify each new vector before using it to orthogonalize the next one?

I'm trying to construct a set of orthogonal polynomials, starting from a specially-prepared initial polynomials: ...
779 views

### How can I rewrite this with NestList or FoldList?

The original code used For: ...
1k views

### Write a function that returns the logarithmic derivative

How can we write a function that if we input an expression f, it returns the log derivative $\frac{1}{f} \frac{df}{dx}$? We have to use a conditional or pattern ...
392 views

### Appending _?NumericQ automatically to every variable of a function in the definition [duplicate]

I have a list of expressions as follows: as=Table[a[k],{k,1,500}] I would like to append _?NumericQ to every element of this ...