## 7160 Reputation

10 years, 142 days

## MaplePrimes Activity

### These are answers submitted by nm

You need to be careful which convention to use for spherical coordinates. There is the Physics one and there is the mathematics one. See https://en.wikipedia.org/wiki/Spherical_coordinate_system

Using the Physics one (more common)

```evalf(int(int(int(ln(r^2 + theta^2 + phi^2 +1),r=0..2),theta=-Pi/2..Pi/2),phi=0..2*Pi))
```

97.2256142300

Using the math convention for the angles

```evalf(int(int(int(ln(r^2 + theta^2 + phi^2 +1),r=0..2),theta=0..2*Pi),phi=-Pi/2..Pi/2))
```

97.2256142300

if you use 0..Pi instead of -Pi/2..Pi/2 you get

```evalf(int(int(int(ln(r^2 + theta^2 + phi^2 +1),r=0..2),theta=0..2*Pi),phi=0..Pi))
```

105.5237634000

Not sure which convention you want. Wikepida page above describes these more.

ps. only numerical integration worked in Maple.

```restart;
ode:=diff(y(x),x)+k*piecewise(y(x)>=0,y(x),y(x)<0,0) =sin(x);
dsolve(ode)

```

Can't solve it analytically. You can solve this nuemrically only

```restart;
k:=1;
ode:=diff(y(x),x)+k*piecewise(y(x)>=0,y(x),y(x)<0,0) =sin(x);
sol:=dsolve([ode,y(0)=1],numeric)
```

Maple used to have many of these cases, but it got better over years handling them.

A trick to bypass this issue, is to delay the substitution of the actual function until after you obtained the series solution. As follows.

Using a generic f(x,y) first, then this function is replaced by the actual value of the function after the series solution is obtained. This makes life much easier for Maple pdsolve.

 > restart;
 > interface(version);

 > pde := diff(u(x,y,t),t,t) = diff(u(x,y,t),x,x) + diff(u(x,y,t),y,y); bc := u(x,0,t)=0, u(x,1,t)=0, u(0,y,t)=0, u(1,y,t)=0; ic := u(x,y,0) =f(x,y),  D[3](u)(x,y,0)=0; sol := pdsolve({pde, bc, ic}); my_actual_function :=x*y*sin(Pi*x)*sin(Pi*y); sol:=eval(sol, [infinity=4,f(x,y)=my_actual_function]);

 > #now it works         value(sol)

 >

Looking at Wikipeida, it looks like you used different formula. The formula with the origin at center is

You wrote

Where the eccentricity you used is 0.25.

Fixing this, and increasing e, you get ellipse.

```e:=0.25; b:=1;
p1:=plot(b/sqrt(1- (e*cos(theta))^2), theta = 0 .. 2*Pi, coords = polar, scaling = constrained,color=red):
e:=0.75;
p2:=plot(b/sqrt(1- (e*cos(theta))^2), theta = 0 .. 2*Pi, coords = polar, scaling = constrained,color=blue):

plots:-display([p1,p2])

```

Try this. Need to use := and not = for assignment. And why write 1.  instead of just 1 ? This is not Matlab. If you want real numbers, you could always convert the final answer to float, and it is more accurate this way.

```restart;

H := proc(n::integer)::real;
local s, i;
s := 0;
for i by 2 to n do
if i <= n - 1 then
s := s + 1/(i*(i + 1));
else
s := s + 1/i;
end if;
end do;
return s;
end proc;

A := proc(n::integer, T::procedure)::real;
local d1, d2, s;
d1 := T(n + 1) - T(n);
d2 := T(n + 2) - T(n);
s := T(n + 1) - d1*d2/(d2 - d1);
return s;
end proc;
```

```restart;