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

4
votes
1answer
45 views

How to add UpValues to a symbol to make a expression expanded normally?

Here is a implementaion of Bernstein basis function. I add the following UpValues to ...
9
votes
2answers
219 views
+100

Checking the argument of user-defined function with side-effect method

Today, I answered a question of mine that asked two month ago. Please see here Now I would like to add the argument checking in this function. Then I used a method that Mr.Wizard answered ...
-1
votes
0answers
29 views

Some program for calculus [closed]

I'm tring to do a program or find a program that generates random numbers and makes a calculus, for example: print 5 number 4,5,6,3 now add a symbol after the number 4+ , 5+ , 6- ,3+ then if you ...
3
votes
1answer
95 views

A pre-parsed HoldForm

HoldForm holds an expression's parsed form not its actual "inputted form" e.g. ...
5
votes
2answers
200 views

How do I “evaluate in place” programmatically? Need to evaluate Defer[] result in non-interactive setting

I need to evaluate the result returned from an external package, which contains Defer in it, but do this in a script without user interaction. I am not able to ...
3
votes
1answer
128 views

How can you get the area of a region from an image?

Suppose we have a square of side "L" m, How can I calculate the hatched area, if the corners of the square are centers of circles. It can be generalized to any region? edit: This is the result I ...
12
votes
1answer
204 views

How to add AccuracyGoal and PrecisionGoal options in a numerical function?

There are many built-in functions that contain AccuracyGoal, PrecisionGoal and ...
-2
votes
1answer
154 views

How to get the coordinates of points within an image?

How can I get the coordinates of an image, and make Mathematica draw the image from the coordinates found? I am interested in just the outlines of the regions. Here is an example of the kinds of ...
7
votes
1answer
99 views

How to select a submatrix containing similar elements from a matrix? [closed]

( This question is related but does not ( fully ) answer my questions. - Finding the position of similar elements in a matrix ) I have not written code yet, I am in the design phase of code for the ...
6
votes
1answer
68 views

Can Query operators be naturally cast as either Ascending or Descending?

One of the challenges of coming to grips with Query's on Association's and Datasets is ...
0
votes
0answers
38 views

Programming of basin of attraction for with memory iterative methods

I have made the programming for without memory method and i got the basin of attraction but i could not make it for with memory iterative method. I am sending you the programming of with memory ...
0
votes
1answer
47 views

Write a function pollard[n, B] that tries to factor an integer n, using Pollard's p − 1 method with at most B iterations [closed]

This is what I got but it seems it's not working. When I test it, it just goes through and nothing gets returned. Is there something I'm missing? ...
6
votes
1answer
118 views

Is there a practical way to define a default value for missing keys in an Association?

It can be very useful to define background or default value for an object that can be incremented or otherwise modified. A simple (and for me, common) use is a counter: ...
2
votes
1answer
83 views

Implicit derivatives in one line. How do I do it?

I have this little script to derive implicitly $PrePrint = # /. {D[y_, x_, NonConstants -> {y_}] :> y'[x]} &; Example: ...
0
votes
1answer
72 views
3
votes
1answer
99 views

Using function to transform a list

I have a list like that: {{Integer,String},....}, integer ranges from 1 to 900 and String "I" to "IV". And I need to find which pair of {x,y} each sublist is related to, so i can get a new list like ...
1
vote
2answers
83 views

Ask about the variable and constants in partial derivative in a loop

EDITED I have a function in a list like : func={2(x^2)+x*y+3(y^2)}; I want to have a UI that ask me which parameter (x or y) is a variable in a ...
2
votes
2answers
63 views

Sum broken into two sub-sums according to a condition on the terms

I have a sum in mind, but I want to break it into two sums and get a separate total for each of the two. All cases where the square root is accurate, i.e., exact All cases where the square root is ...
4
votes
3answers
130 views

How to get multiplication of the elements of a specific list/Matrix

Assume there is a list: List1={a,b,c,d}; Then I want to get these calculation: ...
4
votes
1answer
130 views

How to check the option value?

Given that I have a function func as follow: To check the value of options, I using the step-by-step method If[] ...
4
votes
1answer
65 views

How to define an expression which is differently evaluated in calculations and printed

Let's say, we have a list: values = {1.2, 0.04, 0.9}; Is it possible to replace 0.04 by some expression, which displays as ...
0
votes
0answers
64 views

How to spend any image in “2D” or “3D” to an image mesh, ie as a wire frame in black and white?

How to spend any image in "2D" or "3D" to an image mesh, ie as a wire frame in black and white? For example some of these: edit :example output
9
votes
1answer
104 views

How to implement a custom random process object?

I want to implement a custom random process thing1 to pass to RandomFunction. The process I have in mind is conceptually extremely simple: two alternating Poisson ...
1
vote
0answers
58 views

Should I Remove the initial symbols of Module?

Often we use Module to construct complicate function. Consider that Module create new vars every time we run the function, should I remove the initial values at the end of Module-function?Or should I ...
0
votes
0answers
79 views

Fun/Frustration With Coding Coding Theory

I have code following from this post: http://math.stackexchange.com/questions/1317722/fun-frustration-with-coding-coding-theory I think I am done with the code, but now I face a single problem. The ...
2
votes
1answer
149 views

How to determine whether an expression can act as a “good” function?

It's not easy to see whether an expression can act as a "good" function. A good function refers to an operater that transforms symbolic entities like 1+x^2 or ...
1
vote
0answers
63 views

