Re: multiintegral and table

• To: mathgroup at smc.vnet.net
• Subject: [mg131643] Re: multiintegral and table
• From: Bill Rowe <readnews at sbcglobal.net>
• Date: Sun, 15 Sep 2013 07:07:27 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net

```On 9/14/13 at 6:03 AM, phutauruk at gmail.com (Parada Hutauruk) wrote:

>Dear all,

>I have a function

>f_1 [x_,y_] = Integrate[2*y + x^2, {x,0,1},{y,0,x}]

Don't do this. f_1 is interpreted by Mathematica as something
named f with Head 1 and is definitely not a subscribed variable.
You cannot use an underscore in names with Mathematica.

Also, did you notice the color of the f when you typed f_2? It
wasn't blue (the default color of a undefined global name was
it? That should be a big hint you are doing something wrong.

getting rid of the underscores:

f1[x_, y_] = Integrate[2*y + x^2, {x, 0, 1}, {y, 0, x}];
f2[x_, y_, Q_] = Integrate[2*y + x^2*Q, {x, 0, 1}, {y, 0, x}];
fTotal[x_, y_, Q_] = f1[x, y] + f2[x, y, Q];
dataxx = Table[{Q, fTotal[x, y, Q]}, {Q, 0, 10, 0.0025}];
ListPlot[dataxx]

will generate the expected plot.

But since both f1 and f2 evaluate to simple expressions and
assuming x, y have not been assigned values, then the following
code generates the same plot more efficiently

f1 = Integrate[2*y + x^2, {x, 0, 1}, {y, 0, x}];
f2 = Integrate[2*y + x^2*Q, {x, 0, 1}, {y, 0, x}];
Plot[f1+f2, {Q, 0, 10}]

One other thing. Mathematica has several built-in things that
are named with a single uppercase letter. So, it is wise to get
in the habit of not using single uppercase letters as variables.
That avoids conflict with built-in functions and likely will
save you a lot of grief debugging your code.

```

• Prev by Date: Re: ReplacePart
• Next by Date: Re: ReplacePart
• Previous by thread: Re: multiintegral and table
• Next by thread: Re: multiintegral and table