This tag is intended for the review and improvement of style for already functioning code. It not meant to change the objective of the code.

learn more… | top users | synonyms

4
votes
2answers
128 views

Sound synthesizer using Manipulate

Sound synthesizers, both digital and analog, often include a parameter section for shaping the amplitude of a sound wave over time. This parameter section is commonly known as an "ADSR EG" (attack, ...
0
votes
1answer
86 views

Making a bouncing ball simulation interactive [closed]

Problem A ball initially at height $h_0$ above a horizontal surface is dropped at time $t = 0$ with zero initial velocity. When it arrives at the surface, the ball bounces in the vertical ...
0
votes
1answer
39 views

Mean brightness and the standard deviation of columns in a gray scale image

I want to calculate the mean brightness and the standard deviation of columns in a gray scale image (8bit). Can the following calculation code be made faster or/and shorter: ...
1
vote
1answer
68 views

Efficient method to calculate green's function between points

I am working on an analytical model for sound radiation from a cylinder. As part of this work I am using the boundary element method to predict the sound pressure at a particular location away from a ...
15
votes
8answers
2k views

How to avoid procedural loops in this example?

I want to iterate over a list, and return the index as long as I found the first element satisfying my condition. Written in a for loop: ...
3
votes
1answer
54 views

How to index multi-dimensional vectors in NDSolve/WhenEvent?

I want to solve a system of coupled ODEs using NDSolve with WhenEvent. But I'm having a hard time trying to index the state ...
15
votes
3answers
301 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 ...
2
votes
2answers
128 views

Multiple object detection and tracking in images

The code below: reads in a number of png images, where the background is dark and objects of interest (here 3) are bright dots determines in each image the coordinates and other information ...
1
vote
2answers
75 views

Using solve on conditional functions

I know that the code is pretty long, but most of it is just defintion. Do you see why the Solve gives me "his system cannot be solved with the methods available to Solve" back? ...
4
votes
1answer
123 views

What is wrong with my code so it neither produces a correct plot nor an error message?

I am trying to define some initial functions and then using them to define my secondary functions and then plot the secondary functions. I am supposed to get two curves with a finite width ...
1
vote
3answers
249 views

Enneper's minimal surface

How to plot the Enneper's minimal surface like this I tried: ...
0
votes
2answers
554 views

Mathematica Implementation of Householder’s Method

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

How to construct the RHS of Wick's theorem

I've been trying this for a few days now, but I just can't seem to find an efficient (speed-wise) functional way to code the following task. Context: I would like to construct an expressions that is ...
2
votes
1answer
170 views

Passing function as argument

I've been mucking around with passing functions as arguments to other functions and via trial and error seem to have something that works. I was wondering if someone could have a quick look at some ...
0
votes
1answer
44 views

Exporting in .dat format [closed]

I am new to Mathematica. I am trying to write the data of the plot of some function which I am using in a .dat format. I am using the following commands to do so: ...
0
votes
1answer
94 views

NDSolve for a system of nonlinear coupled pde

I try to solve a system($n$) of coupled nonlinear 1-d PDE's which is basically coupled sine-Gordon equations (through 2nd spatial derivative) in time and space. I am interested in the dynamics when I ...
34
votes
0answers
1k views

Fast Spherical Harmonics radiative transfer

This is a rather specific question and I apologize for spamming you with some lengthy code. But it could be interesting for some reader and maybe you can help out, so please bear with me. I am using ...
6
votes
1answer
145 views

How can I do a two dimensional Fold? [closed]

I'd like to Fold over higher dimensional objects than lists. Semantically, the format would be something like ...
2
votes
1answer
37 views

wrong result of an iteration related to replacement and comparing

We have two nested matrix and a code for replacement following an equality as: ...
1
vote
3answers
195 views

How to combine Tabview with Dynamic Graphic to change the colour of a polygon

How does one get TabView to specify the colour of the Polygon? How does one put a label on ...
1
vote
1answer
47 views

FilterOptions Errors with Riemann Sum Notebook on Math World

I am trying to run the notebook for a maximum (upper) integration calculation (hopefully, symbolically). I am using the notebook available at Wolfram Math World (upper left of web page). When I ...
1
vote
2answers
91 views
0
votes
1answer
177 views

How to write this Matlab code in Mathematica

I have a small hiccup here. I am trying to write my Matlab code for a dynamical system in Mathematica. I have managed to get most of it except one part. The Mathematica code for the system is <...
3
votes
1answer
72 views
1
vote
2answers
123 views

how to generate repeatable Unique streams?

I need to label some data in arbitrarily nested ragged lists, with a stream of unique labels. It's very convenient if the labels are consecutive integers, starting at ...
1
vote
2answers
96 views

Maxima turn out to be false maxima when extremising function locally

In short: I have a 2-D function that gives this plot, where the orange dots are maxima: There are 4 maxima in this plot. Now, I plot the function again in a smaller region, close to these maxima, ...
4
votes
3answers
147 views

Tips to write more readable code [closed]

What are some tips to write a more readable code? For example in C, tab is your friend. You can also declare variables in a way such that you can read the code easily later on. In Mathematica, if ...
4
votes
2answers
257 views

Finding large Collatz Sequences, trying to improve speed

Background: I am already very much in love with Mathematica but I am also a novice. So far I have only gathered experience in procedural programming in Python. Generally speaking I am trying to ...
14
votes
3answers
396 views

Clever use of DownValues, or failure to understand the “Mathematica Way.”

I needed to look at the changes in the values of about 4000 items from one year to the next. I have a table with identifiers and values for each year. Not all of the items are in each list. The ...
11
votes
1answer
161 views

The equivalent of dplyr mutate with Dataset

In R, there is a package "dplyr" that works on data.frame objects, which is one of the origins of the Mathematica Dataset construct. One of the things dplyr can do is "mutate" the columns of a data....
2
votes
2answers
169 views

Solving problem using recursive functions

Attached below is a question posed by the Canadian Mathematical Society, and I have my code and answer. Is there a better way of writing the code, and will the answer be different as a result? My ...
0
votes
1answer
124 views

Understanding simple code [closed]

Can anyone help me with how to understand the definition of the ExpandNCM function listed in the NonCommutativeMultiply ...
4
votes
1answer
99 views

How to define UpValues of NBSpline when the length of argument is unknown?

I mimic the built-in BSplineBasis[] to build a user-defined function NBSpline[], Namely, ...
11
votes
1answer
245 views

Extract what symbol is set by SetDelayed, Set, TagSet, UpSet, SetAttributes, etc

One of the recent features of the Mathematica Plugin for IntelliJ IDEA (www.mathematicaplugin.halirutan.de) is a Structure View which let's you see information about several definitions that are done ...
5
votes
0answers
149 views

Better way to compute triple (or higher order) convolution

I have an identity that I want to verify: $$\sum_{i+j+k\ge 2}\binom{n}{i,j,k}{B_{N,i}B_{N,j}B_{N,k}}=\left(\frac{2N^2+n^2-3nN}{2N^2}\right)B_{N,n}+\left(\frac{3n^2-2n-4nN}{2N^2}\right)B_{N,n-1}+\...
2
votes
1answer
894 views
6
votes
2answers
145 views

Plot of The RiemannSiegelZ Function

I would appreciate your help to visualize the of the following function RiemannSiegelZ[x] with this range. { 18154980120849865 , 18154980120849885 } I tried this: ...
0
votes
1answer
100 views

Eigenvalues and Eigenvectors Order [duplicate]

Say I have a list of eigenvalues and eigenvectors produced from a matrix $M$ using the command {eig1,eig2}=Eigensystem[M], which will return the eigenvalues with ...
0
votes
1answer
37 views

Variable Definitions and Random Numbers [closed]

I have currently created the following matrix: m={{RandomReal[{0,1}],RandomReal[{0,1}]},{RandomReal[{0,1}],RandomReal[{0,1}]}} In other words, a $2 \times 2$ ...
3
votes
1answer
53 views

Saving Dot-ed eigenvectors in a special comparison

We have produced a 4*4 matrix in any iteration containing nx from 0 to 2 by steps of 0.5. and in any iteration we have saved sorted orthogonalized-eigenvectors based on their eigenvalues with this ...
2
votes
0answers
53 views

Reducing quantile & color map queries for use with Associations

This set of queries perform basic maps to quantile and then color-map. There's got to be a more compact solution. What are some approaches to reduction? Numeric: ...
3
votes
0answers
95 views

Memory Management for Large Datasets [closed]

I've written some Mathematica code to generate polynomial roots. The code take an argument n as the highest degree of polynomial to solve for and then exports a file containing a list of the roots: <...
2
votes
1answer
315 views

Runge-Kutta-2 on System

After spending some time using the Mathematica documentation and this Mathematica.SE answer, I implemented the Runge-Kutta-2 routines. I am hoping someone can validate what I did and tell me that it ...
1
vote
1answer
66 views

Sort and Save Matrices Eigenvectors to a Larger Matrix

We are going to sort and save all orthoginalized-eigenvectors of 4*4 random matrices (produced in any iteration) to a larger matrix such as storagematrix. Since, produced random matrices are 4*4, ...
30
votes
1answer
2k views

May the Fourth be with you

Happy Star Wars day. I was playing around with the image manipulation functions in Mathematica in an attempt to recreate the Star Wars crawl. There's an HTML/CSS implementation which is in my ...
5
votes
1answer
121 views

Composition vs serial assignment, which performs better?

I have a giant block of code that manipulations an expression in many different ways. Currently it looks like ...
1
vote
2answers
272 views

Having trouble translating Matlab `fsolve` into Mathematica

I searched the site and found that someone said FindRoot is equivalent to fsolve, however, without proper options, ...
3
votes
2answers
164 views