Questions tagged [code-request]
Questions on finding existing Mathematica implementations or expertise to address a clearly stated problem.
498
questions
3
votes
2
answers
194
views
How to Draw Rectangle Chart Using Three Layers of Data?
I have some data given at three levels:
...
2
votes
4
answers
316
views
How to use Callout in a directed graph with circular embedding?
Given the following code:
...
5
votes
7
answers
414
views
Selecting string elements from list by using strings from another list
Given two lists of string elements list1 and list2:
...
2
votes
1
answer
123
views
2
votes
1
answer
62
views
How to locate chart labels correctly?
Given
...
1
vote
1
answer
55
views
How to inverse matrix equations? [closed]
I've never used matematica before so still learning. I'm trying to show that two equations below are equal to one another. To do that, doing an inverse transformation from 3.5-3 to 3.5-4 would ...
2
votes
1
answer
118
views
Convert R code to Mathematica code of Poisson log-likelihood for the epidemic curve
I want to define a function that simulates the model for a given combination of parameters and calculates the Poisson log-likelihood for the epidemic curve of reported cases:
...
3
votes
1
answer
171
views
Improve performance of Linear Optimization
EDIT
I am reframing the question here by pulling out the relevant part about linear optimization, you can find the original question and the entire code down below.
I am trying to increase the ...
4
votes
4
answers
386
views
A simpler or more concise way to divide the boundary of a polygon into equal arc lengths?
I am really looking just for the least amount of code needed to do this but it is still readable.
Here is the same polygon but the border is respectively split up into 10, 20, and 30 points along the ...
2
votes
1
answer
89
views
Covering a rectangle with shapes/closed curves of equal area?
Motivation: We want to cover a rectangle using smaller, non-overlapping shapes with the same area: the difference between the total area of the shapes and the area of the rectangle should be zero or ...
1
vote
0
answers
68
views
How can I write the code for an inverse integral transform?
How can I code any type of integral transform with its inverse integral transform in Mathematica which gives the correct results and properties? Below is the example for Elzaki transform:
...
0
votes
0
answers
44
views
Way to download all attachments from yahoo.com
For a long time now I want to download the attachments from my yahoo.con mail, only the files, no text, but in batches, so MMA gets into my mail and downloads every attached file it finds in a folder.
...
1
vote
1
answer
67
views
How to represent a digraph in a 2D circle structure using NeighborhoodGraph[.]
This code works and delivers NeighborhooGraph[.] of a chosen vertex. The resulting graph is bit difficult to understand and therefore I like represent the same ...
4
votes
1
answer
115
views
Questioning Mathematica's Condition Representation: Strange Solution for Integer Variable
I have the following sequence:
$$f_n(x)=\left\{\begin{array}{cl}
1 & \text { if } 0 \leq x<\frac{1}{2} \\
1-(n+1)\left(x-\frac{1}{2}\right) & \text { if } \frac{1}{2} \leq x<\frac{1}{2}+\...
6
votes
2
answers
182
views
Listing all user-defined definitions used in a function call
Is it possible to obtain all user defined definitions (and attributes) that are used in the evaluation of certain command (or alternatively just their symbols which I could imagine being easier when ...
1
vote
0
answers
162
views
How to show the limit of two functions in a code approach zero?
I don't know how to shorten the program, the entire code is required to understand everything:
...
3
votes
1
answer
74
views
how to compute linked Manipulates with a more efficient code
I have several Manipulate codes as parts of a large block diagonal model. Each diagonal model produces outputs which are used in the second diagonal model, outputs ...
2
votes
1
answer
119
views
Covering a rectangle with arbitrary shapes of equal area, where the total area of the shapes is minimized
This is a follow up to this post, which had to be broken down since it was too long.
1. Definitions
Let $A=[-2,2]^2$, where $\text{Area}(A)=16$ and $\lceil \cdot\rceil$ is the ceiling function.
For $\...
4
votes
7
answers
353
views
Matching position of same elements in two lists
Suppose I have two lists of the same size as follows:
A1 = {a, b, c, d};
A2 = {c, a, b, d};
I want to construct a function that gives the relation between ...
4
votes
1
answer
110
views
Put text in Graphics3D syntax?
Some friends from the forum helped me to make this MMA script, I have tried to modify it to put text similar to the image, perhaps with a more beautiful letter, but I can't think of how, I have seen ...
0
votes
1
answer
117
views
4
votes
2
answers
144
views
How to find the most influential paths in a weighted, directed graph
Given a weighted, directed graph, I want to find the most influential paths (a combination of large weights). I reverse the usual shortest path problem because the context I am trying to model defines ...
4
votes
3
answers
155
views
how to balance a matrix by proportional adjustment of rows and columns
Given a matrix:
ClearAll[mat, refR, refC];
mat = {
{21.2, 29, 19.9},
{9, 48.8, 22.4},
{49.8, 62.2, 7.8}
};
I want to adjust the elements of ...
0
votes
0
answers
51
views
Part specification error
I am doing a solved exercise shared here.
However, while running the code, I encountered an error on page-8, under the Dynamics section.
with error :
I think this error is due to the absence of ...
1
vote
0
answers
92
views
How to find BetweennessCentrality[...] for binary edges rather than vertices?
I have the following directed graph g and can find BetweennessCentrality[g] for vertices.
...
1
vote
2
answers
119
views
Number operator
Suppose CR is my creation operator and AR is my annihilation operator.
I have to show that ...
2
votes
0
answers
59
views
Pick position of a particular list in the list of lists [closed]
Suppose I have some following lists with different size
...
3
votes
1
answer
104
views
Enumeration of a certain sequence IV
Let $F_n$ denote the $n$-th Fibonacci number. I am interested in the sequence $$a(k, n)=\left | \left \{0 \leq m \leq n: \frac{F_m}{k} \; \text{is a perfect square} \right \} \right |,$$
where $|\...
0
votes
2
answers
34
views
How to obtain terms defined by a recursion relation in terms of the first value without solving the recursion?
I have a set of coefficients $A_{i}^N$ where $i=0,\dots, N$ that obey a recursion relation that takes the form
$$A_i^N = C_i^N-\sum_{M=1}^N\sum_{k=0}^{N-M}A_k^{N-M}\psi_{i,k}^{N,M}$$
The coefficients $...
0
votes
1
answer
48
views
when we solve the simple ODE then [closed]
NDSolve[{u'[y] + (k + y) u''[y] - Ha^2 (k + y) u[y] -
u[y]/(-k + y) == -k, u[-1] == 0, u[1] == 0}, u[y], y]
gives the error
...
5
votes
1
answer
140
views
Adding Edge and Vertices to already made graph?
I have a notebook that generates a hexagonal grid graph and its vertex connectivity, coordinates, and numbers as an input for an FEA program in matlab. I simply want to add members to this shape (or ...
1
vote
1
answer
66
views
Additive graphs code
For $n\geq 1$ the fibonacci sum graph on the set $[n]=\{1,2,\ldots,n\}$ denoted by $G_n$, is the graph with vertex set $[n]$ and edge set $\{uv, u+v=F_i, \text{for some}\quad i\}$. I wrote the ...
1
vote
1
answer
163
views
Generating a table of squares and square roots up to 100
I want to generate a table of roots and perfect squares similar to the image, but I can't find the right code, I have searched the forum for something that works for me without favorable results. Can ...
2
votes
2
answers
89
views
Map, applying list in a defined function
Suppose I have defined some function (This is arbitrary)
F[alpha_,a_,b_,c_]:=List[alpha,a+b+c]
I want to apply this F for a given huge list of sets
...
1
vote
2
answers
103
views
Finding negative powers of polynomial expressions
Suppose I have the following expressions
...
3
votes
3
answers
192
views
Count and positions of an element in a given list
I want to implement an operation on the following list:
For a given arbitrary length of list $\{a1,a2,a3,a4,a5,a6,a7,a8,\cdots\}$, the task is to find the number of zeros and their position(s).
So I ...
1
vote
1
answer
95
views
How can I roll up a line to get a circle? [closed]
I am trying to transfer n1=4 points that I have on a line, on a circle. suppose:
...
4
votes
2
answers
80
views
Decomposing input to two list
Suppose I have $j[1,a1,a2,a3,a4,a5]$, I want to extract this as $\{1,\{a1,a2,a3,a4,a5\}\}$.
--My first trial:
Using the command Split, I can make
...
1
vote
0
answers
96
views
Matlab to Mathematica code to solve system of ODEs [closed]
I have the following system of second order non-homogeneous DEs:
\begin{align}
0 &= 2 x_t - J_{\pi_t}(x_t) \frac{\epsilon - 1}{\theta} (1 + \varphi) + \frac{\partial J_{x_t}(x_t)}{\partial x_t} \...
0
votes
0
answers
18
views
For given rules, discard some rules by imposing conditions
For a given input, and after some implementing conditions I want to discard unnecessary rules and pick only relevant rules.
More explicitly, suppose I have a following transformation rules.
...
0
votes
0
answers
42
views
Auto generate usage message in order to automatically have templates available for user defined functions
In order to remind myself of the arguments a function takes and their ordering I find it useful to use the shortcut to show the template (Ctrl+Shift+k). However, I don't write usage prompts for my ...
1
vote
1
answer
26
views
Substitution and make a list $ List[f[A, x]@{a1, a2}] =? \{f[a1,x],f[a2,x]\}$
For given list $\{a_1, \cdots, a_n\}$ and a function $f[a_,x]$, I want to make a function whose input is $[\{a1,\cdots, a_n\}, f[A,x]]$ and produce $\{ f[a_1,x], f[a_2, x], \cdots, f[a_n,x]\}$, i.e., ...
0
votes
0
answers
67
views
how to get this view in math,(always appear like this)
How do I make math look like this forever?
0
votes
1
answer
79
views
Improve performance of DeleteDuplicates for list of matrices
I have a matrix $A_0[x,y,z]$ and a list of matrices $B$ with about 30 matrices. Matrix $A_0$ is a function of some parameters $x,y,z$. I create a new list of matrices, say $A_1$ produced by ...
0
votes
1
answer
88
views
Lyapunov exponent of Van der Pol-duffing oscillator by varying parametric forcing
For a parametric Van der Pol oscillator as given
x'[t] == y[t], y'[t] == -0.1*y[t]*(1 + f*Cos[1.0*t])*((x[t])^2 - 1) - 0.41*(x[t])^3 + (0.5^2)*x[t]
for ...
1
vote
1
answer
149
views
Finding a suitable form factor for a given set of conditions
I have the following Mathematica code:
...
3
votes
1
answer
120
views
0-1 test or Lyapunov exponent, to prove my below system is chaotic?
The following question is a part of my research here,I want to calulate the Lyaponov exponents of the following dynamics to show whether i have a chaotic dynamics or not. $$
\ddot{x}-ax+bx^{3}+cx^{5}...
0
votes
0
answers
75
views
Why my bifurcation diagram can't be created?
I just tried to creat Bifurcation diagram for the following Duffing equation: $$
\ddot{x}-ax+bx^{3}+cx^{5}+A \,\cos \left(( \omega t)\right)+\gamma\, \dot{x}=g,\dot x(0) =0,x(0)=0
$$
with $$g: n \...
0
votes
1
answer
77
views
How to optimize the code for solving the Apollonian circle equation?
The distance from a moving point in the plane to (0,0) is lambda times the distance from (a, 0). And lambda is not equal to 1. Find the equation
...
0
votes
1
answer
60
views
Defining product between table
For the given table, I want to make their dot product as follows.
My pseudocode is given as follows: In order to make the dot product, first the table size should be the same.
...