dynamic – How to plot the stable and unstable manifolds of a hyperbolic fixed point of a nonlinear system of a map?

I would like to plot the stable and unstable manifold of the Hénon map x_{n+1} = 1 – a*x_n^2 + by_n, y_{n+1} = x_n. I believe that iterate the inverse map i would get the stable curve, and for the unstable i need to choose an large number of initial conditions inside the neighborhood of the saddle point along the unstable direction and then iterate the map for a few times, but i do not know how to do this things.

plotting – How to plot a sphere from the standard equation?

The equation for a sphere is x^2 + y^2 + z^2 == r^2

With({r = 7.5},
 ContourPlot3D(r^2 == (x^2 + y^2 + z^2),
  {x, -10, 10}, {y, -10, 10}, {z, -10, 10},
  AxesOrigin -> {0, 0, 0},
  PlotRange -> {-10, 10},
  BoxRatios -> {1, 1, 1},
  AxesLabel -> {"X", "Y", "Z"},
  ViewPoint -> Front))

enter image description here

To use Plot3D you must solve for both solutions for z

With({r = 7.5},
 Plot3D({
   Sqrt(r^2 - x^2 - y^2),
   -Sqrt(r^2 - x^2 - y^2)},
  {x, -r, r}, {y, -r, r},
  AxesOrigin -> {0, 0, 0},
  PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}},
  BoxRatios -> {1, 1, 1},
  AxesLabel -> {"X", "Y", "Z"},
  ViewPoint -> Front))

enter image description here

calculus and analysis – Plot of Integrate[expr] not matching NIntegrate[expr] (Imaginary Part is flipped?)

I am interested in getting an analytic form for the integral of an expression. When I integrate my expression, I get a very clean result, but with a very complicated “Condition” attached to it, which looks like this (code provided at end):

enter image description here

I am interpreting that this integral “blows up” for some very complicated situation, but otherwise has a single solution. Now if I grab that solution and plot the real and imaginary parts as a function of the variable $Delta_p$, I observe that the analytical solution disagrees with its numerical counterpart.

The plots of the Real part (of the analytic integral vs the numerical integral) seems to be pretty close:
enter image description here

But the plots of the imaginary part (of the analytic integral vs the numerical integral) disagree by a negative sign:

enter image description here

The imaginary part is somehow flipped! Any ideas what is going on? Why is this issue happening?

Here is my code for obtaining these results:

expr = 1/W Sqrt(Log(2)/(Pi)) 1/(
   1 + ((CapitalDelta)/
     W)^2) (I (-4 ((CapitalDelta) + (CapitalDelta)c1)^2 + 
        4 ((CapitalDelta) + (CapitalDelta)c1) ((CapitalDelta) + 
(CapitalDelta)c2) + 
        2 (Gamma) ((CapitalGamma) + 
           2 I (-(CapitalDelta) + (CapitalDelta)c1 - 
(CapitalDelta)c2 - (CapitalDelta)p)) + 
        2 I (CapitalGamma) ((CapitalDelta)c1 - (CapitalDelta)p) + 
        8 ((CapitalDelta) + (CapitalDelta)c1) ((CapitalDelta) + 
(CapitalDelta)p) - 
        4 ((CapitalDelta) + (CapitalDelta)c2) ((CapitalDelta) + 
(CapitalDelta)p) - 
        4 ((CapitalDelta) + (CapitalDelta)p)^2 + 
(CapitalOmega)c2^2))/(2 (Gamma) ((CapitalGamma) + 
         2 I (-(CapitalDelta) + (CapitalDelta)c1 - 
(CapitalDelta)c2 - (CapitalDelta)p)) ((CapitalGamma) - 
         2 I ((CapitalDelta) + (CapitalDelta)p)) + 
      I (2 (CapitalGamma)^2 ((CapitalDelta)c1 - (CapitalDelta)p) + 
         8 ((CapitalDelta) + (CapitalDelta)c1)^2 ((CapitalDelta) + 
(CapitalDelta)p) + 
         8 ((CapitalDelta) + (CapitalDelta)c2) ((CapitalDelta) + 
(CapitalDelta)p)^2 + 8 ((CapitalDelta) + (CapitalDelta)p)^3 - 
         2 ((CapitalDelta) + (CapitalDelta)c2) (CapitalOmega)c1^2 
- 2 ((CapitalDelta) + (CapitalDelta)p) (CapitalOmega)c1^2 + 
         2 ((CapitalDelta) + (CapitalDelta)c1) (-4 ((CapitalDelta) 
+ (CapitalDelta)c2) ((CapitalDelta) + (CapitalDelta)p) - 
            8 ((CapitalDelta) + (CapitalDelta)p)^2 + 
(CapitalOmega)c1^2) - 
         2 ((CapitalDelta) + (CapitalDelta)p) (CapitalOmega)c2^2 + 
         I (CapitalGamma) (4 ((CapitalDelta) + (CapitalDelta)c1)^2 
+ 4 ((CapitalDelta) + (CapitalDelta)c2) ((CapitalDelta) + 
(CapitalDelta)p) + 8 ((CapitalDelta) + (CapitalDelta)p)^2 - 
            4 ((CapitalDelta) + (CapitalDelta)c1) ((CapitalDelta) 
+ (CapitalDelta)c2 + 
               3 ((CapitalDelta) + (CapitalDelta)p)) - 
(CapitalOmega)c1^2 - (CapitalOmega)c2^2)));

