Skip to main content

Questions tagged [code-request]

Questions on finding existing Mathematica implementations or expertise to address a clearly stated problem.

Filter by
Sorted by
Tagged with
0 votes
0 answers
31 views

ReplaceIndexed function

I would like a replaceAllIndexed in the spirit of MapIndexed where there is an easy way to access the counter in the rule. I ...
Kvothe's user avatar
  • 4,491
0 votes
0 answers
73 views

SoftmaxLayer with one-hot vectors

The quantum physics problem I am looking at is a rotated qubit. The setup involves a y-rotated qubit measured in the z-basis (hence spin-up and spin-down). This scenario typically includes modeling ...
John Doe's user avatar
  • 229
0 votes
0 answers
43 views

Using CrossEntropyLoss function for basic neural network

Hi I am interested in understanding how to use the neural network functions in Mathematica. I have just started learning hence this is a basic query. The simple example I am looking at is as follows: ...
John Doe's user avatar
  • 229
0 votes
0 answers
42 views

Solve in solving equation system

I have the following problem: I have a system of equations specifically consisting of 56 equations, with 34 coefficients to be determined, in simplified form: ...
iron's user avatar
  • 1
0 votes
2 answers
76 views

Generating lists where new elements depend on the previous element

I am interested in using some type of list or table in-built Mathematica function to generate a list, where the elements of the new list not only depends on the input values of a previously defined ...
John Doe's user avatar
  • 229
3 votes
2 answers
141 views

How to draw a curve projection?

I want to draw the following projection picture for the cuspidal cubic curve in Mathematica. Does anybody know how to do this?
eloparti's user avatar
5 votes
4 answers
350 views

Still on Filling

I am really sorry to bother you for the same problems, but I cannot get in the view about this command, the filling option. What I want: to fill the semicircle part, under the $y = x$ curve. Here is ...
Enrico M.'s user avatar
  • 961
0 votes
1 answer
61 views

Generate all commutators and anti-commutators up to a certain order of a list of matrices

I am given a list of matrices. At first order I want to evaluate the commutators and anti-commutators of all pairs in the list and return a new list that contains two lists: one containing all ...
JohnnyB's user avatar
  • 95
4 votes
3 answers
205 views

Vertical line: plotting and filling

I need some help to complete this code in order to make the wanted plot. In the following, the function that I define as $m(x) = 1$ should be replaced (if possible) to a function that plots a vertical ...
Enrico M.'s user avatar
  • 961
1 vote
1 answer
64 views

Adding list of error-bars to plot

I have a basic question about adding error-bars to a plot. It seems that the built-in errorbar function is no longer available, could someone advise on what would be an efficient way to include the ...
John Doe's user avatar
  • 229
2 votes
1 answer
56 views

Solving multivariable equation after setting partial derivative to zero

I have a real-valued function of four variables, namely $L[\phi, m0, m1, m2]$. I am interested in taking the partial derivative $\partial_{\phi}L$ thereof and setting the partial derivative to zero, ...
John Doe's user avatar
  • 229
3 votes
1 answer
104 views

Problem with calculation of Lyapunov exponent

The code given by Chris K for Lyapunov Exponent does not work and gives lot of errors for the dynamical system given in equation(2) of this paper The dynamical equations: ...
Arssat's user avatar
  • 81
7 votes
1 answer
496 views

Borromean rings [closed]

how can I plot the Borromean rings in Mathematica? I am interested in the configuration showcased in figure.
Yasha Gindikin's user avatar
1 vote
1 answer
85 views

How to plot a community structure with specific properties

This code generates a community structure where each community is shown with a different color. The same color is used for bars within a community and outgoing edges from that community. I would like ...
Tugrul Temel's user avatar
  • 6,223
2 votes
1 answer
86 views

Alternative Representation for Energy Levels and Energy Level Density

I need to show the energy level density around the local maximum of this double-well potential. I can do it using the following: ...
user444's user avatar
  • 2,446
5 votes
5 answers
210 views

How to color a selected set of variables in a ListPlot

This code: ...
Tugrul Temel's user avatar
  • 6,223
4 votes
1 answer
278 views

Recognizing a Higher Percentage of Multiple Barcodes from an Image

