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
93 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
147 views

Compile with array operations

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

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

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
4k 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
55 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
85 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
124 views

MapThread with List Manupulation

I have the following three lists: ...
1
vote
1answer
59 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
84 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 ...
6
votes
3answers
131 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 ...
0
votes
1answer
61 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
317 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 ...
0
votes
1answer
66 views

Populating an array with outputs of a function [closed]

I have searched, but didn't find much help on my issue. I have an optical physics problem that I'm working on .. ...
22
votes
6answers
414 views

Constructing symbol definitions for With

I would like to be able to define two arrays, one containing symbol names and one containing the values of those symbols, for use in constructs such as With. For ...
1
vote
1answer
69 views

Why there is no SlotSequence (##) form analogical to #[[ ;; n]]

I'm aware that this may be closed as offtopic but there are people around with "offtopic" knowledge :) So, in List context we can: ...
6
votes
1answer
69 views

Head of a MatrixForm expression?

An example in http://www-zeuthen.desy.de/theory/capp2005/Course/hahn/mathematica.pdf amounts to the following ...
0
votes
1answer
35 views

Convert variable into function

Sorry if this is a duplicate, but I have a variable called H. H is some complicated function of ...
2
votes
1answer
66 views

MapThread over a nested list

This may be a simple question. Please close it if it is already answered. I have a nested list kr = {{35, 32, 27, 20}, {36, 33, 28, 21}, {37, 34, 29, 22}} I ...
0
votes
1answer
26 views

Square root of a value defined in a finite field?

I am trying to find the right way to compute the square root of a number defined in a finite field. For example, ...
5
votes
2answers
316 views

Multiply each element of an array by another array?

I would like to multiply an array by each element of another array, and am having a lot of trouble finding a built-in or automated method of doing. Here is an example of what I'd like to achieve: ...
0
votes
0answers
29 views

g00 (metric tensor) not explicitly evaluated in FeynCalc

I am learning Mathematica and FeynCalc by doing some basic cross section calculations. I have an issue with trace calculations: When I plug in for instance the ...
1
vote
4answers
101 views

Finding a number which has the same remainder when dividing certain other numbers

I am having some trouble with formulating my problem in Mathematica for this question: Is there a number greater than 1 which leaves the same remainder when it divides into 1716, 2154, and 4271? ...
1
vote
1answer
84 views

How to programmatically comment out multiple source files?

How to programmatically comment out the entire content of multiple .m source files assuming they start with correct Mathematica syntax? I need it to be robust so ...
0
votes
0answers
37 views

Using derivative d in Mathematica [duplicate]

In mathematics derivates are often written like $$d^2y \over dx^2$$ or $$dy \over dx$$ In Mathematica we have the function D, but is it possible to use a similar approach?
0
votes
1answer
154 views

Please explain this code (contains Append, Do, Coefficient)

I am a graduate student using a past student's Mathematica program. Will someone please explain to me exactly what this piece of code is doing? Specifically the ...
0
votes
0answers
41 views

Using Table[ ] vs using Do[Append [ ] ] [duplicate]

Is it generally better/faster to use the Table function over using Do[Append []]? For example, I have this piece of code: ...
3
votes
2answers
113 views

How to define the irrational domain or any other arbitrary domain?

I have found no way to define the domain of Irrational numbers. I can easily define a test to see if a number is irrational by defining: ...
0
votes
1answer
70 views

How to write series of Do[ ]'s with a single Table[ ]?

Edited to provide more information (sorry I don't know how to format matrices here) I would like to replace: m = 4; ...
0
votes
0answers
70 views

Why is my answer being displayed with “Subscript^(0,1)[a,b]”?

I type in my equations using ctrl+- to make it look nice and my answer outputs in "Subscript^(0,1)[a,b]" form? What is going on? In the answer some bits are displayed with the actual subscripts and ...
3
votes
1answer
82 views

Differentiating a Dot Product

I apologize if this type of question has been asked before, but a preliminary search turned up nothing. I would like to differentiate dot products. For example, consider taking a derivative with ...
0
votes
1answer
65 views

KroneckerProduct and Transpose [closed]

I need to take the KroneckerProduct of the an $n \times n$ identity matrix and a $1 \times n$ row vector (let's call it $T$), both of which are numerical. As in: ...
0
votes
2answers
110 views

How to display output as symbols?

I have this piece of code which populates a matrix following different rules depending on row and column number: ...
3
votes
1answer
91 views

Why is ^^ff not the same as ^^ToExpression[“ff”]?

I want to convert a hexadecimal string to a decimal (base 10) number: 16^^ff 16^^ToExpression["ff"] The 1st line returns the correct answer of 255, while the 2nd ...
0
votes
1answer
79 views

Holding Input Windows

I am creating a Mathematica document which contains a list of proofs in various fields of Mathematics so that I can easily review whenever I would like. First, I create a large set I call 'proofs' ...
1
vote
1answer
91 views

Looping with NDSolve?

I have a series of PDE equations that are solved with NDSolve for certain variables $a$ and $b$ - Now, I want to see the output at a time $t$ as $a$ and $b$ change; so I was thinking of a loop ...
2
votes
2answers
87 views

Return only one numeric solution to equation [duplicate]

Consider a simple plane equation 2x-3y+4z==7 I just want some position vector on that plane. For example, {7/2,0,0} would be ...
6
votes
2answers
381 views

How to reverse the direction of the y axes

I have a similar question to this one. Unfortunately, the answers there didn't help me. I would like to plot a simple function with the normal Plot function. ...
2
votes
3answers
320 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, ...
4
votes
1answer
67 views

Dot when used in a pattern becomes Times… Why?

In[1] := Hold[a.b] // FullForm Out[1] := Hold[Dot[a,b]] So far so good. ...
0
votes
0answers
20 views

Incorporating Built-In Function Options/Parameters into Shorthand [duplicate]

Shorthand syntax provides an alternate way to apply functions and, in many cases, improves readability. A simple example would be ...
1
vote
2answers
144 views

Conditional range in a parametric plot

I have a program that needs to be done like this: ParametricPlot[ equation, If[x < 1, {x, 0, t}, {x, t, 2}]] But Mathematica didn't seem to recognize the ...
6
votes
1answer
131 views

How can I define a ⊕ operator?

What is wrong with the following code? CirclePlus := SparseArray[Band[{1, 1}] -> {##}] & a_ ⊕ b_ := CirclePlus[a, b] SetDelayed::write: Tag Function in ...
3
votes
1answer
57 views

Pathological behaviour when evaluating a sum

When I declare the function $f$ as follows: f[n_] := Sum[x/Sum[Sqrt[y], {y, 1, x}], {x, 1, n}]/n the input ...
1
vote
2answers
167 views

Making nice code: choosing one of several procedures

Happy new year mathematica gurus of stack exchange! As I see it one of the major obstacles in getting decent at programming mathematica is that, not only do you need to learn how certain commands ...
6
votes
1answer
100 views

Why can Format be used on the left side?

I am learning Mathematica in random order by reading its documentation. This approach is what I like most when learning new things. Consider the following 2 cases. Syntax A: ...
3
votes
2answers
101 views

Why does the iterator index in Table not work here?

I type the following command line Table[D[#1,varx[[i]]] &,{i,3}] where varx is a vector of dummy variables ...
2
votes
1answer
216 views

What are the min and max arguments to EdgeDetect?

What are the min and max arguments to EdgeDetect, for all methods and specifically "Sobel"? How do I find the limits or ranges ...
1
vote
2answers
127 views

Changing Default Color for Titles, Sections, Subsections, etc., and Items (bullet color) [duplicate]

I'm new to Mathematica 9, and I assume there must be an easy fix for my problem, but I have not been able to find any yet. Essentially, I want the default color for the text of all of my titles, ...
6
votes
5answers
277 views

Is it possible to insert arguments into functions when they're used like Function@ or //Function?

Is it possible to insert arguments into functions when they're used like Function@ or //Function? Sometimes I need to do this, but then I have to return to the standard function usage: Function[] ...
2
votes
2answers
96 views

Is it possible to use infix notation ~ for functions with one argument or more than 2 arguments?

According to a Mathematica textbook, we can write N[x,n] by using infix notation as x ~ N ~ n. How about other functions with ...