parameterRules =  {(CapitalOmega)c1 -> 
    4, (CapitalOmega)c2 -> .1, (CapitalGamma) -> 
    1,  (CapitalDelta)c1 -> 0, (CapitalDelta)s -> 
    0, (CapitalDelta)c2 -> 0, z -> 1, (Gamma) -> 0, (Phi) -> 0, 
   W -> 10};

(*Analytic Integration:*)
DL4lvldopplerPtoP(CapitalDelta) = 
  Integrate( expr, {(CapitalDelta), -(Infinity), (Infinity)}) // 
    Normal // Simplify;
analyticalSol = DL4lvldopplerPtoP(CapitalDelta) /. parameterRules;


(*Numeric Integration:*)
numericallyIntegraled = expr /. parameterRules // Simplify;
f((CapitalDelta)p_?NumericQ) := 
  NIntegrate(
   numericallyIntegraled, {(CapitalDelta), -(Infinity), 
(Infinity)});


(*Plotting real and imag parts of (Analytic and Numeric):*)
Plot({Re(ComplexExpand(f((CapitalDelta)p))), 
  Re(ComplexExpand(analyticalSol))}, {(CapitalDelta)p, -10, 10}, 
 Frame -> True, 
 FrameLabel -> {{None, None}, {"(CapitalDelta)p", 
    "Im(expr): Numeric Vs Analytic"}}, GridLines -> Automatic, 
 GridLinesStyle -> LightGray, BaseStyle -> 12)
Plot({Im(ComplexExpand(f((CapitalDelta)p))), 
  Im(ComplexExpand(analyticalSol))}, {(CapitalDelta)p, -10, 10}, 
 Frame -> True, 
 FrameLabel -> {{None, None}, {"(CapitalDelta)p", 
    "Re(expr): Numeric Vs Analytic"}}, GridLines -> Automatic, 
 GridLinesStyle -> LightGray, BaseStyle -> 12, PlotRange -> All)

One thing to note is that I tweaked the conditional expression to just be a normal expression. If I don’t do this, I cannot obtain a plot anymore, and if I try to look at my analytic expression, I get the form:

Cell(CellGroupData({Cell(BoxData(
 RowBox({"Simplify", "(", 
  RowBox({
   RowBox({"Re", "(", 
    RowBox({"ComplexExpand", "(", "analyticalSol", ")"}), ")"}), ",", 
   " ", 
   RowBox({"Element", "(", 
    RowBox({"(CapitalDelta)p", ",", " ", "Reals"}), ")"})}), 
  ")"})), "Input",
 CellChangeTimes->{{3.799702119453383*^9, 3.799702156106647*^9}, {
  3.7997022143955765`*^9, 3.7997022256841283`*^9}},
 CellLabel->"In(97):="),

Cell(BoxData("Undefined"), "Output",
 CellChangeTimes->{
  3.7997020940830355`*^9, 3.799702157040344*^9, {
   3.7997022211933966`*^9, 3.799702226293498*^9}},
 CellLabel->"Out(97)=")
}, Open  ))

