Questions tagged [broken-code]

Use this tag only if you did your research and you still don't know why your syntactically correct code does not work.

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

How do we define the function near the end of my post?

Suppose I have two sets $F_{1,n}$ and $F_{2,n}$ written as: ...
user avatar
  • 199
0 votes
0 answers
55 views

Code Producing FindMinimum::nrnum; how do we fix it?

Suppose $A=\left\{\sqrt{m}:m\in\mathbb{N}\right\}$ and $S\subseteq A$: I wish to create a code which finds: $$\min\left\{c:\forall(d\in S)\exists(c\in A)\left(c/d\in A\right),\max(S)\le c \le \prod\...
user avatar
  • 199
0 votes
0 answers
36 views

Problem with ToExpression and TexForm changing two variables multiplied together into one multi-lettered variable

I have a problem where if I multiply two variables a c in Mathematica, then copy as LaTeX (or just use the Mathematica output) to get a c, then put it in ToExpression["a c",TeXForm], I get ...
user avatar
3 votes
1 answer
61 views

How to compile sum over the compiled expression?

Consider the following toy code: ...
user avatar
  • 3,542
1 vote
1 answer
90 views

How do we find the limit of my code?

Suppose we have the following: ...
user avatar
  • 199
1 vote
0 answers
79 views

How to fix Mathematica crashing in the following case?

I have a problem with Mathematica when trying to glue two tables together. The tables have the form ...
user avatar
  • 3,542
1 vote
1 answer
73 views

Outputting probability of rolling 6 dice N times, generating a new output each roll

I am looking to output the probability of n classic six-sided dice but I am not sure how to go about starting. This is what I have written out so far, but no way to go about accounting for n dice for ...
user avatar
1 vote
0 answers
48 views

Possible bug: Wrong differentiation of ParametricFunction inside Parallelize?

In the note RootSearch problem when called from within ParallelDo I described the problem with Ted Ersek's RootSearch package and came to the conclusion that it is ...
user avatar
1 vote
0 answers
103 views

RootSearch problem when called from within ParallelDo

I have been using Ted Ersek's RootSearch package for Wolfram Mathematica for many years. The package worked great, including inside the ...
user avatar
3 votes
2 answers
348 views

Euler-method implementation

How can I implement this pseudocode in Mathematica? Algorithm: ...
user avatar
  • 145
0 votes
0 answers
47 views

If definition of elements in table

I need to define a table where the definition of the elements differs if the indices $i$ and $j$ are equal or different. In particular I have to implement the following formula $$(K_1^{(1)}(m_1,m_2))_{...
user avatar
  • 105
-1 votes
1 answer
78 views

Costly function inside nested Modules [closed]

The function initDataTable simply reset all data to Black first, then set the bottom right quarter to ...
user avatar
  • 149
0 votes
0 answers
81 views

Reduce method not working for system of equations

I have the following code which sets up a Reduce function call: ...
user avatar
0 votes
1 answer
70 views

Deleting all elements in a list where the output of elements from a function is zero

I tried using DeleteCases to delete elements in r1 where g2==0 to get a defined arithmetic ...
user avatar
  • 199
0 votes
1 answer
53 views

Code Producing Power::Infty

I tried computing the following ...
user avatar
  • 199
2 votes
1 answer
116 views

Python to Mathematica code bug

I have an assignment in Mathematica, which I've already solved using Python and it's a bit hard to convert the code. Here's what I have done so far: ...
user avatar
  • 133
0 votes
0 answers
41 views

How to create 2-D or 3-D curves to simulate something like the SIR model

I don’t know what is wrong with my code. I am trying to create 2-D or 3-D curves to simulate something like the SIR model, but with tumor growth instead. It is a proliferation-invasion/ reaction-...
user avatar
2 votes
0 answers
43 views

ParallelTry Hangs on previously working code

When I run the below ParallelTry command, it just sits on it and says its being evaluated, but I cant abort it, it doesn't return what I am expecting, and I have to ...
user avatar
  • 413
1 vote
0 answers
41 views

Errors in loading IGraphM [closed]

I have been using IGraphM without any problem until today. My Codes using IGraphM started to ...
user avatar
  • 4,391
1 vote
0 answers
77 views

What is wrong with my code for implementing PSOR (Projected Successive Over Relaxation)? [closed]

I have written the numerical scheme of PSOR (Projected Successive Over Relaxation) method of a obstacle program in 1D, which is as follows: \begin{align*} &u_0=u_N=0\\ &u_i^{k+\frac{...
user avatar
  • 11
-3 votes
1 answer
68 views

Having trouble coding my own QR decomposition using Gram Schmidt [closed]

I have this code for Gram Schmidt: ...
user avatar
1 vote
2 answers
131 views

QR decomposition using Gram Schmidt [closed]

First of all I don't want to use the reflection method, only Gram-Schmidt. So here's the program for Gram-Schmidt: ...
user avatar
1 vote
1 answer
68 views

Help Calculating My "Deviation"

I created a "distribution deviation" where for $\left\{a_1,...,a_k\right\}$ we take all take the mean of all combinations of $\frac{\min\left\{a_{i},a_{j}\right\}}{\max\left\{a_{i},a_j\right\...
user avatar
  • 199
0 votes
0 answers
93 views

Error in Monte Carlo simulation. Now Random walk (dotted curve) doesn't fit to the analytical curve (dashed curve)

I've been trying to code a kinetic monte carlo simulation for a system of consecutive chemical reactions using a fixed (repaired) code that the user flinty gives me in the last questions I post: ...
user avatar
  • 13
1 vote
1 answer
82 views

Strange error not found in a monte carlo code, Infinite expression 1/0 encountered

I've been trying to code a kinetic monte carlo simulation for a dimerization reaction, 2M ---> D. However I have a kinetic Monte Carlo code for a first order decomposition reaction of AIBN (that's ...
user avatar
  • 13
-1 votes
1 answer
42 views

Using coding to calculate my average for functions defined on countable sets?

Suppose we have a function $f:A\to\mathbb{R}$ where $A\subseteq[a,b]$, $a,b\in\mathbb{R}$ and $S\subseteq A$. Now suppose $f$ is $$f(x)=\begin{cases} x^2+1 & x\in S_1\\ x & x\in S_2\\ \end{...
user avatar
1 vote
1 answer
93 views

How to partition $[a,b]$ into $m$ equal sub-intervals and count the number of sub-intervals that intersect with a subset of $[a,b]$?

Suppose we have a subset of $[a,b]$, where $a=0$ and $b=1$, such as $$A_1=\left\{\frac{1}{2^x}+\frac{1}{2^y}+\frac{1}{2^z}:x,y,z\in\mathbb{Z}\right\}\cap[0,1]$$ Which is a subset of $[0,1]$ If we ...
user avatar
2 votes
1 answer
75 views

How to partition $[0,1]$ into $m$ equal sub-intervals and count the number of sub-intervals that intersect with my cantor set?

Suppose I define my cantor set as ...
user avatar
1 vote
1 answer
57 views

ParametricPlot on Piecewise function not working with consecutive t values [closed]

I am trying to graph a piecewise function composed of a series of parametric cubic functions. I initially created a ParametricPlot for the first four pieces of the equation and it was working fine, as ...
user avatar
  • 33
0 votes
2 answers
62 views

Unable to find the exact dimension of an expression

I have defined a variable called y, this contains a huge equation, but when I look for the dimension of y it shows 3. How come a single expression has dimensions of 3? It is supposed to be 1 right? <...
user avatar
  • 1,639
0 votes
0 answers
248 views

Fourier Transform and Inverse Fourier Transform of Lists

I am trying to compute the Fourier transform of a list, say an array of the form {{t1, y[t1]},.....{tn, y[tn]}}; apply some filters in the spectral components, and then back transform in time domain. ...
user avatar
  • 153
2 votes
1 answer
47 views

User Implemented SHA-1 is failing for strings of length >512 bits

So, earlier, I posed a question regarding getting a user implemented SHA-1 hash function to work correctly. Well, I fixed the problems, cleaned it up a little bit, but now I have the problem for when ...
user avatar
1 vote
1 answer
175 views

Q: How to manage notebook crashes, "In a previous session", and memory consumption?

I worked in a notebook. Something went wrong. I do not know what or why. The notebook did not react anymore and closed. After it, I try to open the same notebook. Then the next text appears: "The ...
user avatar
0 votes
1 answer
719 views

I can't solve system of differential equations with Dsolve

Here is the code and the system, and it is supposedly analytically solvable. $$\frac{dx(t)}{dt} = i(\frac{3w}{2}x + ke^{2iwt}y)$$ $$\frac{dy(t)}{dt} = i(kxe^{-2iwt} +\frac{3w}{2}y)$$ and my code ...
user avatar
  • 101
0 votes
1 answer
138 views

Help with debugging my code [closed]

In order to descrive the multifractal behaviour of a set, Baumann provides a code based on the functions Dq and Tau, given below. ...
user avatar
  • 77
-2 votes
1 answer
276 views

What is wrong with my code? [closed]

What is wrong with my code below ...
user avatar
  • 359
1 vote
2 answers
128 views

I have two lists that are the same, yet I get a FALSE when i try to show they are equivalent

I have tried changing the variables, reevaluating the cells, but it just keeps giving me false. The weird part is that it was originally true and it changed to false, randomly.I did not want to post ...
user avatar
0 votes
1 answer
92 views

Do-loop with ParametricNDSolveValue not giving expected results

I have written code that using a Do-loop. In the loop I am changing the value of x, v, l and R, and looking at the computed ...
user avatar
  • 47
0 votes
1 answer
35 views

Solve command code problem with system of equations

This is my original equation f[x_, y_] = (4 x^2 + y^2)*Exp[-x^2 - y^2]; So I'm trying to find the partial derivatives w/ respect to $x$ and $y$ and set them ...
user avatar
7 votes
1 answer
396 views

What is wrong with this code? (Usage of FunctionInterpolation and how to make code efficient)

I am trying to create an interpolation out of a function that comes from an improper integral. The end goal is to make a 3d plot over a specific region. Specifically, I have the following code: ...
user avatar
  • 517
1 vote
0 answers
135 views

I can't find any mistake in my code! [closed]

...
user avatar
1 vote
2 answers
69 views

MaxValue does not use composed function correctly

I used the compose operator on two functions (a vector-valued interpolated from ndsolve composed with Norm) and then passed the result to MaxValue, which works fine only if I reapply the norm. What is ...
user avatar
  • 15
2 votes
1 answer
145 views

Code for finding multiple roots only finding two

I've an issue with my code. I am basically trying to get the n-th root of a function. My code finds two roots correctly, but for others, which I think should be distinct, I get the two roots repeated ...
user avatar
  • 121
1 vote
0 answers
274 views

What am I doing wrong in calculating the mean square error? [closed]

I am trying to compare the results of estimators from least squares and quantile regression from the perspective of the mean square error (MSE). The steps for performing this Monte Carlo approach are: ...
user avatar
3 votes
2 answers
253 views

Extract mesh coordinates from a LaplaceSolution Plot

I have made a code for the solution to a particular problem involving the Laplacian, and after plotting in 3D the resultant potential, I have tried to look for a ...
user avatar
  • 85
2 votes
0 answers
42 views

How can I fix this cycle in order to iterate several times? [closed]

I have been working on a code whose only purpose is to get the mean value over four numbers. And I managed to do one cycle, however after trying to repeat this process until a certain condition is ...
user avatar
  • 85
2 votes
1 answer
146 views

How to combine Graphics primitives in a DynamicModule without breaking it

I am trying to present Graphics primitives dynamically. I want the displayed image to be able to update after the user changes the controls. An example would be ...
user avatar
  • 3,980
1 vote
2 answers
665 views

Michaelis–Menten kinetics using Gillespie Algorithm

I am trying to implement Michaelis–Menten kinetics using Gillespie Algorithm. $$\text{Reaction 1:}\quad E+S\rightarrow C$$ $$\text{Reaction 2:}\quad C\rightarrow E+S$$ $$\text{Reaction 1:}\quad C\...
user avatar
6 votes
2 answers
158 views

NonlinearModelFit inside Manipulate

I can't understand why this behavior with my code... I'm trying to visually adjust the best parameters to fit my model, everything is working fine, less the part of adjusting the model. ...
user avatar
  • 222
0 votes
1 answer
98 views

Why this expression doesn't work?

I am trying to choose a function and then the parameters using Manipulate, but isn't working... ...
user avatar
  • 222