E. Chan-López
  • Member for 4 years, 2 months
  • Last seen this week
  • México
Poincare Section of an Hamiltonian
19 votes

Try with the following code: H[px_, pz_, x_, z_] := 1/2 (px^2 + pz^2) + z + 2 (3/4 - Sqrt[x^2 + (z - 1)^2])^2 - 1/8 xpp = D[x[t], t, t] - x[t] (-4 + 3/Sqrt[x[t]^2 + (-1 + z[t])^2]); zpp = D[z[t], t, t]...

View answer
Is it possible to write a MMA version of LineInt like Maple?
14 votes

Another approach to this problem: (*Code for simple paths*) LineIntegrate[vectorfield_List, varsfield_List, path_List, varpath_, I_List] := Module[{vars, r, s1, s2, g1, g2}, vars := Table[...

View answer
Plotting Limit Cycle
10 votes

Hopf bifurcation analysis The differential system: f1[x_,y_]:=a x (1 - x/k) - b x y; f2[x_,y_]:=-c y + d x y; F[{x_,y_},{a_,b_,c_,d_,k_}]:=Evaluate@{f1[x,y],f2[x,y]}; X={x, y}; μ={a,b,c,d,k}; $$ \...

View answer
Get rid of a certain variable in a fraction's numerator
Accepted answer
9 votes

Try this: PolQuotient[num_, den_, var_] := PolynomialQuotient[num, den, var] + 1/den*PolynomialRemainder[num, den, var] Test: PolQuotient[a - b, a + b, a] (*1 - (2 b)/(a + b)*) Improving the above ...

View answer
How to draw discrete dynamic systems in mathematica
8 votes

Play with the following example: $$ \begin{eqnarray} x(n+1)&=&rx(n)(1-y(n))\\ y(n)&=&x(n), \end{eqnarray} $$ with $r=\displaystyle\frac{2005}{1000}$ and three orbits. The phase ...

View answer
Plot a double integral
Accepted answer
7 votes

Try this: f[x_] = Integrate[Integrate[x^7 (x - 2)^4 (x - 3)^9, x], x] Plot: Plot[f[x], {x, 2, 4.1}, PlotRange -> All, AspectRatio -> 1/GoldenRatio]

View answer
Routh-Hurwitz criterion not giving correct answer when done manually?
7 votes

Your approach didn't work because the last condition cannot be solved easily, that is, you need at least one parameter of degree one to solve without complexity. Then, Chris's routine does work ...

View answer
Sort nested list by a fixed order
6 votes

Something like the following: Map[Sort[#] &, list] (*{{{a, 1}, {b, 3}, {c, 5}}, {{a, 5}, {b, 1}, {c, 3}}, {{a, 5}, {b, 3}, {c, 1}}, {{a, 1}, {b, 5}, {c, 3}}}*) A first approximation: MyOrderList[...

View answer
How many equilibrium points exist?
5 votes

Try this: cont1 = ContourPlot[(Ωx /. {μ -> 1/2, c -> 1, p -> 1/100}) == 0, {x, -2, 2}, {y, -2, 2}, PlotRange -> Automatic, ContourStyle -> {Thickness[0.002], Darker[Red]}, LabelStyle -&...

View answer
How to get Limit cycle oscillation from the following differential equation?
4 votes

With $r=3.25$, $b=2.36$, $k=0.14$, $ϵ=1000$, and $a=0.01$ your "limit cycle" appears. r = 3.25; b = 2.36; k = 0.14; ϵ=1000; a = 0.01; sol[t_] = NDSolve[{x'[t] == -2 x[t] + r (k + 1) y[t] + ...

View answer
Is this a known issue in 12.3.1 with GridLinesStyle with Dashed option not working?
Accepted answer
4 votes

$Version (*12.3.1 for Microsoft Windows (64-bit) (June 19, 2021)*) The following change works for me: Graphics[Circle[], Axes -> True, GridLines -> Automatic, GridLinesStyle -> Directive[...

View answer
Evaluating the Poincaré section for Hénon-Heiles potential through Hénon Method
Accepted answer
4 votes

With the following code, you can plot the Poincaré sections of the Hénon-Heiles system: With[{icv = {0, 0.36169437164930385`, 0.20100851639176504`, 0.029106357137938632`}}, psection = Reap[NDSolve[{x'...

View answer
How to Generate a Phase Portrait for a Jacobian Evaluated at Fixed Points
Accepted answer
4 votes

The Discrete System: $$ \begin{align} x_{n+1}&=c \left(1-(x_n+y_n)\right)+x_n \left(1-p y_n\right)\\ y_{n+1}&=\left(p x_n+b\right)y_n \end{align} $$ The Discrete System code: F[{x_, y_}, {b_, ...

View answer
Telling Mathematica to treat square roots as real valued
4 votes

Try this: Refine[ToRadicals@FullSimplify[PowerExpand[1/Sqrt[Product[1 + (2 s)/k^3, {k, 1, \[Infinity]}]]], Assumptions -> Element[s, Reals]]]// TraditionalForm

View answer
Conjugation with real elements
4 votes

Using ComplexExpand command: A = 5 t^2 + 3 t + 4; ComplexExpand[Conjugate[A]] For expressions within radicals, we must use the Refine command for the ComplexExpand command to work properly. Here is ...

View answer
Is there any way to refactor this equation?
Accepted answer
3 votes

Try this: expr = (-4*dt^2*(c3 + a3*t)^2*t0^4 + dxC^2*(t0^2 + t1^2)^2 + dxM^2*(t0^2 + t1^2)^2 + dxY^2*(t0^2 + t1^2)^2)/(4*t0^4)//FullSimplify Collect[expr, {dxC, dxM, dxY}, FullSimplify] (*-dt^2 (c3 ...

View answer
Do loop so that I do not get double terms?
Accepted answer
3 votes

Based on the suggestion of Henrik Schumacher, and the answers of Hausdorff and Daniel Huber, you can do it as follows: Format[braket[{{a_, b_, c_}, {d_, e_, f_}}]] := Row[{"\[LeftAngleBracket]&...

View answer
Lotka-Volterra in mathematica
Accepted answer
3 votes

This is what Chris means: a = b = c = d = 1; x0 = 2; y0 = 3; q = 0.2; egyensulypont1 = Graphics[{Blue, Thick, PointSize[0.02], Point[{c/d, a/b}]}]; egyensulypont2 = Graphics[{Red, Thick, ...

View answer
Removing complex numbers from a set
3 votes

Try DeleteCases: list={-1628.12 - 557.34 I, -1628.12 + 557.34 I, -920.324 - 1508.13 I,-920.324 + 1508.13 I, 2107.28, 2145.53, 2207.2, 2289.7,2318.05 - 13.4031 I, 2318.05 + 13.4031 I} DeleteCases[list, ...

View answer
Error message shows up when I start working on a previously saved notebook on Mathematica
3 votes

First, select all the input cells on the right side, like this: Then, apply Ctrl+8 and save changes.

View answer
ContourPlot and MeshFunctions issue between versions 11.3 and 12.0
Accepted answer
3 votes

Try this: IIges[x_, y_] := Sin[x]^2 + Sin[y]^2; xm = 4; {dx[x_, y_], dy[x_, y_]} = D[IIges[x, y], {{x, y}}]; ContourPlot[{dx[x, y], dy[x, y]} == 0, {x, -xm, xm}, {y, -xm, xm}, ContourStyle -> ...

View answer
Harvested prey–predator model incorporating a prey refuge
3 votes

Some modifications for the code in Vitaliy Kaurov's answer: <<MaTeX` << c:\CurvesGraphics6\CurvesGraphics6.m Initial condition outside the limit cycle: α = 200/207; a = 4; k = 3; β = ...

View answer
Plotting a System of ODE's Phase Portrait
3 votes

The dynamics at the non-trivial equilibrium point: Needs["MaTeX`"] << c:\CurvesGraphics6\CurvesGraphics6.m Non-trivial equilibrium is unstable Non-trivial intersection of zero ...

View answer
Differential equation system, Jacobian matrix, characteristic equation
3 votes

The vector field defined by your system: f1 = σ (Y - X); f2 = 3 X (ρ - Z) - Y; f3 = X Y - β Z; F = {f1, f2, f3}; V = {X, Y, Z}; The equilibria: P1 = Solve[F == 0, V][[1]] P2 = Solve[F == 0, V][[2]] ...

View answer
Defining a function recursively
Accepted answer
2 votes

Try this: T[x_, y_, n_?IntegerQ] /; n >= 0 := If[n === 0, x, Expand[x^2*T[y^2*x, 2 y + 4, n - 1]]] Test: T[x, y, 0] (*x*) T[x, y, 1] (*x^3 y^2*) T[x, y, 2] (*16 x^5 y^6 + 16 x^5 y^7 + 4 x^5 y^8*) ...

View answer
Is there a Mathematica resource to work with Geometric Algebra?
2 votes

Check in the following link: GeometricAlgebra Package.

View answer
Creating a table from a for loop output
2 votes

Try this: P = {};(*empty list*) a = -Pi/2; b = 3 Pi/4; tolorance = 0.0000; f[x_] := Sin[x] && a <= x <= b; For[i = 1, i <= 11, i++, {c = (a + b)/2, If[f[a]*f[c] < tolorance, b = ...

View answer
How to find a median of odd and even numbers from a list of numbers
2 votes

Try Cases: list={94, 35, 47, 29, 86, 40, 46, 72, 87}; twolists=List[Cases[list, Except[_?EvenQ]], Cases[list, Except[_?OddQ]]] (*{{35, 47, 29, 87}, {94, 86, 40, 46, 72}}*) Map[Median, twolists] (*{41,...

View answer
Nesting multiple functions of multiple variables
2 votes

The correct way to draw some orbits for this map: With[{ε = 1.023, icv = Union[Table[{m, m}, {m, 0, 6, 0.1}], {{1.63, 0.41}, {5.23, 2.58}, {5.33, 2.64}, {5.43, 2.64}, {5.53, 2.64}, {5.63, 2.64}, ...

View answer
Mathematica can't simplify asymptotic expressions containing constant symbols
2 votes

Try this: Simplify[Refine[Asymptotic[Sech[a x], a x -> ∞], Assumptions -> Element[a,Reals]]]

View answer