# ParametricNDSolve error: Dependent variables cannot depend on parameters

**URL:** <https://community.wolfram.com/t/parametricndsolve-error-dependent-variables-cannot-depend-on-parameters/23188>\
**Category:** Questions\
**Tags:** calculus, equation-solving, numerical-computation\
**Created:** [December 4, 2023, 1:12am UTC](https://community.wolfram.com/t/parametricndsolve-error-dependent-variables-cannot-depend-on-parameters/23188 "2023-12-04T01:12:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![malvam](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@malvam](https://community.wolfram.com/u/malvam)\
**Post date:** [December 4, 2023, 1:12am UTC](https://community.wolfram.com/t/parametricndsolve-error-dependent-variables-cannot-depend-on-parameters/23188/1 "2023-12-04T01:12:43Z")

</div>

I’m trying to solve numerically this system of non linear DEs and there’s some trouble with the numerical solution of the last differential equation, because while running the last line of the code that uses

```
`ParametricNDSolveValue` appears the followin message ParametricNDSolveValue::pdvar: Dependent variables {G,F[t,a,b]} cannot depend on parameters {a,b}.

```

I’m not quite sure about the evaluation in the F function but I tried. Here’s the code:

```
t0 = 7;
u0 = 1.0;
v0 = -0.5;
z0 = Sin[t0];
sol = ParametricNDSolveValue[{
    u'[x] == -Log[10] (-u[x] + a v[x]),
    v'[x] == -Log[10] (u[x] - (a w[x])^2),
    w'[x] == -Log[10] (w[x] (1 + a) - Cos[x]),
    z'[x] == -Log[10] (4 a Sin[x]),
    u[7] == u0, v[7] == v0, w[7] == w0, z[7] == z0}, {u, v, w, z}, {x,
     7, -2}, {a}, MaxSteps -> Infinity];
dynsys[x_?NumericQ, a_?NumericQ] := sol[a][x];
x[t_] := Log[1 + t]/Log[10];
F[t_?NumericQ, a_, ?NumericQ, b_?NumericQ] := 
  Sqrt[(b (1 + t)^3)/(
   1 - u[x[t]]^2 - v[x[t]]^2 - w[x[t]]^2 - z[x[t]]^2)] /. 
   dynsys[x[t], a][[1]];
Gsol = ParametricNDSolveValue[{G'[t]/(1 + t) - G[t]/(1 + t)^2 - 1/
      F[t, a, b] == 0, G[0] == 0}, {G}, {t, 0, 3}, {a, b}, 
   MaxSteps -> Infinity];

```

---

<div class="post-metadata">

**Author:** ![sangdonlee](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sangdonlee/32/41841_2.png) [@sangdonlee](https://community.wolfram.com/u/sangdonlee)\
**Post date:** [December 4, 2023, 1:09pm UTC](https://community.wolfram.com/t/parametricndsolve-error-dependent-variables-cannot-depend-on-parameters/23188/2 "2023-12-04T13:09:24Z")

</div>

1. w0 is not defined.

2. The “x” in u[x],v[x],w[x] and z[x] is an independent parameter (e.g., “x” is similar to “t” in ODE) but you again used the “x” as a state or dependent variable (i.e., x[t]:= Log[1 + t]/Log[10]). Thus x in u[x] and x in x[t\_] are mixed up. x[t\_] := Log[1 + t]/Log[10];

3. The following ODE is working:

---

<div class="post-metadata">

**Author:** ![malvam](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@malvam](https://community.wolfram.com/u/malvam)\
**Post date:** [December 5, 2023, 12:40am UTC](https://community.wolfram.com/t/parametricndsolve-error-dependent-variables-cannot-depend-on-parameters/23188/3 "2023-12-05T00:40:13Z")

</div>

Thanks for the feedback!  
The x[t] := Log[1 + t]/Log[10] is more of a rescaling for the F function in order to be used in the second DE.  
Could that be done in another way?

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [December 5, 2023, 2:56pm UTC](https://community.wolfram.com/t/parametricndsolve-error-dependent-variables-cannot-depend-on-parameters/23188/4 "2023-12-05T14:56:11Z")

</div>

This works:

```
t0 = 7;
u0 = 1;
v0 = -1/2; w0 = 1;
z0 = Sin[t0];
sol = ParametricNDSolve[{u'[x] == -Log[10] (-u[x] + a v[x]), 
    v'[x] == -Log[10] (u[x] - (a w[x])^2),
    w'[x] == -Log[10] (w[x] (1 + a) - Cos[x]),
    z'[x] == -Log[10] (4 a Sin[x]),
    u[7] == u0, v[7] == v0, w[7] == w0, z[7] == z0},
   {u, v, w, z}, {x, 7, -2}, {a},
   MaxSteps -> Infinity];
x[t_] := Log[1 + t]/Log[10];
F[t_, a_, b_] := Sqrt[(b (1 + t)^3)/(1 - u[a][x[t]]^2 -
       v[a][x[t]]^2 -
       w[a][x[t]]^2 - z[a][x[t]]^2)] /. sol;
Gsol = ParametricNDSolveValue[{G'[t]/(1 + t) -
     G[t]/(1 + t)^2 - 1/F[t, a, b] == 0, G[0] == 0},
  G, {t, 0, 3}, {a, b}, MaxSteps -> Infinity]

```
