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.
108
questions
-2
votes
1
answer
393
views
What is wrong with my code? [closed]
What is wrong with my code below
...
1
vote
2
answers
132
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 ...
0
votes
1
answer
97
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 ...
0
votes
1
answer
39
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 ...
7
votes
1
answer
425
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:
...
1
vote
0
answers
143
views
1
vote
2
answers
75
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 ...
2
votes
1
answer
162
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 ...
1
vote
0
answers
314
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:
...
3
votes
2
answers
291
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 ...
2
votes
0
answers
43
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 ...
2
votes
1
answer
166
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 ...
1
vote
2
answers
824
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\...
6
votes
2
answers
174
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.
...
0
votes
1
answer
101
views
Why this expression doesn't work?
I am trying to choose a function and then the parameters using Manipulate, but isn't working...
...
6
votes
2
answers
171
views
A box structure with a depth exceeding the maximum allowed depth was encountered
I am trying to perform the task in Mark McClure's article Parametric L-Systems and borderline fractals. I have copied his opening code on the first three pages:
...
-3
votes
1
answer
117
views
Help with NDSolve for system of odes [closed]
Can someone please tell me what I am doing wrong? I am trying to solve a system of odes using NDSolve. The code I have written is as follows:
...
1
vote
1
answer
99
views
Please help me find my error [closed]
When I use variables, errors are encountered. But when I change the variables to constants, I don't have a problem, but I wonder why.
...
0
votes
0
answers
37
views
How to get a full name function [duplicate]
I have some function in string format,and I can get it short name without context
...
5
votes
1
answer
567
views
Label State Space Models converting ODEs
Say I have a set of differential equations not necessarily in first order form. I would like to build the corresponding state space model. When equations are many and long, it becomes difficult to ...
3
votes
1
answer
115
views
1
vote
1
answer
69
views
Defining constants inside a script?
At the beginning of my script, I define a constant E by writing E:=2u+2uv, but then at the end of the script after running the final command, the result comes out with the form K/(2u+2uv). My question ...
-5
votes
1
answer
190
views
How to get the coefficients of a generator function? [closed]
I am trying to programming the following in Mathematica; however I am having trouble getting this to work inside the For loop.
$$\text{For}\left[i=1;i^2<10,i\...
0
votes
1
answer
79
views
I just don't see the difference
I checked it by hand and i am sure that the first code does what i want it to do. But i just don't get even by calculating by hand why the 2nd code is wrong.
The only difference in the two codes is ...
3
votes
2
answers
640
views
Solving a reaction diffusion dystem [closed]
I have a problem solving a numerical reaction diffusion equation. It emits the following message:
RecursionLimit::reclim2: "Recursion depth of 1024 exceeded during evaluation
How can I solve this ...
7
votes
2
answers
514
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, ...
1
vote
0
answers
152
views
How to suppress the Windows crash report dialog results from Mathematica sporadical crash when the code is running [closed]
This problem occurs in mathematica 10.0 for windows 7 64 bit.
The dialog box in the center of the picture shows that "mathematica kernel for windows has stopped working". I don't know when this error ...
-5
votes
1
answer
105
views
Can't get plot using the Evaluate function [closed]
I am trying to plot a series of five curves using a loglogplot command and then labeling the curves with a value. This is the program I am trying to run.
...
1
vote
1
answer
349
views
ParametricPlot3D shows an empty box
I'm trying to visualize numerical solution of 4 differential equations (these are the coordinates of a wave function in a quantum mechanical system):
...
1
vote
0
answers
33
views
Inconsistency when adding a variable to an analysis
I have a system of three ODEs that I want to find the steady states of, and whether or not they're stable via a simple analysis. To do so, I just calculate the eigenvalues of the Jacobian evaluated at ...
10
votes
2
answers
1k
views
What is the Difference Between Rule (->) and RuleDelayed (:>)?
I am new to Mathematica so this question may seem rudimentary. Sorry for that! :)
I want to implement the well-known property of Kronecker's Delta
$$\Sigma_{i=1}^{n} a_i \delta_{ij}=a_j,\quad 1 \le ...
2
votes
1
answer
1k
views
NDSolve: Indeterminate expression 0. ComplexInfinity encountered? [closed]
The following code give errors that I don't understand.
Could you please suggest a method to solve these differential equations?
...
0
votes
1
answer
67
views
Second order differential equation, with term from previous numerical solution
I have a second order differential equation, in terms of a term that was previously obtained from numerically solving another equation.
Numerical solution of equation before 2nd order equation:
<...
1
vote
3
answers
542
views
Solving cubic equation with unknown coefficients
I am trying to solve a cubic equation with unknown coefficients (p and t), here is the code:
...
-7
votes
1
answer
134
views
My program to model exterior ballistics doesn't doesn't produce the plot I expect
Here is my program to model exterior ballistics. It doesn't doesn't produce the plot I expect. How can I fix it?
...
0
votes
1
answer
125
views
Lagrange multipliers implementation (beginner question) [closed]
I am trying to write a code to find the minimum of $f(x,y) = (Mx + Ny) \,/\sqrt{M^2 x + N^2 y}$?, subject to the constraint $g(x,y)=x+y-1$. Also, $x,y>0$, and $M$ and $N$ are positive constants.
...
0
votes
1
answer
50
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$ ...
2
votes
1
answer
267
views
Why different output is obtained for the same code (Mathematica 10.1)?
I wrote some code in Mathematica:
...
10
votes
2
answers
5k
views
How to set up a simple Monte Carlo simulation?
there is a 1% chance that there will be a scattering event, if there is a scattering event the direction of scattering will be determined by a random sample of the custom[a_] function and if there is ...
2
votes
1
answer
367
views
Getting errors when I try to evaluate code taken from Trott's Mathematica Guidebook for Graphics
I would like to learn how to make high quality images in Mathematica. In my pursuit, I have come across Michael Trott's Mathematica Guidebook for Graphics. I have been trying some of the examples, ...
0
votes
2
answers
204
views
Replace $z$ with interpolated function and plotting
I start off with this equation $z(x,y) = sin(xy)$. I create an interpolation from $0 < x < 5$ and $0 < y < 5$.
I then use this interpolation on a simple function $w(x,y) = x + y + z(x,y)$
...
4
votes
1
answer
896
views
Issue in ParallelTable after evaluating another function using NDSolve and FindRoot. What is wrong with this inverse?
I am trying to find the inverse of a function which is defined through NDSolve and NIntegrate.
The question is pretty similar ...
1
vote
1
answer
880
views
Error message: Coordinate index 0 is out of range for the enclosing GraphicsComplex
I am unable understand following error message: Coordinate index 0 is out of range for the enclosing GraphicsComplex. How to fix it?
Attached data here: pts and polygons. See also end of question.
<...
3
votes
2
answers
2k
views
Create Table of replacement rules
I want to create a table of replacement rules.
...
0
votes
1
answer
98
views
What's going wrong with this button! [duplicate]
I'm implementing an Adaline algorithm where all inputs are 1x5526 and the output is a number from 1 to 10. I have this two functions defined and worked outside the ...
3
votes
3
answers
1k
views
For-loop not working as I expect
I want to do this:
When 10 <= t < 130, give t -> 1;
When 130 <= t<300, give <...
-4
votes
1
answer
1k
views
How can I plot a function that is the sum of another function?
I plotted m[t], but actually what I want to plot is g[t], which is a summation of m[t] from ...
4
votes
1
answer
366
views
Why Min cannot be used as constrains of NMinimize?
I met a strange problem when trying to do an optimization.
Initialization code,
...
3
votes
1
answer
138
views
some confusion about ReplaceRepeated
This is Right.
NestWhile[Log, 100, # > 1 &]
{100} //. {x_} /; x > 1 :> {Log[x]}
100. //. x_ /; x > 1 :> Log[x]
This is wrong,why?
...
0
votes
1
answer
340
views
updating code from 5.0 to 9.0
I am updating a code from a 5.0 version to a 9.0 version. I am speaking about "Advanced visual quantum mechanics".
There is a package with this code:
`
...