Questions on the basic structure of the Mathematica language (Wolfram language) including atomic data types, syntax etc

learn more… | top users | synonyms

13
votes
1answer
329 views

Why is an Identity function needed?

Today I came across the function Identity[x] in Mathematica (documentation). The example given in the documentation uses it in ...
1
vote
0answers
19 views

How to ValueQ a symbol, constructing the symbol name from strings? [duplicate]

In a function I'm writing, I need to check whether a particular symbol has been assigned a value (any value) in a particular context. This would work: ...
9
votes
2answers
214 views

Pattern and Orderless function

I'm a Mathematica beginner. I am exploring the use of patterns and (only for fun) am trying to implement a permutations function. My (dirty) code is: ...
0
votes
1answer
39 views

Could I use Select with condition on any column other than First (Last)? [closed]

I often deal with huge tables of various functions of randomly generated values for my research. Sometimes there's need to only keep rows which satisfy a specific condition. This is easy with ...
1
vote
0answers
72 views

What's in a Name? [closed]

StringReplacePart["StringReplacePart","At",{14,17}] ... Surely you can't be serious? ... Naming Matters: I think what and how we call things is underestimated ...
2
votes
1answer
58 views

How can an argument of the form f[t] be injected into the RHS of a function definition [duplicate]

This is what I want, for an arbitrary function x This is what I have done: ...
7
votes
2answers
102 views

Cannot Block Plus

It is customary to use the following idiom to partially evaluate something inside a held expression: ...
0
votes
1answer
35 views

The FindRoot output only with numbers [duplicate]

I have this code in Mathematica: FindRoot[{Sin[x - y + 2] - x == 0, Sin[2 x - z] - 8 z == 0, Sin[z + y + z] - 2 x == 0}, {{x, 0}, {y, 0}, {z, 0}}] where it's ...
0
votes
2answers
50 views

How to make Mathematica to assemble components we already have like a regular input

Suppose we have the following list: {5, 3} I want to add the -> to the end of the first element in the list in Mathematica ...
1
vote
1answer
67 views

How should I enter indexed terms? For example, constants $n_k$ for $k\in\{1,\,\ldots,\,N\}$

How should I enter $\quad \quad \sum^{N}_{k=0}{f(n_k)}$ into Mathematica? More generally, how should I work with the indices? Take the following as an example. I know how the ...
4
votes
1answer
50 views

Boundedness of an expression

First post on this part of the stackexchange network, I was just wondering if Mathematica allows one to quickly see if an expression is always within a certain range given values for the parameters it ...
1
vote
1answer
80 views

A question on using Cases [closed]

I am working on Wagon's FindRoots2D section. Clear[f]; f[x_, y_] := x - y^2 Cos[y]; g[x_, y_] := -y + x Sin[x]; fcnVec[{x_, y_}] := {f[x, y], g[x, y]}; I am ...
0
votes
1answer
62 views
1
vote
1answer
69 views

DownValues when using Set and SetDelayed

It is known from several questions asked in SE that one of the basic differences between Set and SetDelayed is that the former ...
0
votes
2answers
37 views

Equality of expressions containing complex numbers [closed]

I am using Mathematica to test the equivalence of symbolic expressions. I run into what appears to be a bug when I test the equivalence of expressions involving an imaginary number taken to a complex ...
3
votes
1answer
43 views

Order of evaluation of Exp and Normal on result from Series

This may be more math related than Mathematica related, but I thought this might be of interest to the group. I'm trying to work with some Taylor Series approximations of functions that are ...
6
votes
1answer
67 views

Is $ModuleNumber working properly on my machine?

In the documentation ref/$ModuleNumber, I read: Every Wolfram System session starts with $ModuleNumber set to 1. Yet, when I quit Mathematica 10.1 (OS X 10.10.4), restart it, open a new notebook ...
3
votes
3answers
141 views

How I can count multiplications in an experssion?

