I have the following ODE that I have solved with NDSolve:
y'[x] == -l*a*(y[x]^2 - c*y[x] - p*x^3*Exp[-2*x])/x^2
where $l = 1.508*10^{13}$, $a = 5*10^{-9}$, $c = 10^{-11}$, and $p = 1.038*10^{-5}$ are constants using the code
sol1 = NDSolve[{y'[x] == -l*a*(y[x]^2 - c*y[x] - p*x^3*Exp[-2*x])/x^2,
y[10] == 10^(-5)}, y, {x, 10, 100}, MaxStepSize -> 0.001].
But now that I've done this, I want to vary $a$. Specifically, I want to graph $y[100]$ as a function of $a$, where $a$ varies from $10^{-7}$ to $10^{-11}$.
I've tried looking at past threads but I haven't seen anyone do what I want to do.
I've tried making sol1 a function of $a$ but that doesn't work because then I've fed NDSolve a non-numerical value.
I've tried solving the ODE as a PDE (not an ideal solution...) by taking $a$ as a variable with the following code
sol2 =
NDSolve[{D[y[x, a], x] == -l*a*(y[x, a]^2 - c*y[x, a] - p*x^3*Exp[-2*x])/x^2,
y[10, a] == 10^(-5)}, y, {x, 10, 100}, {a, 10^-11, 10^-7}, MaxStepSize -> 0.001].
However, I run into an error anyway: "At x == 10.`, step size is effectively zero; singularity or stiff system suspected."
Does anyone know how to graph the end result of sol1, $y[100]$, as a function of $a$?
NDSolve
runs fast in your case, you can solve the equation multiple times for differene $a$, retrieve the value of $y(100)$ for each and plot aListPlot
. $\endgroup$Plot[x^2,{x,0,1}]
you in fact obtain a set of connected points, not a mathematically continuous graph. You can plot yours for e.g. 100 or 1000 values of $a$. $\endgroup$ParametricNDSolve
often is used for this purpose. $\endgroup$