Questions on correct (or improved) formulation of Mathematica code to achieve particular results. Use this tag (not "symbol") for questions about all those odd @@ /@ # & and ~ characters.

learn more… | top users | synonyms

0
votes
0answers
30 views

Let's Make a formula [on hold]

Gents, Could you please assist to create a single line MATH formula for: We have numerous 4 element sets. We need to show X sets that are equals to Y. IF m{X} < X then add sets that are equals to ...
1
vote
1answer
52 views

How would one minimize with respect to an unknown number of variables?

Say I had a function like the following: f[n_] := Sum[a + Subscript[b, k], {k, 0, n}] Such that ...
4
votes
3answers
372 views

What is the right way to write a function that includes other functions?

I want to include multiple sub functions: $b(x) = 10x$ $w(x) = s + b(x)$ $c(x) = x^2$ into two main functions: $ua(x) = w(x)-c(x)$ $ub(x) = w(x)-c(x)^2$ As a reaction to this answer, I wrote ...
29
votes
5answers
878 views

Why is there no PositionFunction in Mathematica?

Too often I have seen the programs of inexperienced users greatly slowed by using Position in an iterative fashion, when far faster would have been to compute a ...
10
votes
2answers
194 views

Why doesn't a Composition[] hold its arguments and what can be done about it?

Now that Composition (also RightComposition) has shorthand syntax I am more inclined to use it, however what I feel should be ...
0
votes
1answer
53 views

Is there a command returning information about a particular object? [closed]

Suppose I have a variable var1, a function MyFunction, and a graphic SomePlot. I remember ...
12
votes
1answer
234 views

Shorter syntax for Fold and FoldList?

I find it tedious to write out the following: a = {1, 2, 3, 4}; Fold[f, First @ a, Rest @ a] f[f[f[1, 2], 3], 4] It ...
0
votes
1answer
43 views

Combining functions - is this a case for Piecewise?

I have a function $Eb1$ which was the subject of a question I asked recently - you can see it here on stack exchange. Now, in that example it's specified between a boundary $r_n$ and $r_o$ where $r_o ...
0
votes
0answers
37 views

Resolving initial / boundary condition conflicts ?

This is likely very simple, but I often run into trouble with inconsistent boundary conditions for PDEs; While I know Mathematica sometimes produces "false" errors for spatial derivative conditions, ...
2
votes
1answer
39 views

How to joint symbolic expressions together [duplicate]

I want to joint symbolic expressions together to create a another symbolic expressions. one way to do that is as follows: ...
2
votes
2answers
55 views

Using Table with arbitrary number of variables [closed]

Let $P=\{p_1,...p_n\}$. I would like a way to implent Table[Expression,{$p_1$,lim},{$p_2$,lim},...,{$p_n$,lim}] where n and lim are parameters defined by the user. Any ideas?
6
votes
1answer
113 views

Extract what symbol is set by SetDelayed, Set, TagSet, UpSet, SetAttributes, etc

One of the recent features of the Mathematica Plugin for IntelliJ IDEA (www.mathematicaplugin.halirutan.de) is a Structure View which let's you see information about several definitions that are done ...
4
votes
2answers
86 views

Scalar product operator of complex vectors

What is the scalar product operator for complex vectors (or matrices) in Mathematica? The usual $Dot[]$ doesn't work. E.g. here is what the Mathematica gives $$\{1,0\}.\{I,0\}=I$$ but the answer ...
0
votes
1answer
64 views

How do I plot a Taylor polynomial of various degrees in two variables?

I want to plot the Taylor polynomials of $f(x,y)= Sin(1 + x + y^2)/(4 + x^2 + y^2)$ of degrees 4 and 7 around the point $(0,0)$ over the rectangle $[-\pi,\pi]\times [-\pi,\pi]$ I am currently using ...
0
votes
1answer
117 views

Differences between 'Solve' and 'LinearSolve' [closed]

Using the function 'Solve' I can do the following: Solve[a x + y == 7 && b x - y == 1, {x, y}] I get the following output: I want to get the same output using 'LinearSolve' instead. How ...
0
votes
1answer
59 views

How to output a bat file and execute it?

I tried to write a bat file which helped me rename files. Command to do this in that file is "ren file1 file2" which is equivalent to RenameFile[file1,file2]. ...
0
votes
1answer
76 views

Getting “Null” output from package?

I have a script written to test a package as follows: ...
4
votes
3answers
720 views

Matrix Multiplication in context of row and column vectors

I've been looking at some matrices in Mathematica and I've noticed something very weird: They're extremely temperamental when it comes to dot products! For example, if I have the following, ...
5
votes
2answers
137 views

Syntax highlighting conflict

I'm trying to syntax highlight this expression: x=$\sqrt{\pi }$//N and from various sources I've learned that x (the assigned symbol) belongs to context Global while the Pi and N belongs to System. So ...
0
votes
0answers
53 views

My “N” turned red randomly [duplicate]

For some reason my N function showed up in red even though I haven't noticed it in that color before. The color actually makes the code much more readable but I just don't know if I should be alarmed ...
1
vote
1answer
46 views

Correctly substituting a matrix into a scalar equation [duplicate]

I am having trouble correctly substituting a matrix into an (originally) scalar equation. For example: A = {{3, 1}, {1, 2}} cp = CharacteristicPolynomial[A, x] ...
3
votes
1answer
66 views

Highlight the same symbol throughout notebook

