3
$\begingroup$

I've already looked through the questions similar to this one, but I couldn't figure out how to modify them so that they work, and I suspect that there are deeper issues than just the syntax. Here is my code attempt:

fFunction[a_, b_, c_, z_] = 
 alpha[z] /. 
  First@DSolve[{c*
    alpha[z]*(alpha[z]^2 + alpha[z]) / ((alpha[z] + 1)^2 + b^2) - 
   1 == alpha'[z], alpha[0] == a}, alpha[z], z]

Basically there are four variables, where a,b,c are constants related to the physical apparatus which I'll put in later, and then alpha, which is the main variable I want to consider. Basically I want to solve the differential equation for alpha, which I suppose is actually a function of four variables. I understand how to do it for the one variable case, but this multivariable case, which I believe shouldn't be substantially harder, is eluding me.

Is the problem that Mathematica is trying to evaluate the inside first, but can't?

$\endgroup$
  • 2
    $\begingroup$ The difficulties you may be encountering are due primarily to the fact that DSolve is not returning an explicit solution for alpha[z]. This has nothing to do with the three constants. I would add that you should be careful when making fFunction an explicit function of z. $\endgroup$ – bbgodfrey Nov 26 '16 at 2:30
  • $\begingroup$ If I change it to NDSolve like this: fFunction[a_, b_] = alpha[z] /. First@NDSolve[{alpha[ z]*(alpha[z]^2 + alpha[z]) / ((alpha[z] + 1)^2 + b^2) - 1 == alpha'[z], alpha[0] == a}, alpha[z], {z, 0.1, 10}], it has a different error where it says that a is not a number $\endgroup$ – Jensen Lo Nov 26 '16 at 2:43
2
$\begingroup$

This seems like a good time to use ParametricNDSolveValue:

zmax = 2;
pfun = ParametricNDSolveValue[{c*alpha[z]*(alpha[z]^2 + alpha[z])/((alpha[z] + 1)^2 + b^2)-1 == alpha'[z],
alpha[0] == a}, alpha, {z, 0, zmax}, {a, b, c}]

Plot[pfun[1, 1, 1][ze], {ze, 0, zmax}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thank you so much, this was the perfect solution. I'll definitely keep this in my mathematica toolbox in the future. $\endgroup$ – Jensen Lo Nov 26 '16 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.