Skip to main content

function construction - How to input a dynamically changing parameter in NDSolve?



I am trying to solve a system of DEs with additional conditions, and one condition depends on a parameter. Let us consider the following example:


eq = D[y,x]==2;

cond = y[1]==param;
NDSolve[{eq,cond},y[x],x]

How do I make a function that takes the input of a number param and outputs the NDSolve result with the corresponding parameter? I tried to make the condition itself a function, but this doesn't work:


eq = D[y,x]==2;
cond[param_] := y[1]==param
fun[param1_] := NDSolve[{eq,cond[param1]},y[x],x]

PS. There is a somewhat similar question, but there the parameter is of Boolean nature.




Comments