I would like a path or way to find barcodes in an image and read more of them and ideally quicker (It is very slow for an image). So, BarcodeRecognize[] already ...
Teg Louis's user avatar
3 votes
1 answer
91 views

Quickly processing long lists using SequencePosition

Overview SequencePosition does exactly what I need; however, it seems to be very slow for long lists. Is there an input option that would allow it to process faster? Or, perhaps an alternative ...
user6546's user avatar
  • 1,069
5 votes
2 answers
162 views

How to combine two different datasets to create a unified dataset

I have two different datasets : dsDat1 and dsDat2: ...
Tugrul Temel's user avatar
  • 6,223
7 votes
6 answers
553 views

How to identify intervals for each integer number

I have two lists: ...
Tugrul Temel's user avatar
  • 6,223
9 votes
2 answers
1k views

Can Mathematica perform logical reasoning?

The question goes like this: Ms. Li has just moved into a new home and plans to buy several potted plants at once. Her thoughts are as follows: Buy either Green Radish or Podocarpus. Buy at least ...
csn899's user avatar
  • 4,315
1 vote
1 answer
59 views

Compressing a file's name string

I was working with files where each name records a lot of information about what is in its respective file and wanted to compress it a little bit. So I wanted to change it's 'base'. And I noticed that ...
Teg Louis's user avatar
2 votes
2 answers
183 views

Why do image sizes shrink when printing multiple plots as a single object?

I searched the repository a lot and found no answer to the following question. My code below produces 4 plots as a group. Each plot has ImageSize->300. However, ...
Tugrul Temel's user avatar
  • 6,223
6 votes
3 answers
417 views

Placing a single X and a single Y axis to a group of plots

I have the following 4 plots sharing a common X and Y axes. I place 4 plots in a grid of 2 by 2. I do not want to use separate X and Y-axis labels for each of them. Instead, I want to put a single X-...
Tugrul Temel's user avatar
  • 6,223
1 vote
2 answers
73 views

Numerical search of two simultaneous equations for three unknowns

Given the following two equations with three unknowns $\eta_1, \eta_2$ and $\tau$: $\frac{i e^{-i \phi/2}}{\sqrt{2}} = \cos(2 \tau - \eta_1 -\eta_2)\cos(\eta_1-\eta_2) - i\sin(2 \tau - \eta_1-\eta_2)\...
John Doe's user avatar
  • 229
3 votes
2 answers
280 views

Reading what is inside DataStructure[]

In my code I end up with such data structures and I cannot see what is inside. Is there a command to open this type of data structure? I tried \\Normal but it does ...
Tugrul Temel's user avatar
  • 6,223
7 votes
1 answer
283 views

How to condition all cells of a notebook to a specific SeedRandom?

Is there a way to fix SeedRandom[.] for an entire notebook? If I carry out many calculations using random numbers, I need to give a separate code ...
Tugrul Temel's user avatar
  • 6,223
4 votes
1 answer
140 views

How to maximize over a set containing an isolated point?

How can I maximize a function F over a set composed by a compact set like [a, b], plus a single isolated point, like $[a, b] \cup \{p\}$? I cannot code the isolated point part.
Heidegger's user avatar
  • 321
1 vote
2 answers
137 views

Shape of a boomerang

I want to create a physical pendulum in 2D with the shape of a boomerang. And first problem I met with was how to define a boomerang, so I could have a shape of it and use it to make my pendulum. Can ...
pewna osoba's user avatar
1 vote
1 answer
148 views

How can a directed network model be linked to Dataset[ ] for further computation?

REVISED Question: My only request is to know how to monitor the evolution of {agentStates, steps} in simulateSlow[...] function. ...
Tugrul Temel's user avatar
  • 6,223
2 votes
1 answer
74 views

Defining multivariable function from previous cell output

