Linked Questions

2
votes
1answer
2k views

What is the meaning of two square brackets in function definition? [duplicate]

I came along the following function definition f[a_, b_, c_][r_] = ... with some function on the right hand side. Is this equivalent to ...
1
vote
0answers
136 views

what is the difference between these definitions? [duplicate]

I define 2 functions: g[s_][x_,y_] := the gaussian (1) g1[s_,x_,y_] := the gaussian (2) I get the same answer using ...
0
votes
0answers
76 views

How does Wolfram Language implement for enabling symbols to receive various forms of parameters? [duplicate]

How does the official implement a list/tuple of parameters that can be different in type and quantity as a whole? After re-read @Szabolcs's and @MichaelE2's comments. Finally, I accepted the ...
1
vote
0answers
63 views

What is exactly an element a[i] in mathematica? [duplicate]

I'm confused about the logic behind mathematica programming. We can have function that will be called doing $f[x]$, thus the element $f[x]$ can be seen as the return value of a function taking an ...
453
votes
37answers
99k views

What are the most common pitfalls awaiting new users?

As you may already know, Mathematica is a wonderful piece of software. However, it has a few characteristics that tend to confuse new (and sometimes not-so-new) users. That can be clearly seen from ...
528
votes
19answers
132k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
129
votes
8answers
7k views

Can one identify the design patterns of Mathematica?

... or are they unnecessary in such a high-level language? I've been thinking about programming style, coding standards and the like quite a bit lately, the result of my current work on a mixed .Net/...
68
votes
4answers
16k views

How do I save a variable or function definition to a file?

Is it possible to save a function which was created via Interpolation of some data in such a way that I can use this function in a new Mathematica session without ...
23
votes
8answers
2k views

Selectively Mapping over elements in a List

I am using the following code to easily generate a row of images of all eight planets of our Solar System: ...
37
votes
5answers
7k views

Clear complains that a subscripted variable is not a symbol or a string?

Here's a small listing where I've used EscqEsc to typeset θ in the notebook: ...
36
votes
4answers
3k views

Do people actually use UpValues?

I know what they are and how to define them. They have to serve some purpose - else why include them? But I never used them and all examples on this site and the docs never show a practical use of <...
47
votes
2answers
2k views

How do you set attributes on SubValues?

SubValues, as discussed in a previous question, are declared as follows ...
19
votes
3answers
857 views

Generating assignments and transforming code inside held forms when generating code

I have been playing with slightly above trivial code manipulations in Mathematica. I thought Mathematica would be great for this kind of work because of rule replacement and expression manipulation, ...
3
votes
6answers
2k views

Defining an integer-valued function on an integer domain

This should be an easy question! I want to define a function with domain = the 12 integers {1,12}, with the values f[1]=31, <...
20
votes
2answers
630 views

SetAttributes[f,Flat]: Why the order dependence?

I'm experiencing a strange phenomenon. Here's a (quite artificial) test case: The following definition work just fine: ...
23
votes
2answers
602 views

How to implement FittedModel like objects

In the course of making some RLink wrappers I want to have some richer containers like Mathematica does with its FittedModel ...
9
votes
3answers
1k views

Why are functions called first-class objects in Mathematica?

I've heard lots of people say a function is a first-class object in Mathematica. "Everything is an expression, including function." "There is no distinction between functions and data." Having read ...
10
votes
4answers
784 views

Finding Anagrams of given length from DictionaryLookup

What I'm trying to find are the 4 letter words in the Mathematica dictionary that have the most anagrams and the amount of anagrams these have each. But I can't seem to find all the 4 letter words in ...
10
votes
2answers
1k views

How to send output of Information[] command to a text file?

I am having little hard time sending output of Information[] command to a text file. related question How to write output to an external text file in addition to ...
16
votes
3answers
318 views

Why is the first argument of the SetDelayed evaluated?

In[1]: f=g; In[2]: SetDelayed[f[x_],x^2]; In[3]: ?f Global`f f=g In[4]: ?g Global`g g[x_]:=x^2 However, SetDelayed has the ...
5
votes
3answers
1k views

recursive integration

