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

learn more… | top users | synonyms

7
votes
1answer
64 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
57 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
67 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
228 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: ...
3
votes
1answer
129 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 ...
11
votes
1answer
156 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
146 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
42 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
40 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
148 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
56 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
91 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
70 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
61 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
85 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
55 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
56 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
59 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
72 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
68 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
44 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
117 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
40 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
119 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
95 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 ...
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
143 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 ...
9
votes
3answers
161 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
63 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
49 views

How to destructure local variables?

Why can't I use this Where[{iw, ih} = ImageDimensions[i], ...] instead of this ...
0
votes
1answer
56 views

Permanently fixing a variable in the function

I need to define a function let's say f[x_, y_] := x^2 + y^2 such that I need to fix one variable (let's take y = a) and to ...
0
votes
2answers
75 views

Function that creates a table from two lists

I have two lists shown below: list1 = {(0,0,0,0),(0,0,0,1),(0,0,1,0),...,(1,1,1,1)} list2 = {1,5,5,5,...,5} How can I construct a function that outputs a table similar to this: $$\begin{array}{c|c} ...
0
votes
2answers
148 views

How to construct a linear feedback shift register

Are there any posts regarding the construction of a LFSR (Linear Feedback Shift Register) in Mathematica? I can't seem to find any and I am not sure how I would construct one.
0
votes
1answer
54 views

Built in function to convert list of numbers into list of binary numbers [closed]

Does Mathematica have a build in way to convert a list of numbers into a list of binary numbers? If not how can this be accomplished?
0
votes
1answer
95 views

Help with functions in Mathematica

Still learning how to do things in Mathematica. I want to make a function that has many parts. Doing this in something such as Java, which I am familiar with, would be simple. In Mathematica I have ...
2
votes
5answers
225 views

Making loop based off what I can say in words

I have a list of values a: {1,4,11,14} I want to print out values that satisfy b(1+a) = 0 mod 15 where b are the values from 0 to 14. The output I am wanting is ...
2
votes
3answers
84 views

Perform For-loop and show output which meets a certain criterion

I am new to Mathematica and I have a For loop like so: For[i = 0, i < 15, i++, PowerMod[i, -1, 15]] Currently it doesn't output anything. The calculation I am ...
0
votes
0answers
31 views

How can I remove some bad rules applied as a result of syntax error?

This user is pretty light-weight regarding Mathematica rules and such. I dont know how the following issue was created (some prevous bad syntax in the same session) ...
10
votes
1answer
360 views

How to visualize pattern matching process?

I want a function that does the same job like ReplaceRepeated, and can make the matching process visible. I searched the Internet but didn't find any existing code ...
1
vote
1answer
114 views

Using FindMinimum with matrix input

I define the following function which spits out a number S when I feed it a dxd square matrix: ...
0
votes
0answers
56 views

Using NestList instead of Do [duplicate]

How can I express the following code using NestList: ...
10
votes
1answer
171 views

Copy Built-in function to new name

It is know that some built-in functions are system function and changing their properties may cause trouble. Suppose for example I want to change features of Cases: ...
4
votes
3answers
222 views

Manipulate: How to create custom reset Button automatically?

I have a complex Manipulate with more than 10 controls. Each one has its own default value. I'd like to add a custom button in the control area to reset all ...
13
votes
2answers
427 views

I define a variable as local to a module BUT then the module uses its global value! Why?

I have a question about modules and local variables. Here's my example: h = 5; Module[{a, h}, a[h_]= h^2; a[4]] (*Out[2] = 25*) I expected the module to ...
17
votes
1answer
379 views

Confused about how Partition works

I have a problem about the padding list about Partition command. For instance, ...
3
votes
1answer
111 views

ControlType -> None Vs. Module inside Manipulate (i.e. making everything local)

I'm building a program on another one made available in the Wolfram Demonstration Project. I've noticed that in the original code (working flawlessly) many variables were made local inside the ...
0
votes
1answer
228 views

How do I write nested for-loops?

Looking through the reference.wolfram, I couldn't see an example of how to write a multiple line "for" loop in Mathematica. I need to nest many for-loops in such a way I can do many things in the ...
5
votes
2answers
403 views

Code elegance and compactness. Help needed with Map, Apply

I need some help with code optimization and compactness. I have a set of two-dimensional points and I can use the Mathematica function FindClusters to find 4 clusters. I'd like to plot the points ...
2
votes
0answers
65 views

What was the thought behind the parallel versions of Table, Map, etc..?

There separately named versions of the parallel analogues of Map[] and friends: ...
1
vote
1answer
82 views

Computing a Sequence using Recurrence

I posted a similar question earlier today, but unfortunately I realized after several hours that I over-simplified the problem for this forum. There is a very good answer to the Computing a sequence ...