# Tagged Questions

Questions on writing non-trivial programs in Mathematica. Do not use this tag for questions on plotting/graphics or for questions on doing mathematics with Mathematica, where the focus is more on the math than the program.

62 views

### How to use Do and NestList combine?

g[x_]:=((i - 1/i)*x + (1/i)*(x/2))/2; I want to find the following list NumberForm[NestList[g, 0.8, 20], 16]; But don't ...
305 views

### Show how Mathematica defines a function

Is there a way to show how Mathematica defines a function, such as In: Something[Sqrt], Out: Sqrt[x] -> x^(1/2) As far as I understand it the command ...
109 views

### List of amazing things you can do with Mathematica [closed]

What is the coolest (amazing) thing you can do with Mathematica? for instance there are my favorite things Automating xkcd Diagrams Extending Van Gogh’s Starry Night with Inpainting Making ...
124 views

### Loose binding of &

This code returns 2, as expected. ...
109 views

### How automatically perform an action each time a function is invoked?

Please, consider these functions: f[x_] := Module[{}, Return[x + 1]; ]; g[x_] := Module[{}, Return[x - 1]; ]; I want evaluate ...
38 views

### Construction of palettes [duplicate]

Is there a good documentation to help to construct my own palettes. The problem is to use a palette as an assistant to remember some long command line with many place holder and not to be obliged to ...
84 views

### Calculating the angle between the line joining two points and the x-axis [closed]

I need to calculate the angle between two points, the returned result should between $0$ to $2π$ and getAngle[point1, point2]==getAngle[point2, point1]. I have ...
100 views

### How to create some macros

I have two question in one. In the following code, I want to manipulate a plot in a centered cell. It is fastiduous to try always to remember the way to act. Could I define some macro as in a standard ...
234 views

### How to parse a clojure expression?

Clojure is a lisp-like language that runs on JVM and in Javascript. I just started learning it and I'm building a simple parser with Mathematica to understand and visualize it. Like other lisps every ...
53 views

### Function that outputs the dual of the formula

The exercise is simple: define a function that gives the dual of the formula. While I have experience in mathematics and logic, I do not have real experience in programming. Logic is propositional ...
51 views

126 views

### Learning the Wolfram Language ‘from the bottom up’ [duplicate]

I'm a armchair programming-language theorist, and I know … quite a few programming languages, some to extensive depths. (Hell, I've built more than my fair share.) Most of the information I've found ...
110 views

### Matrix Diagonalization programming

I have a very simple problem, with me misunderstanding the use of Modules and Functions in general, in mathematica. I have a function of which I want to input a Matrix, and in the function I want ...
123 views

### How does exactly Check work?

Please, consider the following code : ...
25 views

### Discretization of a region for NDSolve using [duplicate]

I would like to mesh the region below in order to use it for a calculation by means of NDSolve. Could anyone help me to discretize this region for NDSolve using. Thank you very much. Needs["NDSolve<...
71 views

### Code optimizations with functions inside Module

I wrote a small code by using functions inside Module: ...
5k views

### General strategies to write big code in Mathematica?

I think after six months of exposure to Mathematica and the Wolfram Language I am fairly OK with writing short codes and snippets. However, what are some general strategies to use in order to write ...
55 views

### FullForm and the attribute HoldAll

I have noticed that TrueQ @ (And @@ {False, True, True, True}) gives False and, on the contrary, ...
105 views

### Module that prints first m positive odd integers and returns the square root of the sum of them

I am working on this problem and I feel like I've come so close. Write a module that takes as input a positive integer m, prints the first m positive odd numbers and returns the square root of the ...
90 views

### Is it possible to 'partially' protect a variabile? [closed]

Please, consider a variable initialized at the beginning of a program: $myVar = {}; Protect[$myVar]; and the only two functions allowed to change it: ...
29 views

### How to select bottom three “norm” values and their corresponding matrices? [closed]

I calculated five random matrices of 6x3 (with some code which is already working) having name Subscript[randompop, j].Here is the output ...
106 views

### Mimicking Console and Output Matlab/Rstudio-Style Environment in Mathematica?

I am trying to crudely approximate the RStudio or Matlab Workspace environment in Mathematica by having a specific notebook function as the "console notebook" where I execute commands and another ...
136 views

### Plotting Graph of Zeno paradoxes

Zeno Paradoxes is about a Greek Heroes Archilles having a race with tortoise. the tortoise given a head start distance. Greek heroes Archilles have constant speed ...
162 views

### How to optimize my own BezierFunction?

A few months ago, I asked a question about the implementation of Bezier surface. Please see here for a full detail. I also know that BezierFunction[] is built-in ...
42 views

### Question about transforming a list of rules

Consider the following list: ...
85 views

### An unexpected match when using Condition, Optional and passing a Sequence

Mathematica is behaving in an expected way when passing a parameter with an Optional and a Sequence. Here is an example: ...
73 views

I cannot seem to draw a windmill that fits in the photo background. Any help is appreciated! Thank you :)
4k views

