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
1answer
40 views

While Loop Not Looping [closed]

no matter what I do, the following function always returns the first v. This does does not make sense to me at all. It should loop and reevaluate v and only stop when v matches the condition. What am ...
0
votes
1answer
47 views

Position of elements in a list satisfying some criteria - Understanding the syntax [closed]

From this post: if one wants to know the position of the elements of a list that satisfy some criteria, (s)he can do something like that: ...
1
vote
2answers
44 views

How to get the outermost command evaluated first?

I have an expression like ToString[Stuff[...]]. I plan on having the Stuff[...] be manipulated as a string according to the output of other parts of the program. The problem is that Mathematica tries ...
2
votes
1answer
69 views

Array in Sum in Minimize - error “Part specification x[1] is neither a machine-sized integer”

Help please M = 10; z = Array[x, M] {x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10]} ...
2
votes
1answer
49 views

RegionUnion issues with many Regions

The new RegionUnion[] function is just what I needed if only I could get it to work. I have many non-overlapping regions that I will need to use as plotting domains ...
0
votes
0answers
41 views

How can I mix // with a function of two arguments? [duplicate]

I often find myself using // when playing around with expressions, but it is always cumbersome to have to switch to the full notation just to apply a function of ...
9
votes
5answers
301 views

Postfix Double Slash Notation with Multiple Parameters [duplicate]

Examples A convenient shorthand that I use frequently is the "double slash" notation to string commands together. For example, I can write: ...
1
vote
1answer
83 views

How a novice user better understand the Q/A [duplicate]

A novice user reading Q/A here: I sometime need to just understand the syntax and meaning of commands exampled here. where is the best place to find it?
0
votes
1answer
63 views

Moment generating function for custom distribution [closed]

For some reason the following fails. I tried everything I could, and I don't know what else to try. ...
12
votes
0answers
124 views

A documented syntax of FileNames doesn't work?

According to the documentation for FileNames: However when I attempt to use this syntax I get an error: ...
5
votes
3answers
252 views

Element-wise list operation on list of lists [closed]

Suppose a function F operates on list A: $$A=\{a_1, a_2,\cdots, a_n\}$$ I have a list of lists, B: $$B=\{A_1, A_2,\cdots,A_m\}$$ Is there a syntax to specify that F should operate on members of B, ...
1
vote
0answers
51 views

CreateDialog opening two windows instead of one

I'm having issues working with code from Mathematica 9.0.1 since I've updated to 10.0.0. My previous code involved using packages to set functions, and then those packages were loaded and the ...
1
vote
0answers
84 views

SyntaxForm not correctly parsed by FrontEnd

When using TagBox with SyntaxForm, I noticed sometimes it is not well parsed by the ...
1
vote
1answer
61 views

Appending functions to a list [duplicate]

Could someone please explain the difference between these methods, and possibly a nicer way to get the first result? (This is a toy example and in my real program I'd like to use ...
4
votes
1answer
171 views

How to see abstract syntax tree of Wolfram Language expression

I mean, suppose I have this expression: 2 + 2 I want to get something like this: Plus[2, 2] as an output. I've tried FullForm, but this just evaluates 2+2 and returns 4. Is this even possible?
5
votes
4answers
162 views

Defining a function with parameters as variables

I have an expression V = (a[1] + a[2])b[1]. How would I define a function of a[1], a[2] and ...
35
votes
1answer
726 views

Incompatible Changes since Mathematica Version 7?

There is documentation of the incompatible changes made to Mathematica with each major release: Incompatible Changes since Mathematica Version 1 Unfortunately that documentation simply stopped ...
36
votes
5answers
1k views

V10's Operator Forms - what are they good for?

V10 introduces an operator form for several functions perhaps primarily due to their role in queries as part of introducing data science functionality. At first pass it seems a lot of effort to add ...
4
votes
2answers
74 views

Why can't I pass in a product of matrices in my modified matrixform? [duplicate]

In attempt to build a function that would work like MatrixForm but would wrap a matrix with brackets, I tried the following function: ...
1
vote
1answer
61 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 ...
5
votes
3answers
409 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 ...
0
votes
1answer
57 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 ...
18
votes
1answer
343 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 ...
13
votes
2answers
228 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
57 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
56 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
47 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
67 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?
7
votes
1answer
148 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
212 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
91 views

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

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
133 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
141 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]. ...
5
votes
2answers
157 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
61 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 ...
0
votes
1answer
119 views

Getting “Null” output from package?

I have a script written to test a package as follows: ...
1
vote
1answer
48 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
75 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
109 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
63 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
83 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
175 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 ...
2
votes
0answers
45 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 ...
2
votes
1answer
233 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
3answers
78 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: ...
0
votes
0answers
31 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 ...
4
votes
0answers
188 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
74 views

Meaning of backtick in conjunction with units [duplicate]

In this fragment from an equation solution the backtick is used twice: ...
0
votes
1answer
146 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: ...
4
votes
2answers
139 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: ...