MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NIntegrate with a J/Link Function


pjcrosbie at gmail.com wrote:
> I cannot get NIntegrate to work on a Java function I have attached to
> Mathematica with J/Link.  The Java function works fine on its own and
> inside Plot but NIntegrate appears to be passing it a symbolic value.
> 
> Code snippets:
> 
> :=Plot[tPort@condtPD[1, dr] , {dr, -6, 6}]  (* works fine, plots
> function correctly *)
> 
> := NIntegrate[condtPD[dr] ,{dr,-6,6}]
> 
> Fails with message:
> "Method named condtPD defined cr.research.conditional.CDnDPortfolio1
> was called with an incorrect number or type of arguments. The
> arguments, shown here in a list, were {1, dr}."
> 
> Can anyone point me in the right direction?
> 
> Many thanks
> 
Hello,

First, I assume you meant NIntegrate[tPort@condtPD[dr] ,{dr,-6,6}]

The problem is that NIntegrate does a preliminary symbolic evaluation of 
  the integrand, which fools Java. The answer is to write an interface 
function that screens out symbolic values:

f[x_Real]:=tPort@condtPD[x];

NIntegrate[f[dr] ,{dr,-6,6}]

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Illusory Multicore Support in 5.2?
  • Next by Date: Re: unable to FullSimplify
  • Previous by thread: NIntegrate with a J/Link Function
  • Next by thread: error function