## 7766 Reputation

17 years, 335 days

## Thanks!...

@Christian Wolinski That's a very clever combination of map and map2, and does the job well.  Thanks!

## In spherical coordinates...

@mmcdara You wrote: "The case of spherical coordinates is more complex (read the reference I provided you in y previous reply)".

In the reference that you have provided, integration in spherical coordinates is made unnecessarily too complicated due to the attempt to integrate with respect to radial direction first and then with respect to the angle.  The solution is simpler if we integrate with respect to the angle first.

## @CaptNnFalcon Your English is fine,...

@CaptNnFalcon Your English is fine, and being new to Maple is not unusual.  The starting point, hower, is to draw the diagram that I suggested.  Do it by hand, not in Maple.  You can't get started without drawing that diagram.

## As this is a homework problem, you are e...

As this is a homework problem, you are expected to do the work rather than asking others to do it for you.  At least provide some indication of the effort that you have put in toward solving this problem.

Suggestion: If you haven't yet done so, it is essential to draw a good drawing of the intersection of the torus with the y=0 plane.  Mark on the diagram the coordinates of the intersection points with the axes.

## Optimized code...

@acer I see no point in attempting to optimize OP's "dummy code" (his words) as we don't know what his real application looks like.

But yes, if we want to optimize the dummy code, we call fun just once within the proc, as in F := fun(x,y), and then use F as many times as needed.

## Workarounds...

@Aleks Here are a couple of different workarounds, in addition to what Preben has suggested.

 > restart;
 > A := abs(x*Heaviside(x) + x*Heaviside(-x));

 > A1 := simplify(A);

 > int(A1, x=-1..1);

 > A2 := convert(A, Heaviside);

 > int(A2, x=-1..1);

## Suggestion...

Considering that your original question appeared more than a year ago, chances are slim that anyone will notice any updates to that question at this time, unless they happen to be looking under the "Recent Conversations" listing.  That I hardly ever do.

I don't see a harm in your asking the question anew.   It will be a good idea to include a link to your last year's question to remove any chance of confusion or accusations of spamming.  And this time don't wait for six months before you react to an answer.

## Thanks!...

@Carl Love Thanks for your suggestion.  It had not occurred to me to apply combine().

## Maple's natural view...

And here's what we get by just adding the point at [0,0]:

```display(
plot(10 + 1/(x-1)^2, x=0..2, thickness= 3),
pointplot([0,0], symbol=point)
);```

## Why complicate things?...

@Preben Alsholm That looks good but I don't see why that is preferable over the much simpler

```with(plots):
display(
plot(10 + 1/(x-1)^2, x=0..2),
pointplot([0,0], symbol=point)
);```

which doesn't fail when there are vertical asymptotes, and avoids the overhead of calls to Optimization:-Minimize and Optimization:-Maximize.

## Vertical asymptote...

@Preben Alsholm I do realize that your suggestion of applying Minimize and Maximize is not offered as a serious solution.  I just want to note that it won't work if the function has a vertical asymptote in the range, as in

```p := plot(10 + 1/(x-1)^2, x=0..2);
```

I agree with you that an option to plot, something like 'includeaxis1' ::truefalse with default false, would be a good idea.

## Getting the max and min...

@erik10 The max and min values of a plot can be obtained by calling plottools:-getdata.  Then you may calculate the desired range based on that, as done in this proc:

```restart;
get_view := proc(p)
local ymin, ymax;
plottools:-getdata(p):
op([2,2], %):
ymin, ymax := op(1,%), op(2,%);
ymin := min(ymin,0);
ymax := max(ymax,0);
return ymin..ymax;
end proc:
```

And here is how you will use it:

```plt := plot(2+sin(x), x=2*Pi..4*Pi):
plot(2+sin(x), x=2*Pi..4*Pi, view=get_view(plt));```

That said, I much prefer the pointplot method that I noted earlier.

## @Ronan That's good.  Do le...

@Ronan That's good.  Do let us know if you had success with those.

## @Rouben Rostamian  Ah, I see now.&n...

@Rouben Rostamian  Ah, I see now.  I didn't know about the interactive feature of the PDF file format.  I don't think that my suggestion of exporting graphics as EPS will help you at all.

## A simpler case...

```y := 1 - cos(t);