Any help would be greatly appreciated!

plotting – Solve a system of three stiff ODEs and plot graphs of it – Oregonator

I want to plot a system of three stiff ODEs (Oregonator model). That model describes a chemical oscillator. I do not have much experience with plotting ODEs, but I have obtained a Mathematica file that does almost the same as I want, but only with a simplified version of the Oregonator. That simplified version has two ODEs, while my system has three ODEs.

I have the following code:

ε=4*10^-2;
δ=4*10^-4;
q=8*10^-4;
f=1;

{xsol,zsol}=NDSolve({εx'(t)==x(t)(1-x(t))+(f(q-x(t))z(t))/(q+x(t)),z'(t)==x(t)-z(t),x(0)==.00012,z(0)==.00576},{x,z},{t,0,40},MaxSteps->Infinity)

This system describes the following model:

enter code here

How do I modify the above code, so that it solves the below system?
enter image description here

I plot the solutions like this:

Plot(Evaluate(x(t)/.xsol),{t,0,40},PlotRange->All,PlotStyle->{Thick,Blue})

I already tried adding ysol and y(t) and y(0), but that didn’t work for me. Probably I did something wrong, but I’m really stuck. The initial value is y(0)=0.375.

How should I modify the code with the NDSolve? Thanks a lot!

plotting – How to plot parametric phase diagram with bar legend?

I am trying to plot the parametric phase diagram with bar legend in the form of a rainbow. I have asked one similar question before in which I have shown the region plot. But equations are different there. Here I have simplified the equations.
I have written this code for getting the plot but not showing any color phase diagram as I want. If anyone can resolve this it will be appreciated.

k1 = 0.1;
kexc = .2;
ome = .4;
kL = (k1 + kexc)/2 - del0*(k1 - kexc)/(2*ome);
g0 = 0.3;
ome1 = 5.5;
a1 = 0.1;
A1 = 1;
B1 = 0;
gma = 0.0001;
delta = -1.5;
Y1 = (k1 - kexc)*g0^2*B1*ome1*(1 - del0/ome)*A1;
M1 = (gma^2/4 + ome1^2);
X1 = kL/2 + (k1 - kexc)/(ome^2*Sqrt(2)*M1)*g0^2*B1^2*ome1*P0*a1;
Z1 = delta + g0^2*(1 - del0/ome)*A1/Sqrt(2)*ome1/ome*P0*B1*a1/M1;
K1 = g0^2/2 (1 - del0/ome)^2*A1^2*ome1/M1;
S1 = g0^2/(2*Sqrt(2)*ome)*B1*ome1*(1 - del0/ome)*A1/M1;
O1 = (1 - del0/(2*ome))/Sqrt(2) + P0*g0^2*B1^2*ome1*a1/(2*ome^2*M1);
F11 = NSolve(
  r1^3*(Y1^2 + K1^2) + r1^2*(2*X1*Y1 + 2*Z1*K1) + 
    r1*(X1^2 + Z1^2 + P0^2*S1 + 2*P0^2*O1*S1) + P0^2*O1 == 0, r1)
CounterPlot({r1}, {P0, 0, 2.5}, {del0, 0, 3}, 
 BarLegend("Rainbow", {0, 6}))

plotting – How to plot multicolor phase daigram with three parameters?

enter image description here

I am trying to plot like the diagram given above. I have two nonlinear equations that I have separated in imaginary and complex forms (u1,v1, and x1,y1). As shown in the figure in the x-axis I want ‘p0’ which varies from (0,2.5*10^3) and in the y-axis, I want ‘del0’ which varies from (0,3) and inside the plot where rectangular color region box it is ‘NL=u1^2+v1^2’which varies from (0,6*10^7). I am trying this but unable to plot this type of diagram and gives me an error: “solve was unable to solve the system with inexact coefficients. The
the answer was obtained by solving a corresponding exact system and
numericizing the result. >>” Should I give another command to get this type of plot or anything else? If anyone can short it out will be appreciated.