### ++ is dangerous for C programmers

I noticed this fact, that may be misleading for programmers used to C language. In Mathematica, if you have a function f[] and an array v, and you write ...
177 views

### How do I use StringReplace to replace repeated characters?

Suppose I have str = "dededekmkmkmvkfjdedemkvmlvdedekfmmdedededemkmkde" And I want to replace the repeated "de"s to one and produce (in a real example, the "de"...
156 views

### Error propagation code

I have a code for error propagation :- ...
67 views

### Running an entire notebook with different values of an input [closed]

I have about a 20 cell notebook which begins at n=3. By replacing 3 by other natural numbers, I can compute what I want using these values, but I do not understand ...
76 views

### Programmatic immersion of 2D surfaces in 3D [closed]

Disclaimer: This may be an open problem, or one that is too large to be amenable to a solution on this site; I'm not sure. Question: I'm looking for a method to programmatically immerse certain ...
109 views

### What is recommended way to define my function option

In Mathematica 5.x days many packages used the following standard mechanism to read option values ...
278 views

### Combinations of multiple matching patterns

I wonder if there is any nice way to combine DownValues (or any other suitable rule-/pattern-/function -based Mathematica construct) when multiple patterns match an expression. Let me explain what I ...
81 views

### How can I calculate the root of any order of power series

How can I calculate the root of any order of power series with Mathematica. Here I insert every quantity by hand. But I want to give a, ...
82 views

### Flipping random elements in a matrix

I'm still a beginner with mathematica so maybe the solution is obvious, but for some reason my code that worked fine earlier doesn't work now. I haven't changed anything about it. I've restarted ...
32 views

Is there a way to programatically know which Wolfram product is evaluating a notebook or cdf file: Mathematica, CDF Player, or CDF Player Pro, Wolfram Cloud? I'm currently using $InstallationDirectory ... 2answers 156 views ### Confining/Periodic boundary conditions implementation for 2D Random Walker I am new to Mathematica, and am having trouble implementing confining boundary conditions for a random walk simulation confining the walker to a pre-defined region (periodic boundary conditions would ... 1answer 50 views ### Solving simultaneous and determinant given constant value and variable T (temperature) [closed] How to solve this two simultaneous equations? these two equations got from this free energy equation ... 3answers 380 views ### Implementation of tensor product formula For the Bézier surface, which owns the following matrix definition:$\begin{align*} \mathbf S(u,v)&=\sum_{i=0}^m \sum_{j=0}^n \mathbf P_{i,j} B_{m,i}(u) B_{n,j}(v)\\ &=\small \begin{pmatrix}... 1answer 104 views ### Clearing a global variable from inside a Module This is a highly simplified version of a initialization problem I have with a complicated program with many (about 100) modules. If one enters: X=42; Clear[X]; the ... 0answers 33 views ### Run mathematica script from python program [duplicate] Is it possible to run the mathematica code inside the Python program? A simple pseudo-code to describe what I mean: ... 1answer 220 views ### How to deal with bad arguments when a function's UpValues is a pure-function? In practice, I needs to define the UpValues of a user-defined function. For instance, the operation of function like differential formula , expansion and so on. ... 1answer 88 views ### How to ReturnFailed symbol in a MakeBoxes context?

Three months ago, I asked a question about How to build a function object like the built-ins? Today, I used a solution proposed by István Zachar ...
46 views

### Results of a function are different when the function call and subsequent statements are evaluated one line at a time

I have some code that I am porting from VBA to Mathematica. The original code processes data on an Excel spreadsheet. In Mathematica, I find it convenient to replicate the Excel spreadsheet data ...
104 views

### Import Tex's aligned multiline equation into Mathematica

I know there have been answers to similar questions, using either ImportString or ToExpression, however I haven't been able to succeed in importing this. I'm using version 10 Mathematica on Linux by ...
131 views

### “Interface” for exam

Is it possible to create a (graphical) interface with Mathematica so that instead of having a Mathematica document where I change definitions and so on, I can just input values and it will use my code ...
35 views

### How to transfer the list of parameters values into With [duplicate]

In the following case: With[{x=1,y=2},Print[x+y]] the values of x and y are declared in ...