Arrange order of evaluations (please help these unit vectors)

I need help to control order of evaluations. Here I try to use Manipulate to control n unit vectors. Their positions are initially random but head left. The 2 operations are 1) translation: moving ...
5
votes
0answers
43 views

How is CellContext->CellGroup supposed to work?

After reading the documentation on the subject, I still cannot get CellContext->CellGroup to work. Here's a simple example. (Unfortunately, I cannot easily ...
4
votes
1answer
139 views

Can I do constraint programming in Mathematica? [closed]

I would like to know if there is a way to do constraint programming in Mathematica? I think there are no built-in functions, but maybe some of you know some additional packages addressed to the ...
0
votes
1answer
80 views

Functions behaving weirdly

The following code f[k_, n_] := Sum[2*(1 + Sum[f[k - j, n - m - j], {j, 1, k - 1}]), {m, 1, n - k + 1}] f[4, 7] f[4, n] gives the output: ...
9
votes
0answers
95 views

Confused by the opts : OptionsPattern[ ] pattern

I'm trying to make sense of the syntax in the clause opts:OptionsPattern[], as found in this standard "rule-based" (pseudo-)function definition pattern: ...
1
vote
1answer
44 views

Why this isn't a valid argument? [duplicate]

I am having truble understanding why F1 produces an error, since both time and velocity are the same kind of object: ...
0
votes
1answer
55 views

Mathematica Code Involving For Loops Not Completing All Iterations [closed]

First of all, thank you for taking the time to read this. I'm working on a portion of code related to the genetic algorithm that is not producing the expected results. What the code is supposed to do ...
3
votes
1answer
88 views

Is it possible to update Dynamic objects even when they are off screen?

I am using Dynamic and DynamicModule to display graphics/statistics generated from a long-running set of parallel tasks. The ...
13
votes
2answers
344 views

How to programmatically ask if Mathematica is running as an Administrator

To avoid execution problems in a program I need to know if Mathematica has been "Run as administrator". What would be the cleanest way to programmatically getting this information?
5
votes
0answers
246 views

How to create protected single-file stand-alone CDF applications

After hours of work trying to understand how much protection I can get when creating stand-alone CDF applications I have come to the decision that the best protection to my work is provided by ...
0
votes
1answer
58 views

How to count column occurrences in a matrix?

I have a matrix of data, and I want to count the number of columns that match, and have some way to organize them by frequency. But I don't want to count the entire column, but consider the matrix ...
5
votes
1answer
119 views

Reap, Sow with Parallelize: bad performance, why?

I have a question about the performance of Reap and Sow with Parallelize. I am aware of the following questions How to collect result continuously (interruptible calculation) when running parallel ...
1
vote
1answer
50 views

Emulating Case Pattern replacement

As most regular users, I have developed utility functions complementing the Wolfram language for frequent tasks. In particular, I have variations on Cases (see ...
1
vote
1answer
144 views

Transform linear system into a matrix form

I have a system of linear equations in variables $A_n$ of form: $$ \sum _{k=-K}^K h_k A_{n-k} J_{n-k}\left(\frac{(1-i) \text{$\eta $Sqrt}(n-k)}{\sqrt{2}}\right)+A_n\left(\frac{(1-i) \eta ...
2
votes
3answers
107 views

Problem with the output of a function I program

(This is the function that I programmed) Zm2[Z_, nk_] := (zm2 = 0; For[i = 0, i < Length[Z], i++, zm2 += nk[[i]] *Z[[i]]* Z[[i]];]; Return[zm2];); ...
3
votes
1answer
165 views

How to further accelerate arithmetic with Fermat Pseudoprime and Fibonacci number

I've been working on this all night, and I have made this go pretty fast, compared to my first iteration of the program, but now I'm out of ideas. I'm trying to write a program to test (by good ...
2
votes
2answers
149 views

Recursive Euclidean algorithm in Mathematica

Can anyone explain to me how do I use a recursion, if I don't know the limit? For example, I need the remainder $r$ of the Euclidean algorithm for $\gcd(a,b)$ which equals $0$. I figured out that the ...
11
votes
2answers
223 views

Built-in symbols that support operator form

In version 10 some built-in symbols are updated to support operator form like the Derivative. For example, Select, ...
0
votes
0answers
53 views

Calling a custom function in slave kernel process connected through mathlink

I am performing a small experiment to check if we can call/execute a custom package function in slave kernel launched from master using mathLink. I have created a dummy application called ...
5
votes
1answer
288 views

Only `Break` from innermost loop

How could I Break from only the innermost loop in a Do[stuff,{i1,i1min,i1max},{i2,i2min,i2max},...] ? I get the desired ...
0
votes
1answer
80 views

`Do` structures - listing iterated values

Please excuse the crudity / simplicity of this question, hbut I have never really got on too well with Do structures - perhaps I don't use them enough - perhaps I ...
2
votes
2answers
102 views

Creating a Cayley's table of square

I'm interested in creating a Cayley's table of square using Mathematica. I'm not a programmer but occasionally resort to using Mathematica to simplify my work insofar as the programming doesn't take ...
1
vote
0answers
96 views

How can I launch kernels in series using mathlink

I have written below code to launch n kernels connected to one another in series using mathlinks. Before you read the code allow me to be more precise what i want to achieve: Source kernel(k1) ...
1
vote
1answer
50 views

Is it possible to use FormObjects and FormFunction in a stand-alone notebook?

I have been looking at the FormObject and FormFunction. Can FormObject and ...