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

2
votes
0answers
299 views
+100

How to perform convolutions on this complicated pdf?

For a known pdf f[x], I need to calculate integrals over the probability density of the means of Logs[f[]] of independent samples from f[x]: $$Q[t,n]\equiv P(\frac{...
0
votes
2answers
44 views

Finding and plotting a parametric solution to a complicated equation (transcendental, log-polynomial)

I am trying (desperately) to find a way to solve a transcendental equation whose solution $x$ depends on non-numerical parameters $a$ and $b$. And then to produce a ...
21
votes
1answer
533 views

Is the renaming mechanism of `With` flawed?

I'm confused about the renaming mechanism of With: ...
2
votes
1answer
100 views

Speeding iterative computation

I want to get the following iterative sequence ...
20
votes
5answers
4k views

How do I increase the readability of this code?

Below is some code I am working on; being a beginner. How can I increase the readability of the part behind Manipulate? I can't read my own code anymore, because it is simply too long and unordered. ...
11
votes
3answers
525 views

How to debug the C code for LibraryLink?

Recently, I use the C to rewrite a Mathematica function NonzeroBasis[], please see here for fully descriptions. Here, ...
9
votes
1answer
185 views

Random walk on a Sierpinski gasket

I am trying to simulate a random walk on a Sierpinski gasket. The best strategy i could come up with is to use Nearest point function to determine the next possible step of my walker. But this creates ...
14
votes
2answers
366 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. ...
0
votes
4answers
92 views

Saving the values calculated in a list or a table

I cannot realise if it is a duplicate question. Sorry; if it is. This ...
316
votes
28answers
53k 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 ...
8
votes
1answer
91 views

How does a construct like `i : func[arg_] := i = an expression using arg` work?

Occasionally I run into a Pattern that looks like i:func[arg_]:=i= an expression using arg I have two questions on this: Can ...
22
votes
2answers
1k views

Schedule programing problem with integer linear programming

I know how to model this question on paper, but I don't know how doing it in Mathematica. Imagine , there is a university student who want to choose courses for this semester and he got the ...
0
votes
0answers
30 views

Produce a function of parameters from a solution to parametric equation [on hold]

I am trying to produce a very simple result, namely given some function $f(x,a)=0$ find a solution $x(a)$ and let it be a function that I later plot depending on $a$. However Mathematica does not ...
424
votes
16answers
96k 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 ...
6
votes
2answers
5k views

Creating custom functions with multiple arguments

I am hoping that this isn't a stupid question so feel free to vote it for closure. Google failed somehow. I want to define a custom function (more complicated than the usual ...
0
votes
1answer
70 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 ...
-2
votes
0answers
15 views

Question regarding Majoring in Maths etc [migrated]

I was wondering. Is it possible for someone to major in Maths as in do their masters in Maths once they've earned their degree in Computer Science?
1
vote
1answer
122 views

How to connect some separate components with shortest total length line

Maybe this post too hard.So I try to make a simple version to research. Simulating a simple graph than that post. ...
4
votes
1answer
190 views

How to check and reset the boolean value of many options one times?

I defined a function which owns many options. In addtion, these options have a common characteristic. Namely, only accepting boolean value True or ...
0
votes
0answers
14 views

Find a conformal map from disc onto trapezoidal plate [migrated]

how can conformal mapping a disk into a trapezoidal plate with defining favorite central point?
4
votes
1answer
522 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
69 views

generating random algebraic matrix using elementary operations

I generate several algebraic matrices of 12x12 where each element is a combination no repeat of the variables x, y, z and operations +, -, *, /, power, establishment (square root), any of them or any ...
2
votes
0answers
48 views

Where can I find tutorials or examples about Internal` packages and other useful packages? [duplicate]

As an intermediate level Mathematica user, I consider one of the greatest barrier on my way to a higher level of programming is the lack of knowledge about extra packages like Internal` package or ...
15
votes
2answers
261 views

How to check the validity of an option value

I have a user-defined function, func, which takes the following form: func[arg1, arg2, options] Here is the actual code ...
1
vote
0answers
36 views

How Defer[1+Evaluate[1+1] work?

I want to generate some expressions. The expression is not evaluated expect some parts will evaluate first. A simple example is Defer[1+1+1] and in this expression ...
0
votes
1answer
96 views

How to overload the operator “*” as KroneckerProduct [closed]

Can I use the expression below a * b * c * d for short to instead KroneckerProduct[a,b,c,d] automatically when a,b,c,d are ...
3
votes
1answer
71 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 ...
-6
votes
2answers
73 views

Develop a loop with two counters [closed]

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
247 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 ...
74
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
124 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. ...
21
votes
2answers
799 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 techniques....
0
votes
1answer
37 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
547 views

Mathematica Implementation of Householder’s Method

I typed the Householder code in this paper, which starts on page 7. The code is: ...
7
votes
1answer
109 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 ...
44
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
149 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 ...
1
vote
1answer
127 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
157 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 time-...
9
votes
3answers
993 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
56 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 ...
2
votes
0answers
99 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
252 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
58 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. ...
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
175 views