In the following, I would like to define a function $h(\theta, \beta, \alpha_1, \alpha_2)$. The function $h$ should be defined by the output of a previous function (which includes the partial ...
John Doe's user avatar
  • 229
1 vote
0 answers
152 views

How to construct a layered 3D graph of three community structures?

Consider: ...
Tugrul Temel's user avatar
  • 6,223
0 votes
1 answer
52 views

Making some powers of variables inside the function : $X * \alpha^{m} *\beta^{n} f[A[x,y]] \Rightarrow X f[\alpha^{m}\beta^{n} A[x,y]]$

Suppose I have a function of the form $ a_1 a_2 \cdots a_n b_1 \cdots b_m \cdots f[L[x,y]]$. I want to make some particular letters and their power inside the bracket. i.e., I want the letter $\alpha,...
phy_math's user avatar
  • 923
1 vote
2 answers
136 views

Normalized Coincident Detection Probability of Laguerre - Gaussian Modes

I am working on a paper in which a pump mode is passing through SPDC(Spontaneous Parametric Down conversion) is converted into two photons called as signal and idler. In which laguerre-Gaussian mode ...
Qubit's user avatar
  • 45
2 votes
0 answers
74 views

Extracting tables from .pdf

Can we construct some automated method for extracting tables from pdfs? I can get decently far by just copy and pasting its content and splitting at newlines but it would be great if it was possible ...
Kvothe's user avatar
  • 4,491
2 votes
1 answer
86 views

How to transform the regions in which a piecewise function are defined?

I have a function f[x,y,z] that has a piecewise definition, i.e., its values depends on the ranges of the arguments. Now suppose I have a coordinate transformation <...
user1620696's user avatar
1 vote
2 answers
178 views

Sorting a list of functions by exploiting the recursive structure

Given a list of functions list and a vector of arguments {t, a}: ...
Tugrul Temel's user avatar
  • 6,223
3 votes
1 answer
563 views

How to simulate a directed acyclic graph?

My goal is to have a code to identify and estimate the regression models associated with a directed acyclic graph (DAG), which is obtained through the reduction of a given weighted, directed graph <...
Tugrul Temel's user avatar
  • 6,223
9 votes
1 answer
374 views

How to replace graph communities with the associated bar charts?

The following code generates a community graph and a set of bar charts, each one of which corresponds to a community. ...
Tugrul Temel's user avatar
  • 6,223
0 votes
0 answers
75 views

Finding the Complete Silhouette Area Formula given a Convex Polyhedron

Like always, I am probably over complicating this and there is a much simpler way to derive a general formula using built-in Mathematica functions, think about it differently, or a faster way to solve ...
Teg Louis's user avatar
0 votes
0 answers
63 views

How to create a customized layered community structure from a directed graph

This answer provides a code for scaling the sizes of communities. I like to make the presentation of the community structure given in this answer (by @kglr) a bit more informative and friendly by ...
Tugrul Temel's user avatar
  • 6,223
4 votes
2 answers
183 views

How to create a size-adjusted community graph with eigenvector centrality bubles

Given this: ...
Tugrul Temel's user avatar
  • 6,223
1 vote
4 answers
312 views

How to observe transition pathway of a stochastic matrix?

Given a stochastic matrix, m, I like to observe the transition path converging to the limiting distribution. ...
Tugrul Temel's user avatar
  • 6,223
2 votes
1 answer
194 views

Python Code to Mathematica for Classical Map of Kicked Top

I am trying to convert this Python code for Classical map of kicked top to Mathematica. For a single trajectory, I am able to ...
user444's user avatar
  • 2,446
3 votes
2 answers
208 views

How to Draw Rectangle Chart Using Three Layers of Data?

I have some data given at three levels: ...
Tugrul Temel's user avatar
  • 6,223
3 votes
4 answers
354 views

How to use Callout in a directed graph with circular embedding?

Given the following code: ...
Tugrul Temel's user avatar
  • 6,223
5 votes
7 answers
443 views

Selecting string elements from list by using strings from another list

Given two lists of string elements list1 and list2: ...
Tugrul Temel's user avatar
  • 6,223
2 votes
1 answer
141 views

How to map community structure with circular embedding and normalized edge weights?

Given: ...
Tugrul Temel's user avatar
  • 6,223
2 votes
1 answer
64 views

How to locate chart labels correctly?

Given ...
Tugrul Temel's user avatar
  • 6,223
1 vote
1 answer
66 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 ...
kp2014's user avatar
  • 19

1
2 3 4 5
11