All Questions

Tagged with
Filter by
Sorted by
Tagged with
3
votes
2answers
121 views

Is there any command similar to Delaunay of matlab?

After finding this webpage where they mention the generation of land using matlab, In its section how it works, explain its operation in detail, I started trying to do it in MMA but I am doubtful of ...
16
votes
2answers
302 views

Improving Performance of an XY Monte Carlo

I normally write my Monte Carlo codes in Fortran for speed, but I was doing some quick and dirty work and wrote one in Mathematica for the XY model on a square lattice (see Kosterlitz-Thouless ...
3
votes
2answers
87 views

Function with string explanation for its arguments with equal signs [duplicate]

I want to write a function using string as explanation for its arguments so that the function becomes intuitive for new users. For example, I want to write a function to compute BMI (just for ...
5
votes
3answers
143 views

Pure functions applied to a two dimensional list

Lets say I have a two dimensional list: list = {{a, b, c}, {aa, bb, cc}, {x, y, z}, {xx, yy, zz}}; and two pure functions: ...
2
votes
1answer
51 views

Define a function with specific permutation properties

I want to define a function evaluate[f_[x__]] which acts on an arbitrary function f[a,b,c,d]. The function ...
1
vote
1answer
109 views

Complex partial fraction expansion

I would like to have a tool for partial fraction expansion of polynomial quotient $$\frac{P(z)}{Q(z)},$$ where the order of the polynomial $P(z)$ is less than that of $Q(z)$. The output of the ...
2
votes
0answers
75 views

Calling a notebook from a different notebook

Basically I have a notebook (let's call it nb1) that when evaluated yields one number when I specify some parameter $\alpha$ (in nb1). I want to call nb1 in a different notebook (nb2) using for ...
19
votes
5answers
1k views

Sisyphus Random Walk

A Sisyphus Random Walk evolves as follows: With probability (r) you advance the position of the walker by +1. With probability (1-r) the walker resets at x0 = 0. To simulate the probability of reset ...
2
votes
1answer
100 views

How to use external Mathematica Code? [duplicate]

I have a Mathematica Notebook with a function that i would like to be able to access from another Notebook without having to have the first Notebook open. The functions calls other functions in the ...
0
votes
2answers
48 views

An Alternative Solution to a List Manipulation Example

Is there any way to write a code that has a function include Block[ ] and Do[ ] loop instead of my code? Here is my code: ...
2
votes
1answer
77 views

Recall the names of functions used in a long MMA code

Suppose you have a very long code in which many new functions are created. For efficient programming, very short and easily iterated function names are preferred. ...
1
vote
2answers
171 views

Integration of a function that oscillates rapidly (apparently)

I would like to know if you could help me solve some doubts about the integration of a function that oscillates rapidly (apparently) that depends on time and two angular variables. The parameters S ...
0
votes
0answers
95 views

Help! SystemException[“MemoryAllocationFailure”]

I am trying to run this code: ...
-4
votes
1answer
123 views

how can i convert my matlab conde into mathematica or atleast convert the bisection program? [duplicate]

(Convert matlab code into mathematica code) (I'm fairly new to mathematica) (bisect function matlab code:) ...
4
votes
3answers
720 views

Recursion - Concentric Circles

I'm trying to develop my Wolfram programming skills and set myself an exercise of creating concentric circles using a recursive delayed function: ...
30
votes
5answers
697 views

Unexpected behaviors in built-in functions

Existence of this topic is discussed in this mathematica.meta post. I'm sure I am not the only non-beginner in WL who from time to time finds themselves not being able to predict an outcome of a ...
7
votes
2answers
1k views

Generate white noise in 2D

I am trying to generate a random (white noise) signal, as mentioned in the section Frequency Synthesis of Landscapes (and clouds) on this website. The problem I have is that I do not know if ...
1
vote
1answer
44 views

Looping variables not replaced by their values

Sometimes Table[ ] leaves the looping variable in the output, instead of replacing it by the values. For example ...
1
vote
2answers
354 views

How to convert from C to Mathematica?

I am trying to understand what is explained in this webpage, in the section entitled "Generating noise with different power spectra laws". After reading that section, I thought I could do it in ...
4
votes
1answer
77 views

Write Partition of $n$ as an $n$-tuple

I recently asked the question (Computationally Employ Sum over Ordered Partitions?) which I think I can work through. But there's a subtelty I overlooked before that problem is even well-defined, ...
1
vote
0answers
68 views

Computationally Employ Sum over Ordered Partitions?

I have the following function defined, with two inputs $g$ and $h$: ...
3
votes
0answers
48 views

Is there an equivalent to defstruct in Lisp for Mathematica? [duplicate]

I guess I am used to using data structures in most languages, the closest function for Mathematica would be similar to the defstruct macro in Lisp... is there such a thing?
1
vote
0answers
81 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]...
1
vote
0answers
47 views

Extracting elements with a certain criteria from a pre existing list

Here I take just a random list of triples of size 10 ...
0
votes
1answer
73 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
71 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 ...
2
votes
2answers
114 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: ...
1
vote
1answer
71 views

symbolic function assignment yields different results than explicit assignment

I am confused as to why the two functions below yield different results (as vs ss)? One function assigns the Piecewise function directly, while the other reads the same function from a list of lists. ...
29
votes
1answer
836 views

Is the renaming mechanism of `With` flawed?

I'm confused about the renaming mechanism of With: ...
8
votes
1answer
144 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 ...
2
votes
2answers
95 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. ...
10
votes
1answer
200 views

Core functions or operations that every aspiring Mathematica programmer should know? [duplicate]

I am aware that there are common yet very powerful operations like Map, Thread, Apply, ...
6
votes
2answers
834 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 ...
3
votes
2answers
273 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 ...
4
votes
2answers
194 views

Discritizing an analytical 3D-function

I have the following Problem: I need a discretized amount of points in a 3D-volume. These points satisfy a condition to built-up a 3D-geometry. In my example below I selected a helical geometry. The ...
1
vote
0answers
191 views

Help with calculating a complicated integral

Edit: The question is solved : )) Thank you for your attention ! I am sorry for mass questions, but the question bothers me a lot. So I would like to ask this question here. This problem arises when ...
5
votes
5answers
256 views

Nested function with an increasing argument

If, for example, I have a nesting function like Nest[1 + x^n (#) &, 1, 3] it gives the result ...
0
votes
1answer
651 views

How to implement the for loop to replace text strings or texts?

I wonder define a bunch variables named like $X_1$, $X_2$, $...$, $X_n$. Is there some smart way to declare them instead of by pure typing. One trick I can image is to use the for loop,...
8
votes
1answer
217 views

How would one return from a place of a pure function's body using Return?

From previous answers, replies and discussions it is known, while not formally documented (even in the most recent Wolfram Language Documentation Center), that Return can be used in a two-argument ...
4
votes
1answer
173 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 ...
5
votes
2answers
1k 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
1answer
917 views

How to properly use conditionals inside NDSolve

Currently I am working with Mathematica to learn the program, and I'm confused what exactly is wrong with this code. ...
3
votes
1answer
232 views

How do I create an array by applying a function to the index of each element?

I am looking for something like matrix(m, n, f), but for Mathematica rather than MuPAD, and for arrays rather than matrices. That is, I'm looking for a(n efficient)...
1
vote
2answers
1k views

FindShortestTour to solve Traveling Salesman Problem

I'm trying to write my own code to find the shortest route but I'm lost on how or where to start. Does anyone have any idea how the FindShortestTour function works? What type of algorithm or structure ...
5
votes
4answers
376 views

Expressions containing globally undefined symbols inside a function where they are defined

Consider the following code. f[a_,b_]:=x x=a+b; f[1,2] (* a + b *) From a certain viewpoint, one might expect it to return 3 ...
13
votes
11answers
2k views

Divide all but the maximal element in a list by 10?

I have a list of numerical data, and I want to write a program that will keep the maximum as it is, but reduce the rest by certain factor (such as 10). For example: ...
9
votes
4answers
572 views

What is shorthand way of Reap list that may be empty because of zero Sow

Sometimes because of conditionals, you cannot guarantee that Sow will be called at least once. Reap[Sow[1]][[2,1]] results in <...
2
votes
1answer
144 views

How to package a function for export?

I often post code for functions on Stack-Exchange, and then later find that they are unexecutable - that people can't use them because I mistakenly omitted some private functions or values that are ...
2
votes
1answer
675 views

How can I call the R-programming packages in my Mathematica?

I am trying to call the R-programming package called highfrequency in my Mathematica so that I can use its function rCov. I ...
8
votes
2answers
1k views

How to create a function like in Python

I want to call a function that would perform a function rather than assigning an expression to them. I.e. ...