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

419 questions
Filter by
Sorted by
Tagged with
102 views

### What are the differences between these functions when used for NMaximize?

In short, the question is how to construct the function you want to optimize? ...
423 views

### multiple generators for iterative construction of fractal

The code below is an attempt to use more than one generator (in this case two) to generate a fractal using the standard iterative procedure involving generators. Only the first two stages of the ...
218 views

### How to input a dynamically changing parameter in NDSolve? [closed]

I am trying to solve a system of DEs with additional conditions, and one condition depends on a parameter. Let us consider the following example: ...
98 views

### How can I avoid a scoping problem when differentiating?

I simplify my real problem as follows: I define a rule function as Clear[rule]; rule[i_] := tt -> i; the real rule function is not this simple. I define a ...
65 views

### Replacement rule for terms that are separated by operators?

My main problem is how one can create a "transcending between operators rule" in the same term according to the minimal example bellow. Suppose I need to perform a replacement of the form ...
93 views

### How to modify the output result of an evaluation

For ease of notation, I have defined a function, $f$, that defines the permutation of Bosonic particles such that it has the following properties (the form of $f$ is irrelavent for this question): \$\...
42 views

### A Function of Arguments or a Function of a List of those Arguments – Which is Recommended?

Which is recommended from a programming perspective and has better performance in memory and speed given guaranteed identical output – a function taking many arguments and then referring to those ...
43 views

### Tracking back a variable corresponding to an output

I have a function: ...
125 views

### ReplaceThen and ReplaceAt - Cross between ReplacePart, Replace, and Extract -- Request for Comment

REWRITE: Multiple edits were hurting clarity Overview: I'm doing some work involving injecting code into held expressions, and found that I was repeating myself in a couple areas related to the ...
75 views

### Function to determine number of trees surviving forest fire [duplicate]

How can I write two functions, each of which have as their argument an array mat of 0s (no trees), 1s (trees), 2s (burning trees), that can determine the trees that survived a forest fire, which run ...
228 views

### How to turn a subroutine into a function?

I've written a subroutine that takes in 6 matrices and after some manipulation returns back 3 new ones. I will use this subroutine fairly often in this notebook so I think it would be easier to turn ...
129 views

### ND on a function using NIntegrate

I need to numerically differentiate a function that takes a list as an argument and that uses NIntegrate in its definition. A simple example is ...
75 views

### How to have NonlinearModelFit not evaluate a function too early?

This is a follow up of my previous question How can I define the following function for arbitray values of the arguments? that received no attention so here I will try to be more concise with the ...
108 views

### How can I define the following function for arbitray values of the arguments?

Consider the following function a[m_, l_] = 1/Log[m/l]; with this function I define ...
113 views

### Given a sequence of expressions, how can I convert them all into functions?

I have a sequence of expressions 1, x, x^2, ..., x^5 I want to define a sequence of functions out of it, what should I do? Namely I want to define a vector of ...
28 views

### Limiting the Domain of a Function

Currently, I am trying to plot (using Mathematica) the following function: $$f(t) = \begin{cases} 0, & 0<t<1 \\ 1, & 1<t<2 \end{cases}$$ And, to try to plot this, I did some ...
856 views

### Convert string to function with an argument

I am trying to build an expression by first writing it out as a string and then using ToExpression to convert it to an expression. However, I cannot figure out how to make expression recognize x as an ...