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.

learn more… | top users | synonyms

-1
votes
0answers
19 views

how to choose from M a point which will be the center of the circle, and in that circle must be a minimum of points [on hold]

C programming on a plane are given a set of points M. Choose from M a point which will be the center of the circle, and in that circle must be a minimum of points
311
votes
27answers
51k views

What are the most common pitfalls awaiting new users?

As you may already know, Mathematica is a wonderful piece of software. However, it has a few characteristics that tend to confuse new (and sometimes not-so-new) users. That can be clearly seen from ...
-4
votes
2answers
59 views

Develop a loop with two counters

Description: I am trying to develop a function that would take two arguments n and m and would run another function multiple ...
6
votes
2answers
239 views

How to program a click panel for chemical elements (like a periodic table)?

The command ColorData["Atoms", "Panel"] indicates RGBColors of atoms by clicking a panel. As I don't want to reinvent the ...
-1
votes
0answers
30 views

Insert several sequential alphanumeric characters pdf [closed]

As I can make it through "this" directory 1 to "this" in the directory 2 and so on for 50 pdf, Deputy sample directory Example
72
votes
3answers
3k views

Flatten command: matrix as second argument

One thing I could never wrap my head around is how Flatten works when provided with a matrix as the second argument, and the Mathematica help isn't particularly ...
1
vote
3answers
121 views

Basic Programming in Mathematica - How to build a loop [closed]

I want to build a loop with the following rules: I have a list a={5,7,8,9,5,6,8,6,7,8}. I want to print the mean of the first two ...
11
votes
5answers
2k views

Beautiful dance of the Earth and Venus around the sun

I have seen very nice dynamic graphics created by users of Ma. I would like to get help whether the following graphics can be created using Ma. I was not able to create the dynamic picture here. ...
0
votes
0answers
29 views

Set more constrains on a function in Do loop with If condition [closed]

This post is an extension of the post: Do loop with If condition The answer of @JasonB worked fine with me. that to use Reap ...
14
votes
2answers
323 views

Tips to move from functional programming to GUI-based applications

Even though this forum has some questions related to Mathematica programming tips I think that we still don't have specific help for those who want to learn to efficiently create GUIs in Mathematica. ...
21
votes
2answers
795 views

Efficient priority queues?

I'm trying to figure out how to transfer the concept of a priority queue to the functional world. Searches have turned up some implementations that use Append and other expense list copying ...
0
votes
1answer
34 views

Looping over a function with several parameters

Folks I am a beginner in Mathematica and have a simple question regarding loops: Here's the problem, I have a dataset of with four columns and I need to loop over each row. So the matrix in which my ...
0
votes
2answers
518 views

Mathematica Implementation of Householder’s Method

I typed the Householder code in this paper, which starts on page 7. The code is: ...
0
votes
1answer
55 views

A problem with the output

i using mathmatica to study lagrange Interpolating,however i couldn't make the output as I want I wrote both who is the output and how i needed ...
7
votes
1answer
103 views

Generalizing LongestCommonSequence to 3 or more arguments?

The function LongestCommonSequence finds a longest common subsequence between 2 lists. Apparently, this built-in function does not accept more than 2 arguments. How ...
1
vote
1answer
44 views

How to apply hermite InterpolatingPolynomial?

I found that to do hermite InterpolatingPolynomial I need to write: InterpolatingPolynomial[{{{1}, 2, 3}, {{2}, 6, 7, 8}}, x] however,i need to apply it on a ...
43
votes
5answers
4k views

Are there any cases when For[] loops are reasonable?

To my mind the only reason for the existence of For[] loops in Mathematica is to allow new users with some experience in procedural programming languages to write ...
2
votes
1answer
144 views

How to linearize an expression involving derivatives?

I want to linearize the expression involving function $y(x,t)$ $$[y^3(y_x-y_{xxx})]_x$$ by assuming $y(x,t)=y_0(t)+y\prime(x,t)$, where $y\prime(x,t)$ is a small variation. In other words, I will ...
416
votes
15answers
95k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
0
votes
0answers
13 views

How to calculate an accurate estimated reading time of text? [migrated]

I suppose the calculation should not be done by only two factors (average reading speed/words per minute, and word count). But at least by a third parameter, that in my opinion should measure the ...
4
votes
1answer
489 views

How can I invoke the solution of NDSolve to determine a parameter in my equation just inside NDSlove?

I am trying to solve a differential equation by NDSlove for $h(x,t)$. It reads $$h_t=h_{xx}-V_h-\lambda(t)$$ where $V_h$ is a given function of $h(x,t)$ denoted by ...
1
vote
1answer
123 views

Speed Up Sampling of Perimeter of Polygon

I have a polygon whose vertices (points) are defined by some image coordinates that I have manually selected. The polygon is used to create a mask for a region of interest in a microscopy image. ...
0
votes
1answer
48 views

Experiment to test Infinite monkey theorem [closed]

