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

31 views

### How to use OptionValue inside a pure function [duplicate]

I want to define a function with OptionsPattern as argument which returns a pure function using OptionValue: ...
70 views

### Build basic Adobe Kuler-type construction: improving performance / speed

Adobe Kuler is a useful web tool to create colour palettes, but it is limited to 5 colours. I am trying to make a basic Kuler-type construction, but it is very slow, and crashes on my computer for > ...
34 views

### How to make FindMiniumum work with delayed function and NIntegrate [duplicate]

I can plot my function penalty[v] just fine, but FindMinimum doesn't work, it just complains non-numerical values from ...
166 views

### How to get Series to recognize user-defined function has pole

Edit for clarity: How does Mathematica's function Series know that Gamma[x] has a pole at ...
40 views

57 views

### How may I repeat this procedure n times?

This is the procedure ...
1k views

### How does a Pringle lose its curvature?

Nom! As part of a bigger project, I've was writing some code to calculate the scalar curvature of surfaces of the form $z = f(x,y)$. This uses a general calculation of the scalar curvature to produce ...
125 views

### Function does not execute commands and fails to evaluate [closed]

The code I am trying to execute: hh[x_, y_] := x + y; hh[{3, 4}] The expected output: 7 However, on output I get ...
80 views

### Remove part within square brackets for function

So I've defined a variable as follows: q = {{x[t]}, {Φ[t]}} V=0.5*x[t]^2*m^2+0.5*Φ[t]^2*I I've had to differentiate with respect to time so: ...
111 views

### Why a function returns two different values if copied into a Notebook or imported with Get from a Wolfram Mathematica Package?

I have some Mathematica code that shows a behaviour I really cannot understand. The code only contains a bunch of function definitions. If I paste it in the Notebook Front End and I evaluate it, I ...
53 views

### What I make wrong with Module command;

I have a differential equations that I have to solve in two parts.e.g: ...
56 views

### Derivative in my package return 0

I'm writing my package (.m) in Mathematica and when I'll call the function returns 0 instead of right output. Here's my code: Package.m ...
73 views

### How to use recursion to find a logical dual

I want to make a little function that goes through a propositional formula and gives it's dual. Here is what I currently have: ...
43 views

### Greatest common denominator command. Can you explain why this command works?

Can you explain how this function works? mysteryFunction := Fold[#/#2 /. {n_~_~_ -> #/n, _ -> #2} &, #, {##}] &
4k views

### Module with “local functions”

I am trying to use a Module having "local functions", i.e., those which I need to define only inside this module. So I tried this: ...
60 views

### Custom units Compatible with Conversions [closed]

I am writing a Mathematica Palette to work with units, and am wondering if anyone knows a way to define new units outside of the standard ones that come with Mathematica 9. I do know of the ...
280 views

### Simpler way to type Derivative[1, 0][u][0, x]

Though not unbearable, I always feel a little nervous when typing partial derivatives at a specified place e.g. $u^{(1,0)}(0,x)$, which happens a lot when setting initial/boundary conditions for PDEs. ...
37 views

### How to define a general linear function [duplicate]

I'm trying to work with a general linear function in Mathematica. I would like to assign some sort of rules to a function, say Tbar, to evaluate linearly. Basically what I would like to do is have ...
39 views

### Getting a list of function definition parameter values [closed]

If I define a function over certain values: f[0] = 1 f[1] = 2 f[2] = 3 How do I get the list of parameter values that it's been defined on? ...
128 views

### Syntax f[x_][y_]

Need to understand the principle of the distinction between f[x_,y_] and f[x_][y_] It seems also that z[x_, y_][a_, b_, c_][α_, β_] := a (x + y)^b + c/(α-β) ...
62 views

### Distinguish hashtag # operator when using multiple functions [duplicate]

I would like to do this list = Append[list[[#]],Map[list2[[1, #]] & , list[[#, 4]], {2}]] & /@ Range[Length[list]]; But I would like to substitute ...
63 views

### User-defined density plotting function with a functional argument: extracting variables from the function and plotting in a circular region

I would like to customize the function DensityPlot and use it in a package as a function called MyDensityPlot: The functions ...
494 views

### How can I export my learned ClassiferFunction[] and PredictorFunction[]s?

Mathematica 10 provides beautiful high-level machine learning functionality. Sadly, the learned functions once created are rather opaque objects. I need to use them in other projects, so here is my ...
1k views

### Using patterns in pure functions

Pure functions may be handy if you don't want to assign your function a name. For example I would calculate $x(x-1)$ for some numbers $x$ by ...
195 views

### How to construct the RHS of Wick's theorem

I've been trying this for a few days now, but I just can't seem to find an efficient (speed-wise) functional way to code the following task. Context: I would like to construct an expressions that is ...
38 views

### How is Attributes protected and yet can still be set?

The Attributes function itself has the attributes: Attributes[Attributes] ...
477 views

### How to generate this structure of a list without While and the like?

I need to create a list that holds, for given integer d, the elements $1,\ldots,d,d+2,\ldots,2d,2d+3,\ldots,3d,3d+4,\ldots,d^2$ where $\ldots$ is just denoting ...
181 views

### Number by permutation

I want a function that compute number of permutation in lexicographical order. E.g. ...
172 views

### Passing function as argument

I've been mucking around with passing functions as arguments to other functions and via trial and error seem to have something that works. I was wondering if someone could have a quick look at some ...
38 views

### Plot is empty (probably) due to poor function definition

I am trying to plot my response $x(t)$ as a function of system parameter $M_0$. Here is my code to regenerate my problem ...
107 views

### n fold convolution of a function via a recursion function

I wanted to write a recursion function to calculate the n-th convolution of a function f[x_]. I wrote the function ...
169 views

### Sets and sums of different elements

Consider the set S={w,x,y,z}. If the set of all possible sums of any three different elements from S is {-1,3,5,8}, then what is the set S? How could I solve this function using Mathematica?
98 views

### For loop works at top-level but not in a function

Why does this work: For[i = 1, i <= Dimensions[list][[1]], i++, list = Insert[list, i, {i, 3}]] But this doesn't: ...
78 views

### How to obtain the Derivative of a pure Function of variable number of arguments?

Here is a function f that takes a variable number of arguments: f = Times[##]*Log[1 - Times[##]] & I now want to ...