Once I saw people using Matlab use a keystroke shortcut that made all the same symbols as a selected symbol become blue. I am wondering is there is a function in Mathematica that is similar. If so, ...
8
votes
1answer
104 views

Does the syntax coloring I see indicate a real problem?

I need a behaviour provided by: x = 2; Block[{x = HoldForm[x]}, x] x FrontEnd marks ...
0
votes
2answers
43 views

Setting an element of an array to a value

This may be a simple syntax question, but for some reason I've been having trouble with it. Suppose we have an array arr, and we want to set one of the elements to ...
1
vote
1answer
68 views

Sort lists of vertices {indegrees, outdegrees} by indegree

in = VertexInDegree[F]; out = VertexOutDegree[F]; I want both in and out to be ordered by in. Example: graph has nodes a,b,c with indegrees 1,2,0 and outdegrees ...
2
votes
2answers
126 views

Matrix exponential via Cayley-Hamilton Theorem

I'm attempting to calculate the exponential of a matrix via Cayley-Hamilton theorem. (Following the "concrete example" from http://en.wikipedia.org/wiki/Cayley%E2%80%93Hamilton_theorem) I am having ...
1
vote
0answers
33 views

Why is `Cell` > `Convert To` > `InputForm` not invertible?

I sometimes post code to PhysicsSE, and I usually convert it to InputForm first before posting, in order to avoid pages and pages of ...
0
votes
3answers
72 views

Half kth term if n is even and k=n/2?

I am trying to write a function which will perform the equation in the attached image. So far, I have: ...
2
votes
1answer
104 views

Matrix exponential MatrixExp[] vs Sum[MatrixPower[]] doesn't match?

I might be an idiot, but I cannot get the manual expansion of e^At to match the MatrixExp[A t] result. For example, I have the following: ...
0
votes
0answers
24 views

How to change FormatType for output and Syntax error separately?

For some demand, I am using MathMLForm for all output SetOptions["stdout", FormatType -> MathMLForm] But this effect the syntax error format as well.(it's ...
1
vote
2answers
627 views

How does one specify Neumann conditions for NDSolve?

I have a series of functions defined in my notebook, and then want to use this to solve a diffusion-reaction type equation. At the moment, something like this works: ...
3
votes
0answers
147 views

Do any mainstream text editors support Wolfram Language syntax for highlighting?

Syntax Highlighting for Mathematica on a Blog There is the above, but I'm not terribly excited to install rogue packages. For example on github, I share lots of Mathematica code. I see no way to ...
0
votes
0answers
52 views

Meaning of backtick in conjunction with units [duplicate]

In this fragment from an equation solution the backtick is used twice: ...
25
votes
2answers
925 views

Meaning of backtick in floating-point literal

If I compute, say, 1/3//N, Mathematica displays 0.333333 as the result. When I copy that output to use elsewhere, the paste ...
0
votes
1answer
103 views

How to plot a region bounded by three equations?

I'm very new to this website. I am having trouble plotting a 3 dimensional region bounded by these equations: ...
6
votes
4answers
163 views

How to select only NotebookObjects that are referring to ordinary notebooks? (not palettes etc.)

There is of course function Notebooks[] But, unfortunatelly it hasn't got useful options in this context. My question is how to pick ...
4
votes
2answers
121 views

Replacing a function in defined expressions

I'm having a little trouble with substituting functions into an expression. A minimal example is as follows: ...
0
votes
0answers
43 views

TableDirection in TableForm

I got confused about what does "the outermost dimension" and "the first dimension" mean in the document I snipped. Does it mean row or column?
4
votes
2answers
168 views

How can I avoid getting the error message Goto::nolabel in my code?

If anyone could suggest a reason why Label[begin] ... Goto[begin] would return Hold[Goto[Begin]], and (better) how can I avoid ...
0
votes
1answer
125 views

Issue with Compile

The following code works fine with the the function f defined as a module, however, when I convert it to be a compiled function, it gives me errors. Can some one ...
1
vote
1answer
203 views

Compile with array operations

When I use the function f with only the Module ...
1
vote
1answer
37 views

How to set the values into some variables from different lists [closed]

I have a list of Values and a list of variables. I want to set the Values into Variables. Assume the following code: ...
19
votes
4answers
5k views

Is there a syntax for single-line comments for notebooks?

I'm aware that I can use (* ... *) to comment out stuff in a notebook. Many languages have a syntax for single-line comments, such as ...
0
votes
2answers
67 views

Determining whether or not an expression is an integer

I'd like to define a function that controls if a certain number is an integer, rational, algebraic and so far. First, I tried generating a list of those numbers: ...
6
votes
1answer
103 views

A question about two ways to use Default

Usually we define a function with default values by the syntax x_:default, but there is another technique to do this by registering a global default value with ...
1
vote
2answers
132 views

MapThread with List Manupulation

I have the following three lists: ...
1
vote
1answer
77 views

How to input pure function to package?

I would like to input a pure function into a custom written package, but am running into a variety of errors. The package I have created is as follows: ...
1
vote
2answers
125 views

How to evaluate Modules in a notebook from another notebook?

I would like to create a notebook populated with several modules and be able to evaluate these modules by running a separate notebook. I have attempted several uses of the ...
0
votes
1answer
78 views

Normalize equation in NDSolve?

I have numerically solved and plotted the solution to the Mathieu equation using NDSolve successfully, as below: ...
8
votes
2answers
366 views

How to create custom Graphics primitive?

How to create custom Graphics primitive? It should have the following properties, resembling properties of built-in geometric figures, like ...