I need to apply this experiment: For all numbers between [0,128] let be t {set total=0 repeat this experiment n times {set start=0 choose random number [0,255] lets be R While(R!=t) ...
5
votes
0answers
136 views

Dealing with a nonlinear PDE using FEM

As far as I can see in the Mathematica documentation center, there are no built-in ways for solving nonlinear PDEs using Finite Element Method (FEM). I am dealing with a simple nonlinear ...
9
votes
3answers
953 views

Implement the Bisection algorithm elegantly and easily

Description: Rencently, I have finished my course Numerical Analysis, so I'd like to implement many algorithm that I have learned from that course.By this practice, I hope that I can improve my ...
4
votes
1answer
55 views

To embed metadata in a notebook, keeping them both human readable and easily parsable

I' m trying to set up a gizmo to manage the large notebooks collection, in my Mathematica workspace. The main idea is to embed indexing metadata in each notebook and manage them by means of function ...
6
votes
0answers
102 views

Good clearing practices

I have been using Mathematica for about 2 years and I'm pretty ok to write and optimize my code. Wanting to improve my practice, I often look at code examples. However, I can not determine if there is ...
3
votes
1answer
47 views

What options for project development exist if the Cloud and Mathematica Online cannot be used

Due to contractual obligations to protect IP and client information, we unfortunately, cannot use Cloud or Mathematica Online for development in the development of our projects. We are further ...
2
votes
0answers
90 views

How to use Mathematica to help me get highest score in every layout? [closed]

The game is hitting the headline in these day and everyone can click this link to play it.The game have a very simple rule like following: Game Rule It will give you a initial layout when you click ...
4
votes
2answers
245 views

Calculate $\pi$ using Monte Carlo methods

I know that we can have an estimate of $\pi$ using Monte Carlo methods. I know that we make a huge loop and each time we take randomly two numbers in the range [0,1] and calculate the number of ...
2
votes
2answers
57 views

Substituting within a function definition that includes Simplify

I would like to define a function like myfunc[f_] := Simplify[(f/g)] where g will be substituted/replaced with the current value of g at the time of definition. ...
0
votes
0answers
38 views

Construct certain univariate functions over bounded interval having given set of moments [migrated]

We have a class of probability distributions (parameterized by $\alpha =\frac{1}{2},1,\frac{3}{2},2,\ldots$) over the interval $[-2^{-12} \cdot 3^{-3},2^{-16}]$ having as their $n$-th moments ...
57
votes
9answers
3k views

Updating Wagon's FindAllCrossings2D[] function

Stan Wagon's Mathematica in Action (second edition; I haven't read the third edition and I'm hoping to eventually see it), demonstrates a nifty function called ...
10
votes
1answer
171 views
6
votes
1answer
262 views

Generating cylindrical geometry via extruding a section

Toady I want to build geometry as shown below: I know the Mathematica owns the built-in like Cylinder[], Sphere[] and so on, ...
-3
votes
0answers
21 views

Table of an equation roots [duplicate]

I would like to form a table of all roots of an equation (say sin(x)=0) lying inside a certain interval. What kind of Mathematica expression shall I use?
6
votes
2answers
310 views

What does empty {} mean in Module? [duplicate]

I have a question. I would like to know what an empty list ({}) means when used in Module[] as the code below shows? Why has a ...
7
votes
3answers
229 views

Simulation with two random walkers on a lattice with periodic boundaries

I am having some difficulties implementing a Monte Carlo simulation in order to compare the results to analytical calculations. The following code simulates a case with one random walker and a ...
9
votes
1answer
192 views

Fast implementation of Metropolis-Hastings update with multiple sets

This is an optimisation question rather than something I am unable to do. I have a naive, primitive working version of the code (I submit it below) but I am trying to make it work faster. I am asking ...
15
votes
9answers
620 views

Any built-in function to generate successive sublists from a list?

Given lst = {a, b, c, d} I'd like to generate {{a}, {a, b}, {a, b, c}, {a, b, c, d}} but using built-in functions only, ...
2
votes
0answers
50 views

A question regarding shadowed symbols

The more I study, the less I understand. This is the HelloWorld package: ...
9
votes
0answers
117 views

Is there a linter to help write good Mathematica code?

I don't do much real programming, but I've recently been turned on to Atom, which has linter plugins for over 50 languages to make coding easier (most drawing on pre-existing lint-like programs). In ...
0
votes
0answers
63 views

Why Mathematica rather than matlab? [duplicate]

I am not sure I can ask question here, but in my lab, there are two people using Matlab, and two people including me using MMA. They told me that Matlab can do Matrix calculation much faster than ...
9
votes
1answer
119 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 ...
0
votes
1answer
61 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 ...
14
votes
3answers
906 views

Mathematica usage (success stories) for financial back-ends

I've been working for about 5 years in Java, developing financial back-offices (web-services, business logic, report generation etc.). I think Mathematica is very suitable for such calculations and ...
8
votes
1answer
299 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 ...
2
votes
0answers
93 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 ...
4
votes
1answer
123 views

Loose binding of &

This code returns 2, as expected. ...
6
votes
2answers
106 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 ...