0
$\begingroup$

I am trying to implement the inverse Laplace operator through

P[g_] := h /.NDSolve[{h''[x] == g[x], h[0] == 0, h[1] == 0}, h, {x, 0, 1}][[1]]

If I now define some $f$ and apply $P$,

f[x_] = 0.5 - Abs[x - 0.5]; 
P[f]

I do get an InterpolatingFunction, that takes the correct values, i.e. P[f][0.5] is defined and is what I expect. However, if I try to add a normalization of the solution,

P[g_] := h/h[0.5] /.NDSolve[{h''[x] == g[x], h[0] == 0, h[1] == 0}, h, {x, 0, 1}][[1]]

then I get -24.*InterpolatingFunction{...}, which cannot be evaluated, i.e. P[f][0.5] gives (-24.*InterpolatingFunction{...})[0.5]

$\endgroup$
2
$\begingroup$

Like this,

P[g_] := h[#]/h[0.5] & /. 
  NDSolve[{h''[x] == g[x], h[0] == 0, h[1] == 0}, h, {x, 0, 1}][[1]]

or like this

P[g_] := With[{h = 
    NDSolveValue[{h''[x] == g[x], h[0] == 0, h[1] == 0}, 
     h, {x, 0, 1}]}, h[#]/h[.5] &]

Both evaluate as expected,

P[f][.5]
(* 1. *)
$\endgroup$
  • $\begingroup$ Works, but when I try to evaluate a derivative with $ND[P[f][s],s,0.7]$ I get a non-numerical output containing ND itself and a few interpolatingFunctions $\endgroup$ – Bananach May 11 '16 at 12:59
  • 1
    $\begingroup$ I can't reproduce that, for me ND[P[f][s], s, 0.7] gives an error but then gives the right answer. You can get the same answer without the NumericalCalculus package by evaluating D[P[f][s], s] /. s -> .3. Maybe you need to clear the definition of s? $\endgroup$ – Jason B. May 11 '16 at 13:11
  • $\begingroup$ clearing s worked $\endgroup$ – Bananach May 11 '16 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.