A1 = 1;
B1 = 0;
delta = -1.5;(*Subscript((CapitalDelta), L) ; Laser-Lower polariton 
detuning*)
g0 = .315; (* Subscript(g, 0) ; vacuum optomechanical strength *)
ome = 3.014; (* (CapitalOmega) ; Rabi splitting *)
ome1 = .125; (* Subscript((CapitalOmega), m) ; mechanical 
resonator's frequency *)
kexc = 0.002;  (* Subscript((Kappa), exc  ;  )exciton decay rate*)
kk = .2;   (* (Kappa); cavity decay rate *)
gma = 0.00001;  (* (CapitalGamma) ; phonon dcay rate *)
ka = (kk + kexc)/2 - del0*(kk - kexc)/(2*ome);
Sol = NSolve({-delta*v1 - ka*u1/2 - (kk - kexc)*B1*g0*x1*u1/ome == 0, 
    delta*u1 + g0*(1 - del0/ome)*A1*x1*u1 + 
      p0*(1 - del0/(2*ome))/Sqrt(2) + p0*g0*B1*x1/(Sqrt(2)*ome) - 
      ka*v1/2 - (kk - kexc)*g0*x1*B1*v1/ome == 0, 
    ome1*y1 - gma*x1/2 == 
     0, -ome1*x1 + g0/2*(1 - del0/ome)*A1*(u1^2 + v1^2) + 
      p0*g0*u1*B1/(Sqrt(2)*ome) - gma*y1/2 == 0}, {u1, v1, x1, y1}, 
   del0);
ParametricRegionPlot(
 Evaluate@((u1^2 + v1^2)*10^7 /. Sol), {p0, 0, 2.5*10^3}, {del0, 0, 3}, 
 Frame -> True, 
 FrameLabel -> {Style("!(*SubscriptBox((P), (0)))", Bold, 20),
    Style("!(*SubscriptBox((N), (L)))", Bold, 20)})

plotting – How to plot a graph with respect to x axis which is in units of product of variable and parameter?

I would like to know, how to plot a graph, for example of this function:

$f(t)=-frac{4 sin left(frac{gamma t}{2}right)}{gamma ^2 t}-frac{4 sin ^2left(frac{gamma t}{4}right)}{gamma }-frac{2 cos left(frac{gamma t}{2}right)}{gamma }+frac{pi t}{2}$ where $t$ is a variable and $gamma$ is some constant parameter. Is there a possibility to plot it with x axis being in units of notjust $t$, but in units of $gamma t$?

I was thinking it could be done something like this, but it does not work:

Plot(f(t), {(Gamma)*t, 0, 40})

plotting – Trying to recreate a plot which tracks the age of individuals inside a compartment model

I am using a compartment model from the following paper: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0018491

I am trying to recreate Figure 6. I will be honest, I have no clue how to approach this. The paper doesn’t give information on how to achieve the figure, but I would love to understand and know how it is made.

The following parameters and System are being used in mathematica:

L = 2000; (* Maximum queen daily laying rate*)
w = 27000; (* Rate at which eclosion approaches L as N gets large*)
alpha = 0.25; (*maximum rate that hive bees will become foragers when there are no foragers in the colony*)
sigma = 3/4; (*social inhibition factor*)
m = 0.24; (*die-off rate forager bees*)

T = 10000;
sol = NDSolve({
    H'(t) == L*(H(t) + F(t))/(w + H(t) + F(t)) -H(t)*(alpha - sigma*(F(t)/(H(t) + F(t)))),
    F'(t) == H(t)*(alpha - sigma*(F(t)/(H(t) + F(t)))) - m*F(t),
    {H(0), F(0)} == {300, 250}}, {H, F}, {t, 0, T}, MaxSteps -> Infinity);

Steady state

N(#) & /@ Solve({
    0 == L*(H + F)/(w + H + F) - H*(alpha - sigma*(F/(H + F))),
    0 == H*(alpha - sigma*(F/(H + F))) - m*F}, {H, F}) // Simplify