# Error with ParametricNDSolveValue

Consider the following code:

ClearAll["Global*"]
s0 = ParametricNDSolveValue[{A''[t] - \[Omega]^2 A[t] == 1, A[0] == 0,
A[1] == 0}, A, {t, 0, 1}, {\[Omega]}]
A1[\[Omega]_?NumericQ][t] := s0[\[Omega]][t];

s1 = ParametricNDSolveValue[{B''[t] - \[Omega]^2 B[t] ==
D[A1[\[Omega]][t], t], B[0] == 0, B[1] == 0},
B, {t, 0, 1}, {\[Omega]}]
B1[\[Omega]_?NumericQ][t] := s1[\[Omega]][t];

Plot[B1[1][t], {t, 0, 1}]


I get the error "Dependent variables {B,A1[\[Omega]]} cannot depend on parameters {\ \[Omega]}".

How do I get rid of this error? In the second equation A1 should be a known function, not a dependent one.

## 1 Answer

Try this:

s0 = ParametricNDSolveValue[{A''[t] - \[Omega]^2 A[t] == 1, A[0] == 0,
A[1] == 0}, A, {t, 0, 1}, {\[Omega]}];
s1 = ParametricNDSolveValue[{B''[t] - \[Omega]^2 B[t] ==
D[s0[\[Omega]][t], t], B[0] == 0, B[1] == 0},
B, {t, 0, 1}, {\[Omega]}];

Plot[s1[1][t], {t, 0, 1}]


Have fun!

• Thanks! It works.... but why? Why defining the function A gave the error? Jan 27, 2021 at 16:22
• You defined them a bit wrong. You might have defined as A1[\[Omega]_, t_] := s0[\[Omega]][t]; B1[\[Omega]_, t_] := s1[\[Omega]][t]; and call the plot as Plot[B1[1, t], {t, 0, 1}]`. This will give the same effect. But this is not necessaty, since s0 and s1 are defined as standard functions and you may use them for plotting in a standard way. Jan 27, 2021 at 16:32