Skip to main content
deleted 1 character in body
Source Link
infinitezero
  • 1.5k
  • 1
  • 8
  • 20

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;2*arg;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

However, if I enter the function directly, I get the expected result

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]
{1., 1.}

Why does the first try fail and the last try evaluate?

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

However, if I enter the function directly, I get the expected result

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]
{1., 1.}

Why does the first try fail and the last try evaluate?

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

However, if I enter the function directly, I get the expected result

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]
{1., 1.}

Why does the first try fail and the last try evaluate?

deleted 19 characters in body; edited title
Source Link
infinitezero
  • 1.5k
  • 1
  • 8
  • 20

NIntegrate argument is not numeric with __?NumericQcan't integrate function which returns list, but can integrate list directly

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

How to solve this? I can not remove the requirement that f[] is only evaluated for numeric lists.

In response to a comment: However, if I enter the function directly, I get the expected result

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]
{1., 1.}

This evaluates just fine.Why does the first try fail and the last try evaluate?

NIntegrate argument is not numeric with __?NumericQ function

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

How to solve this? I can not remove the requirement that f[] is only evaluated for numeric lists.

In response to a comment:

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]

This evaluates just fine.

NIntegrate can't integrate function which returns list, but can integrate list directly

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

However, if I enter the function directly, I get the expected result

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]
{1., 1.}

Why does the first try fail and the last try evaluate?

added 114 characters in body
Source Link
infinitezero
  • 1.5k
  • 1
  • 8
  • 20

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

HowHow to solve this? I can not remove the requirement that f[] is only evaluated for numeric lists.

In response to solve this? I can not remove the requirement that f[] is only evaluated for numeric listsa comment:

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]

This evaluates just fine.

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

How to solve this? I can not remove the requirement that f[] is only evaluated for numeric lists.

I have the following dummy Code

f[arg : {__?NumericQ}] := 2*arg;;
g := f[{x, y}]
NIntegrate[g, {x, 0, 1}, {y, 0, 1}]
NIntegrate[f[{x, y}], {x, 0, 1}, {y, 0, 1}]

Both tries yield

NIntegrate::inum: Integrand f[{x,y}] is not numerical at {x,y} = {0.5,0.5}.

Despite

f[{x, y}] /. x -> 0.5 /. y -> 0.5
{1.,1.}
f[{0.5, 0.5}]
{1.,1.}

How to solve this? I can not remove the requirement that f[] is only evaluated for numeric lists.

In response to a comment:

NIntegrate[2*{x, y}, {x, 0, 1}, {y, 0, 1}]

This evaluates just fine.

Source Link
infinitezero
  • 1.5k
  • 1
  • 8
  • 20
Loading