I am trying to do multiple integrations recursively. For instance, I would like to do the following equation for arbitrary integer $n$: $\displaystyle R_n(t) = \int_0^t \mathrm dt' R_0(t-t') R_{n-1}(...
5
votes
2answers
7k views

Nested If statements

When I do this: Apply[(If[#2 == what, "yay", If[#2 == whoops, "nay"]]) &, {-5, what}] I get: yay But when I do this: <...
5
votes
2answers
6k views

How do I plot a solution of a differential equation?

I am having trouble generating a plot for a solution to my differential equations. I always end up with just blank axes. ...
0
votes
3answers
4k views

How do I show the combined plot from the do-loop?

I have a do-loop to do the calculations from a set of data and plot the graphs with different results, that was obtained from the calculations. I was able to get multiple graphs but I want to ListPlot ...
11
votes
1answer
557 views

Why does the documentation call functions “pure”?

Clearly, functions in mathematica are not pure functions according to the definition on Wikipedia (no side effects - basically implementabe with table lookups): ...
1
vote
1answer
1k views

What does the slash-colon symbol do?

I came across a bit of code that uses the syntax /: and I don't know what it does. I can't find its documentation, or maybe I'm just not looking properly. The code ...
8
votes
2answers
232 views

Keywords to find documentation for this syntax

Mathematica allows this syntax, but I cannot find any documentation (or books) that discuss the various uses/advantages of it ...
7
votes
4answers
276 views

Iteration of functions

I'm trying to define a function f, such that f[a_]:=a; f[f[a__]]:=f[a]; Then, I tried to evaluate f[x,y]. Since ...
5
votes
2answers
611 views

Assignments in ParallelDo when using indexed variables

For convenience I use an indexed variables syntax to hold results of long computations for different integer parameters: ...
7
votes
2answers
253 views

Apply ToString to a list of variables [duplicate]

I have data1 = {1, 1}; data2 = {2, 2}; datalist = {data1, data2}; I want to create a string list based on the variable names inside ...
6
votes
2answers
205 views

WL terminology: evaluate, call, invoke, use, etc

A WL (Mma) program is a sequence of expressions to be evaluated, which generally involves applying commands and functions to actual arguments. What is the accepted terminology for what I think of as ...
6
votes
2answers
211 views

What makes a pattern more general?

This is a rewording of the question. The original post is below. How come that a pattern for an expression with a specific head is not more specific than a pattern for an expression with a generic ...
11
votes
2answers
1k views

Solve a nonlinear PDE equation with a Neumann boundary condition

I am trying to use Mathematica 10 to solve a PDE $$u_t=u_{xx}+u_{yy}+u(1-u),$$ in the unit disk $(x,y) \in D=\{(x,y):x^2+y^2<1\}$, with the Neumann boundary condtion $$\frac{\partial u}{\partial n}...
6
votes
1answer
618 views

What does it mean when a function is defined with two pairs of brackets

I have noticed a function defined as such: f[x_][y_] := expr; How is the argument y in 2nd pair of brackets being used? What is the difference from defining a ...
7
votes
1answer
1k views

Difference between variables and functions

Forgive me if this question is very basic; I've learned Mathematica mostly by example. In most programming languages, there is a clear distinction between variables and functions: variables hold ...
2
votes
2answers
106 views

What is the point of tagset /:? [duplicate]

I'm teaching myself Mathematica and came across tagset. So I followed the example in the link, but seem to be missing the point. All of the below give me the same answer after assignment: that ...
11
votes
2answers
316 views

Why is `D[a[b][c],a[b]]` equal to `1[c]`?

Background: I had the same issue as described here, and I went to extend Mr.Wizard’s code such that a[b][c] would be shown as $a_b^c$. Issue: To my surprise, ...
4
votes
1answer
258 views

Define scalar quantity that squares to 1?

My equations contain different cases which differ only by some signs. So in order to work with all cases simultaneously, I introduce a placeholder for a sign: s[x] ...
7
votes
1answer
200 views

Graphics Function Definition Style (Using SubValues vs. DownValues)

I am going through some of the items in "Modern Differential Geometry of Curves and Surfaces with Mathematica, Third Edition". An example of the style used by these authors is: ...
4
votes
1answer
262 views

How do I get Mathematica to recognize this simplification? (ReplaceAll pattern rule)

I want Mathematica to understand this $$(\sum_{k=0}^n a_k)(\sum_{j=0}^n b_j) = (\sum_{k=0}^n \sum_{j=0}^n a_k b_j)$$ I have tried this ...
1
vote
1answer
360 views

Plot 3D doesn't show anything

Good Evening, I defined a function which is composed of other several functions. Mathematica compiles well but I can't get a plot and I do not understand way. Can anyone help me with the code and ...
1
vote
2answers
129 views

I want to plot a list of points with specified t and x[t] coordinates [closed]

I have this code: ...
0
votes
1answer
715 views

Compute the half width and full width at half maximum (HWHM / FWHM) of a mathematical expression

I have managed to compute the half width at half maximum (HWHM) and full width at half maximum (FWHM) of a sinc function through the code below. ...
2
votes
1answer
783 views

Partial derivative of defined function with vector input

Background: Have written a formula for the refractive index for a glass slab (n) that depends on the variables t,a and d. Now I want to calculate for example some sort of error and I'll be needing to ...
1
vote
1answer
380 views

Create a function with Dt[x] as a variable

I have a function (for example F[x_]:=Cos[x]). I want to define a function like Fdot[x_,xdot_]:=Dt[F[x]] where xdot represents Dt[x]. For example, to define Fdot one might naivley try Fdot[x_,Dt[...
3
votes
1answer
214 views

I want to compute the derivative of Black and Scholes option

Good evening to everybody, my question is about computing the derivative of a Black and Scholes option and to draw it. My code is ...
1
vote
2answers
198 views

How to deal with the condition that a function own many options?

Assming that I have a function myFunc which has some options. ...
1
vote
1answer
144 views

Requesting explanation of FitModel code

I am struggling with understanding the code given in this original post I understand how the tests are conducted, both of them. However, I do not understand this part: ...
1
vote
1answer
298 views

VectorPlot3D of the Electric Field E as Determined from the Potential V

I am new to Mathematica and I am trying to create the electric field $F$ from the electric potential $V$ (using arbitrary distances) and then plot the subsequent vector graph to show that the electric ...
1
vote
1answer
467 views

NDSolve memory usage [closed]

I am trying to solve numerically a system of linear ODEs with some quickly varying driving functions. The basic command is: ...

15 30 50 per page