Re: NIntegrate with a J/Link Function
- To: mathgroup at smc.vnet.net
- Subject: [mg66005] Re: NIntegrate with a J/Link Function
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Wed, 26 Apr 2006 04:38:20 -0400 (EDT)
- References: <e2kqvb$7mp$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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