Message Boards Message Boards

NDSolve error: The function doesn't have the same number of arguments

Posted 1 year ago

I have two functions (f[z] and gg[r]), each of one independent variable (z and r), and two ODEs (see file enclosed)

in both these functions and their derivatives. I could specify more boundary conditions if I had to (currently that's not the issue), but Mathematica complains that these two functions are not functions of BOTH r and z. Is this a valid complaint, and if not, how to get around it? I have an old version of Mathematica, version 8, so if the newest version can do this and the old cannot, I will get the newer version. I am trying to solve it numerically with NDSolve, but if there was an algebraic solution that would be a bonus.

POSTED BY: Iuval Clejan
4 Replies
Posted 1 year ago

The first bit of advice: Stop trying to "desktop publish" your equations.

Yes Mathematica does display

x^2

and

Superscript[x,2]

almost identically. But try

Solve[x^2==3,x]

and then try

Solve[Superscript[x,2]==3,x]

and see that Mathematica understands how to solve one of those and not the other.

There is also the issue of ' versus \[Prime].

When I un-desktop publish your input, if I haven't made any mistakes, I get

NDSolve[{r^4 Cos[z]^2 f[z]gg[r]-8 f[z]^2 gg[r]-2 r^4 f[z]gg[r]Sin[z]^2-
  r^4 Cos[z]gg[r]Sin[z]f'[z]+2 r f[z]^2 gg'[r]== 0,
  r^4 Cos[z]^2 f[z]gg[r]^2+4 f[z]^2 gg[r]^2-2 r^4 f[z]gg[r]^2 Sin[z]^2-
  r^4 Cos[z] gg[r]^2 Sin[z]f'[z]-r^2 f[z]^2 gg'[r]^2+2 r^2 f[z]^2 gg[r]gg''[r]== 0,
  f[0]==f[2 Pi], gg[10]==0.0001,gg'[10]== -0.0001}, {f,gg}, {r,0.01,10},{z,0.0,2 Pi}]

That is closer, but it is still not enough, there is still at least one more problem that I haven't identified.

It seems "unconventional" that f is independent of r and gg is independent of z and that you specify one boundary condition as being equal to another and do not include any derivative in that, but I have not convinced myself whether those are the real problem or not.

POSTED BY: Bill Nelson
Posted 1 year ago

Thanks for your attention. No, the problem is not the BCs. It's that f[z] is determined up to a few constants (let's say n of them) for each r, and these will be different as r varies, so unless r only takes n values, the system will be over-determined. And likewise for gg[r] for each z.... I could just make both of them functions of both variables, but the original problem yields different equations for that case.

POSTED BY: Iuval Clejan
Posted 1 year ago

Also, the format I had works in version 8. So version 8 is better in that respect than the newest version...

POSTED BY: Iuval Clejan
Posted 1 year ago

It looks like a valid complaint. So never mind...

POSTED BY: Iuval Clejan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract