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.
10
votes
1answer
258 views
Does Mathematica have a function to find all singularities of an expression?
I am looking for function in Mathematica, which finds all singularities in an expression. To keep it simple, the variable is only one, say x.
So given expression <...
4
votes
1answer
64 views
How can one notebook run another without aftereffects?
Notebook A wants to open, display, and possibly run Notebook B without corrupting its operating environment, and then resume, possibly repeating the exercise with Notebook C.
A lttile more detail: ...
9
votes
3answers
300 views
How to work with Date calculations?
I have never worked using the DateObject function
But I suspect there must be a (easy) way of doing it.
I want to find out, when in the future, from which point, ...
0
votes
0answers
48 views
Basic mathematica integration [closed]
Let's say I have a very basic function in Mathematica. For example, f [x_] := Sin [x]
Now, I would like to call this Mathematica function in visual studio, so I ...
10
votes
1answer
408 views
Call a Haskell DLL from Mathematica
Looking for a way to call a Haskell DLL from Mathematica, I've stumbled on this, for GNU R:
http://neilmitchell.blogspot.com.br/2011/10/calling-haskell-from-r.html
It is (to me) a beautiful example ...
1
vote
0answers
51 views
Could one compile a stand alone program from Mathematica and how to [duplicate]
Last year, I start nearly from 0 to learn how to program and I have choosen to work with Mathematica. So this question is certainly naive but think of me as a beginner. I have understood how to make a ...
4
votes
2answers
154 views
Using Goto and Label in different cells?
I'd like to solve an optimization problem, which involves changing the parameters and re-evaluating. The problem is that I can't find a way to jump from one cell to another.
For example:
Set some ...
-1
votes
1answer
53 views
Repeating Calculations/Iterations without a specific function
I am trying to repeat an initial condition many times such that I get a desired final output. ONE final output depends on many subsequent calculations from ONE initial condition. But I want to get a ...
5
votes
1answer
276 views
How can I find the point in a list of points that is nearest to a given point? [duplicate]
I have a function $f(x)=\{\sin(x),\cos(x)\}$, $\,x=\{0,0.01,...,1\},$ and a point $P=\{2,3\}$.
I want to find the $x_0$ such that the distance between $P$ and $f(x_0)$ is minimum.
My code is:
...
3
votes
1answer
134 views
Functions with changeable global variables
I'm not sure is the topic title correct, but I mean such a case.
I have several functions and "changeable" global variables, e.g.:
...
1
vote
1answer
26 views
Simplifying the access to the change of the output font
This command seems to work for changing the font used in output
$PrePrint = Style[#, FontFamily -> "Arial"] &;
Is there a way to make a button which can ...
0
votes
0answers
30 views
Compiled function and vectors [duplicate]
I'm not sure should I ask this as separate question. Actually I posted this as comment to my question on FrenetSerretSystem, but that topic was asnwered (I accepted), no more activity there.
To speed ...
1
vote
0answers
65 views
Vectorization of 10^5 vectors
I've got a question regarding vectorization.
I try to make it simple and as low on physics as possible.
So: I have 10^5 random generated vectors(just x and y component and z is set) with {[-5,5],[-5,...
2
votes
0answers
91 views
How can I ignor small number in my calculation? [closed]
I use the For function in Mathematica and use several functions in this loop. However, during calculation some small numbers in the order of 10^(-200) get produced along with big number. Although I ...
4
votes
2answers
70 views
Handle Format when importing package file content unevaluated
This question and its answers explains two methods which allow to import the content of a package file as held expressions. That is very useful as one then can manipulate that imported held code as ...
1
vote
0answers
53 views
Implementing the ∞-norm [closed]
To write a program in Mathematica, I need to define $\|\cdot\|_{\infty}$ of an expression in a closed interval. Can you help me?
For example
$\qquad \|(\pi.Sin[x]+\pi . Cos[y]+\pi.Sin[x]. Cos[y.\pi]...
3
votes
1answer
52 views
Evaluate an expression with variable values stored in the form “variable name” + val
Consider an expression exp = a^2 + b + c which has variables a, b, and ...
2
votes
1answer
99 views
How to implement Outer with loops
I would like to implement a simplified version of Outer (Outer[f, vec1, vec2,..]) through a looping construct.
Here are is one ...
5
votes
3answers
136 views
How does Needs[“foo`”] find the file that defines context “foo`”?
The post's title says it all, but if more detail is needed:
Suppose I have the following in some file /path/to/foo.m:
...
3
votes
1answer
71 views
How to force error on pattern match failure?
For example, suppose that foo is defined like this.
foo[x_Integer, y_Integer] := x + y;
Then, any expression with head ...
0
votes
1answer
54 views
Adding dots to an empty region of space
I want to add dots to the maze so far I know only how to get one dot on the maze. I don't know if there is way without using coordinates.
So it would look like this with the dots added
2
votes
0answers
119 views
Where is Mathematica in the tiobe index? [closed]
I looked at http://www.tiobe.com/tiobe-index/ and cannot find Mathematica among the top 100 programming languages.
The same I see at small scale: in my research group are nearly 30 scientists, most ...
1
vote
0answers
31 views
How could change the matrix terms to zero matrix in a loop? [closed]
Dear Mathematica experts;
I have a code such as;
For[e=1,e<3,e++,
Be=ConstantArray[0,{3,3}];
a=1;
For[i=1,i<4,i++,
Be[[1,i]]=dRdx[[1,a,e]];
a=a+1;
];
];
...
3
votes
0answers
64 views
What's the role of the lines order in defining a function?
I'm totally surprised by the finding I had never noticed before.
This code works as obviously intended
...
1
vote
1answer
42 views
Conditional on the existence or the non existence
I have a nested serie of feasibility tests according to the code
...
1
vote
0answers
47 views
How to put images on a map so that they disapear when another image passes over them
We are working to create a pacman type of game and we cannot figure out for to get colored dots on the maze to represent the food the pacman eats. Here is our code so far:
...
0
votes
0answers
55 views
Using $Pre for storing previous results, how can I still use AbsoluteTiming?
I use several notebooks where I first calculate some physical dependencies and later on do some design optimisations.
Since the initial calculations are time-consuming, I try to store these results ...
1
vote
1answer
54 views
Calculating multi-objective shortest path for a graph in Mathematica
I would like to calculate multi-objective shortest path for a graph which edges have multiple weights (distance, delay, cost, for example) using e.g. Martins' algorithm. Is it possible doing that ...
1
vote
1answer
65 views
6
votes
3answers
365 views
program a wall in which an object can not pass
This is the code we have created so far for a Pacman type game:
...
4
votes
2answers
150 views
How to plot a bifurcation diagram of a system of recursive formulas in terms of two variables
My group partner and I are having trouble plotting a bifurcation plot of two recursive functions.
Our functions are as follows:
...
2
votes
2answers
225 views
How could I rewrite my code in professional style?
I reduced my question to the lowest possible for having your ideas:
...
0
votes
1answer
56 views
How to figure out an equation from a plot?
I am trying to figure out the equations y=f(x) of the red dashed lines in this log-linear graph where the x values were plotted on a logarithmic scale while the y values were kept linear.
I tried to ...
0
votes
0answers
63 views
PowerMod and Mersenne primes
Is the PowerMod function able to compute Mersenne numbers of large size digit numbers like M47 M48 found in this list http://www.mersenne.org/primes/
like PowerMod[a,M47,p]
If not, is there any ...
4
votes
1answer
74 views
How can I construct the derivative matrix for an irregular domain?
I wish to construct the derivative matrix corresponding to an irregular set of points. For example, I have the following grid consisting 16 nodes in the 2D plane:
...
0
votes
1answer
101 views
Mathematica syntax
Please I'mm trying to understand this sentence in Mathematica if $d=(x4+34x3+45)y^4$
; my task to replace all y2y2 by ...
0
votes
1answer
36 views
How to find lists associated with the max ListCorrelate
Suppose I have two lists like this:
list1 = RandomReal[10, RandomInteger[{20, 50}]];
list2 = RandomReal[20, RandomInteger[{20, 50}]];
Now I can find the max ...
2
votes
0answers
196 views
Code Review: ECDSA for Mathematica
The code below contains functions related to ECDSA (Elliptic Curve Digital Signature Algorithm) with standard parameters secp256k1. The implementation is based on ...
1
vote
0answers
41 views
Extracting elements with a certain criteria from a pre existing list
Here I take just a random list of triples of size 10
...
2
votes
2answers
64 views
Logical test of a single symbol against multiple values
I'm currently trying a function that behaves differently depending on what kind of Type string you enter. This string can have six different values, let's say "A", "B", "C", "D", "E" and "F". What I ...
0
votes
1answer
56 views
“Input” function for when someone was born
I asked this earlier, but removed my post because I was able to create some more code for it. I am writing a program that asks a user for their birthdate in three separate steps, month, day and year, ...
1
vote
1answer
46 views
How to iterate over an “Input” function?
I wasn't sure what to name this title, I will explain this code just incase some people actually aren't running it on Mathematica..This code will ask you "what is #1 * #2", where #1 and #2 are random ...
1
vote
2answers
76 views
Maximizing the Area of a triangle with given coordinates (and more)
I am trying to find the MAXIMIZED area(s) of a triangle given a bunch of coordinates. I will explain each part of my code and explain more in depth to this task..This task is to take 3 coordinate ...
1
vote
0answers
39 views
Apply a test function to variable arguments
I want to provide a function f[x_,y___] which applies a pattern matching test also on the optional parameters (e.g. request that they are vectors of numerical quantities).
In case of one single ...
0
votes
0answers
35 views
Is there a Better Function to Manage Styles?
When I work with Word or with LibreOffice, I always use stylesheets and the quick access toolbar (German: Schnellzugriffe): i.e. when the cursor is somewhere, it shows me the name of the template used ...
0
votes
1answer
48 views
Exporting the private stylesheet of the current notebook to some other notebook
How can the private stylesheet of the current notebook be exported to some other notebook?
0
votes
1answer
50 views
Programatically Storing a Modified Notebook: Part of the Path…does not exist - But it Does!
I have modified a Notebook programmatically like this. The notebook may have been loaded or not before the function is called:
...
2
votes
2answers
81 views
Taxi Cab problem - Loops
First, I just want to say I know that "ManhattanDistance" is a built in command for finding the distance between 2 pairs of points. But I have created my own function as follows:
...
8
votes
1answer
279 views
How do I 'Join' two Structured Datasets?
Consider the following Datasets
dsCompetitions with fields {"id","name","eventTypeId"}
dsEventTypes with fields {"id", "name"}
I want to join the datasets as ...
0
votes
1answer
59 views
nesting functions
I am trying to nest some functions together so that I have one final equation I can call (this is herons formula for triangles), which utilizes those previous functions I created. I've done this ...