I'm trying to solve a second order differential equation using the code given by @xzczd here which is based on this.
What this code makes is transform differential equations in algebraic ones by means of the Finite Difference method.
When I solve the equation
R*X''[R] - X'[R] + R^3 == 0;
I have no problems at all. However when I change the equation to
R*X''[R] - X'[R] + R^3*nColdr[R] == 0;
being that
nColdr[R_?NumberQ]=NIntegrate[g[x],{x,0,R}],
where g is a complicated function of x, I get the output:
FindRoot::nlnum: The function value {0. +2.09232*10^17 (-1.37456*10^-14+2.7573*10^-14 nColdr$6323491[{0.,0.20202,0.40404,0.606061,0.808081,1.0101,1.21212,1.41414,1.61616,1.81818,2.0202,2.22222,2.42424,<<26>>,7.87879,8.08081,8.28283,8.48485,8.68687,8.88889,9.09091,9.29293,9.49495,9.69697,9.89899,<<50>>}]),<<49>>,<<150>>} is not a list of numbers with dimensions {200} at {X$6323491[0],X$6323491[20/99],X$6323491[40/99],X$6323491[20/33],X$6323491[80/99],X$6323491[100/99],X$6323491[40/33],X$6323491[140/99],X$6323491[160/99],X$6323491[20/11],X$6323491[200/99],X$6323491[20/9],X$6323491[80/33],X$6323491[260/99],X$6323491[280/99],X$6323491[100/33],X$6323491[320/99],<<17>>,X$6323491[680/99],X$6323491[700/99],X$6323491[80/11],X$6323491[740/99],X$6323491[760/99],X$6323491[260/33],X$6323491[800/99],X$6323491[820/99],X$6323491[280/33],X$6323491[860/99],X$6323491[80/9],X$6323491[100/11],X$6323491[920/99],X$6323491[940/99],X$6323491[320/33],X$6323491[980/99],<<150>>} = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,<<150>>}. >>
I'm pretty sure that the problem is because of the NIntegrate... I already try to do Hold and then ReleaseHold in different parts of the @xzczd code but it's not working...

tutorial/NDSolvePDEof the document. A rule of thumb is,4or2will work for most cases, and "Try it out" is the only way to figure out the best suited difference order in practice. – xzczd Jun 06 '18 at 16:43NDSolve`FiniteDifferenceDerivative. – xzczd Jun 07 '18 at 10:09NDSolve`FiniteDifferenceDerivativeuses one-sided difference formula at and near the boundary, and central difference formula in the middle, or it won't be able to generate enough equations for the whole domain. You can usepdetoaeto discretize a singleX'[R]and observe the output. If you're not familiar with one-sided formula, start from page 6 of this book. – xzczd Jun 08 '18 at 06:10The function value etc etc is not a list of numbers with dimensions...Isn't it possible to use pdetoae with Neuman-type BCs?
– AJHC Jul 01 '18 at 14:40The function value (...) is not a list of numbers with dimensions {25} at (...)– AJHC Jul 01 '18 at 15:01pdetoaeon them and I did not. Now you just need to usepdetoaeon your b.c., try it out. – xzczd Jul 01 '18 at 15:04X'[0]==X[0]doesn't need to be that troublesome, tryptoafunc[X'[0]==X[0]]. – xzczd Jul 10 '18 at 12:39X[0]==…thenae = Delete[ptoafunc[eq], {{1}, {2}}];, if it's e.g.X[1]==…thenae = Delete[ptoafunc[eq], {{1}, {-1}}];. Your next question is probably "why I should remove difference equation in this way?" Well, to be honest, I don't know, this is somewhat a empirical rule to me. – xzczd Jul 10 '18 at 13:10