Skip to main content
added 108 characters in body
Source Link
p.s
  • 129
  • 7

Example as following

g[x_]:=NIntegate[......];

f[x_]:=g[x]^2+g[x];

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x];
f[x_]=value^2+value;

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Update:Update:

After a bit of study myself, the new code I write is:

g[x_] := NIntegate[......];
f[x_] = #^2 + # &[g[x]]

The function definition gives correct answer. Does it calculate g[x] once or twice in this way?

Example as following

g[x_]:=NIntegate[......];

f[x_]:=g[x]^2+g[x];

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x];
f[x_]=value^2+value;

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Update:

After a bit of study myself, the new code I write is:

g[x_] := NIntegate[......];
f[x_] = #^2 + # &[g[x]]

The function definition gives correct answer. Does it calculate g[x] once or twice in this way?

Example as following

g[x_]:=NIntegate[......];

f[x_]:=g[x]^2+g[x];

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x];
f[x_]=value^2+value;

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Update:

After a bit of study myself, the new code I write is:

g[x_] := NIntegate[......];
f[x_] = #^2 + # &[g[x]]

The function definition gives correct answer. Does it calculate g[x] once or twice in this way?

added 108 characters in body
Source Link
p.s
  • 129
  • 7

Example as following

g[x_]:=NIntegate[......];

f[x_]:=g[x]^2+g[x];

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x];
f[x_]=value^2+value;

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Update:

After a bit of study myself, the new code I write is:

g[x_] := NIntegate[......];
f[x_] = #^2 + # &[g[x]]

The function definition gives correct answer. Does it calculate g[x] once or twice in this way?

Example as following

g[x_]:=NIntegate[......];

f[x_]:=g[x]^2+g[x];

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x];
f[x_]=value^2+value;

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Example as following

g[x_]:=NIntegate[......];

f[x_]:=g[x]^2+g[x];

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x];
f[x_]=value^2+value;

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Update:

After a bit of study myself, the new code I write is:

g[x_] := NIntegate[......];
f[x_] = #^2 + # &[g[x]]

The function definition gives correct answer. Does it calculate g[x] once or twice in this way?

added 2 characters in body
Source Link
p.s
  • 129
  • 7

Example as following g[x_]:=NIntegate[......]

g[x_]:=NIntegate[......];

f[x_]:=g[x]^2+g[x]=g[x]^2+g[x];

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x]value=g[x];
f[x_]=value^2+valuef[x_]=value^2+value;

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Example as following g[x_]:=NIntegate[......]

f[x_]:=g[x]^2+g[x]

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x]
f[x_]=value^2+value

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Example as following

g[x_]:=NIntegate[......];

f[x_]:=g[x]^2+g[x];

I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].

value=g[x];
f[x_]=value^2+value;

The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?

Source Link
p.s
  • 129
  • 7
Loading