# Tagged Questions

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.

48 views

### How to define InterpolatingFunction on a variable set of points?

I would like to define an InterpolatingFunction to which data points are transferred as a parameter, e.g.: ...
338 views

### Is there a GraphicsPrimitiveQ (or a complete list of Heads of graphics primitives)?

For various reasons related to workflow associated with creating figures for journals, I am creating functions that will accept graphics primitives and a set of options and spit out a ...
162 views

### Subset-type function construction

This is probably a very straightforward thing I am missing, and probably also a duplicate(!), but I can't for the life of me think how to do this cleaner. I want to achieve what ...
57 views

### Is it possible to match a sequence with multiple heads without using Condition

Suppose I have: expr = Times[2, a[x,r], a[y,1], c[z,0,0], d[w,m]]; If I want to match a sequence of expressions with the same head ...
89 views

### Pertubation series of given equations

I would like to define a function that does the following. If I have an equation, for example: $$f(x)+[1-f^2(x)]+f^{\prime\prime}(x)+f(x)\ f^\prime(x)=0$$ and I am given a value for $f$ to expand ...
75 views

### How to change the built-in function? [duplicate]

As you can see,the original Differences will get {} when your parameter is a list with one element just. Differences /@ {{1, 2, ...
106 views

### Finding the smallest starting number producing a Collatz sequence of length 125 which ends with a value > 4

I'm supposed to do a Mathematica function that selects the smallest number not less or equal to 4 after 125 iterations. I am not good at coding, so some help/advice would be awesome. My code so far. ...
51 views

### Cumulative function definition and plotting [closed]

I'm quite new to Mathematica. I have an issue defining cumulatively a function. Let's say I have a waveform f[t] , and I want to create a function with many copies ...
63 views

### Should I define a function or not?

I was trying to execute the following code: ...
2k views

### Using pure functions in Table

I need a table with the elements made of pure functions and list elements. This is a simplified example: I need a list as: ...
99 views

### Gradient of interpolated 3D data in mathematica 9

tt = Flatten[Table[{x, y, z, btot[x, y, z]}, {x, -1, 1, 0.1}, {y, -1, 1,0.1}, {z, -1, 1, 0.1}], 2]; ff = Interpolation[tt] Till here it is working fine as it is ...
87 views

151 views

### How to make a function to analyse a sentence?

I have two lists: grammarNonterminal = {{VP,{V,NP}},{NP,{D,N}},{S,{NP,VP}}} sentence = {{D,"the"},{N,"man"},{V,"hit"},{D,"the"},{N,"table"}} I want to make a ...
126 views

### How to constrain the range of a plot of a function to satisfy an inequality?

Given the function f[x_] := x^2, how can I plot f[x] over the range where f[x] >= 10 and <...
30 views

### Solution of a function that is in a variable [duplicate]

If I want to get the solution for a simple function, e.g. a^x, I can use: a = 2; Function[x, a^x][2] However, if I have the function in a variable, I can't get ...
95 views

### Evaluate Limit only if both directions(sides) are equal?Ex: $\lim _{x\to 0}\left(\frac{1}{x}\right)=DNE$

I want the limit of a function to only evaluate if both the left and right hand side are equal. For example $\lim _{x\to 0}\left(\frac{1}{x}\right)$ doesn't exist(two sided limit). However, the right ...
290 views

### More elegant function construction for blues loop

Is there a more elegant way to do this: ...
46 views

### Deciding whether the return value of a function is defined based on its input [duplicate]

I have been met with the following problem: I have defined the following: myFunc[e_Integer]; That means, if I call: ...
92 views

### Defining arbitary Derivatives of functions

If I have two functions like these f[a_,b_] and g[a_,b_]. Lets say ...
88 views

### High-order functions and interactive objects

I have been developing Mathematica code to interpret LaTeX code, extract formulas and apply various Mathematica operations (e.g. Simplify, ...
96 views

### ClickPane and InputField entry in a Manipulate

By clicking at a point on the slope field for an ode, a solution is plotted through that point. Additional clicks produce more plots; the plots are saved in graph ...
213 views

### Make own rule for multiplication

I'm new to mathematica, so I still cannot use it properly. I want to do symbolic programming. My question is : is there any way to define our own multiplication. Suppose $a,b$ are arbitrary variables,...
84 views

### TagSetDelayed on a function with a delayed value

I'm trying to automatically optimize cases when the user evaluates Length[returnsList[x_]] to instead use returnsLength: ...
95 views

### Using a table as a variable in a function

I have a bunch of arrays and need to extract specific rows and columns of these that obey certain criteria. So for one table I'd do like this ...
39 views

### Please explain this pattern/Message related issue and help with finding workaround

I attempted to clean up my code and also add messages to functions if they are called with wrong arguments. This introduced some error which I tracked down to the following: ...
193 views

### Pack Solve results into a vector

I am currently using a really easy function to get the eigenvectors of a corresponding eigenspace: ...
93 views

### Function where variable is integration bound

Lets say I have a function of the form: $f(T) = T^4 \int_0^{1/T} \frac{x^3 dx}{e^x-1}$ This is an example of the situation I am describing not a unique problem. I want to define it as a numerical ...
46 views

### combine two definitions into one [closed]

Suppose I have two definitions of a function such as ...
85 views

### Define recursive function over two indices

I have $x_i=(i-1)/50$ for $i=1,\ldots,51$. Given a function $f(x) = x^2$, I want to find $y_i^k$ given by \begin{eqnarray} y_i^1 &=& f(x_i) \\ y_i^{k+1} &=& \max\left[\frac{y_{i-1}^...
1k views