Next task to complete: Count *-symbol in such expression as a + s^2*b - c/y + o^3 + n*m*u (in this case count of ...
0
votes
1answer
74 views
14
votes
1answer
233 views

What's wrong with Simplify and FullSimplify?

I have a quite complex list of equations and inequalities I combine to a boundary condition for my cost function. After investigation of two days I found the bug (I really name it a bug!). One of my ...
0
votes
1answer
67 views

Draw a number of rectangles from list of coordinates [closed]

I'm new to Mathematica and this is also my first post here. Now for the question: I try to let Mathematica draw a number of rectangles from lists of coordinates. Unfortunately it only works when I ...
1
vote
2answers
71 views

What is the meaning of Range[10] /. {x_ /; PrimeQ[x] -> x^2}? [closed]

I'm currently doing a unit at university that touched briefly on Mathematica, but the final exam will feature multiple choice questions from Mathematica (along with excel and matlab). This leads to ...
9
votes
4answers
233 views

How to Thread with custom functions? Thread vs Map?

This function finds n given the nth prime: findPrime[n_] := If[PrimeQ[n], i = 1; While[Prime[i] < n, i = i + 1]; i, False]; This works: ...
4
votes
1answer
143 views

What is the relationship between Thread and MapThread

I hope this is not a silly question, since there are plenty of questions on Thread and MapThread. However, I still cannot quite ...
12
votes
1answer
163 views

Is there a way to control which special forms Normal converts?

Normal documentation reads: Normal[expr] converts expr to a normal expression, from a variety of special forms. But is there a way to control which special ...
3
votes
3answers
161 views

How to assign symbols to functions

Several functions work with symbols in MMA: Take for example Part: l1=l2=Range[4]; l1[[3]] (*3*) l2[[4]] (*4*) I want to make ...
0
votes
0answers
45 views

Treating expressions as symbols [duplicate]

I'm trying to do something like this: test = {x, y}; With[{test[[1]] = 3}, x/y] However, the following error is printed: With::lvset: "Local variable ...
0
votes
2answers
41 views

Using Nest on a function that takes a function as one of its arguments [closed]

I have a function, nS[f_, xk_], which takes as arguments a function f and a vector xk. It ...
5
votes
0answers
156 views

Built-in symbols which are more close to the root/core of Wolfram Language

Seeing the vast scope of science covered by the Wolfram Language (WL) and the large amount of built-in symbols (functions), I am curious to know which built-in symbols are more close to the root of ...
0
votes
1answer
87 views

Solving a vector equation [duplicate]

I want a simple and intuitive way of solving for $t$ given that $\mathbf{i},\, \mathbf{j},\, \mathbf{k}$ are the unit vectors in $\mathbf{R}^3$. $$ 5 = (2 \mathbf{i} - 3 \mathbf{k} + (\mathbf{i} - ...
3
votes
1answer
93 views

How to deal with Part in a function?

I need to iterate several functions such as {3 x[[1]]^2 + x[[2]], x[[2]], x[[3]]}, {Exp[x[[4]]], x[[2]], x[[3]], x[[4]]},etc. ...
2
votes
1answer
72 views

Can I use Switch with an inequality? [closed]

I'd like to have something like: Switch[x, 10, a = 3; b = 7, >10, a = 5; c = 6, _, a = 7; d = 12, b = 1]; I can't seem to get this to work.
0
votes
1answer
69 views

solving quadratic and linear congruences with different modulus

We are able to solve the quadratic congruences $C^2 + Q^4 - 2\equiv mod 3072$ and $C - Q^2 - 2046\equiv mod 3072$ by entering ...
3
votes
2answers
91 views

How to use an expression for the argument to a function [duplicate]

I would like to define a function over a list of variables like f[a_,b_,c_]:=a+b+c However, when this list is big it makes uncomfortable to read. Can I somehow ...
2
votes
1answer
56 views

Expressing a definite integral as pure function with the upper-bound as it argument

Suppose i have an integral which has a closed form, $\quad \quad \int_{a}^{b} f(x) dx=F(a,b)$ I want to use output function $F$ as a pure function, like ...
1
vote
2answers
60 views

Perform operation on part of a table / create a reference

There is a function f that I would like to operate on a rectangular part of a table t. The part is specified by function ...
0
votes
1answer
67 views

Suppressing tiny imaginary parts in complex numbers [closed]

How do I extract the real part of a substitution expression from FindRoot or Solve? Or alternately, how do I insist that they ...
0
votes
1answer
74 views

Create an array with certain conditions and use it to fill a matrix [closed]

I am translating my code from Python to Mathematica. Here is a piece of my Python code: ...
1
vote
1answer
71 views

Defining a function of matrices [closed]

I am translating my code from Python to Mathematica. How can I define a function similar to the following: ...
0
votes
0answers
50 views

Substitution Permutation Network (SPN) - Decryption In Mathematica

I am working with a Substitution Permutation Function, SPN, in Mathematica. I have an encryption function for an SPN. By changing the parameters that go into the spn function, and not the function ...
3
votes
0answers
158 views

Minimalistic code challenge on Apollonian gaskets

I've been recently fascinated by the beauty, symmetry and mathematical richness of the Apollonian gaskets. So I felt myself challenged to see if it was possible to generate one in Mathematica with ...
0
votes
1answer
42 views

Generating comma separated input for LCM [duplicate]

I would like to calculate the Least Common Multiple of the 100 first numbers. I've tried with LCM[Table[i, {i, 10}]] But it produces a list instead of the right ...
3
votes
0answers
151 views

Mixing Wolfram Language & WolframAlpha Queries - How robust is it?

The advent of Mathematica in the cloud and linguistic input potentially transforms expectations of the Wolfram Language's programming model and its inherent robustness. An example of this comes form ...
7
votes
1answer
96 views

Context-dependent functions

TL;DR warning! My question is not about getting the length of the ticks correct (although if someone has good suggestions, that would be welcomed). My question is about constructing functions that ...
2
votes
4answers
196 views

How can I make a summary of all the commands of Mathematica?

I would like to have a simple way to get summary information about all the many commands built into Mathematica. How could I do this? Is there a site I may refer to?
0
votes
0answers
35 views

How can I change this function for the better? [duplicate]

I have a function for an lfsr (linear feedback shift register): ...
2
votes
2answers
148 views

Can a pattern examine all partitions of a sequence?

Say I have a list: {a, b, c, d}. I'd like to check that the list has some partition, say {{a, b, c}, {d}} such that all the elements of the partition satisfy a ...
10
votes
3answers
186 views

How do I make a string literal without having to escape backslashes?

I'd like to say something like: foo = @"\abc\def\ghi" instead of foo = "\\abc\\def\\ghi" How do I do this? This would ...
0
votes
1answer
66 views

Getting error Import::chtype when mporting 2D array of images [closed]

Suppose I have images = {{1.jpg, 2.jpg}, {3.jpg, 4.jpg}} Now I try to import all of them at level 2, ...
0
votes
1answer
52 views

How to destructure local variables?

Why can't I use this Where[{iw, ih} = ImageDimensions[i], ...] instead of this ...