Hello,

New user of Maple, new to this MaplePrimes.

I am working with the following code taken from this help file.

In particular, I am studying the section "Techniques for solving a non-linear two-point BVP" towards the end.

Here is the initial setup of the code that puts the code I am finding challenging into context:

restart;
ode := diff(y(x),x,x) + (y(x))^2*diff(y(x),x) + cos(y(x)) = x;
bc1 := (1 + y(0))*D(y)(0) - 3*y(0) = 0;
bc2 := (1 + y(1))*D(y)(1) - 3*y(1) - (y(1))^2 + 0.5 = 0;

The code I am struggling with is as follows.

h:=proc(a,b)
local F;
Digits := 10;
if type(a,numeric) and type(b,numeric) then
F:=dsolve({ode,y(0)=a,D(y)(0)=b},y(x),numeric);
[rhs(F(1)[2],rhs(F(1)[3])];
else 'h'(a,b);
end if;
end proc:

Could someone please kindly explain to me what the underlying purpose is of the if.. then.. else conditions written into the procedure code? It is clearly necessary, because if I remove it then the code does not work. I can see that, were we to just run some instruction like h(1,3) then none of this woud be necessary. The value of a is set to 1, the value of b is set to 3, both of these values are numeric and the procedure can run the dsolve operation and spit out the list as determined by the contents of F(1).

But this procedure is being used to ultimately construct an implicit plot (see below), and without the extra conditional statements the code does not work. So, how does the way the code is structred get around the problem?

I have difficulty understanding the Maple environment regarding using quotes to delay evaluation. I have read a lot of information, but at the moment I have confused myself more and more.

I guess the best explanation to help me would be if someone were to describe to me what I am getting/needing/expecting if I were actually the Maple software myself running the code. How does the absence of the conditional statements mess things up for me? How is it rescued by these statements? The 'h'(a,b) really has me scratching my head. What does Maple do when a and b are not numeric? Do a and b start off not being numeric? When do they become numeric?

For clarity, following the help pages, th procedure is to be implemented as follows. First, two more procedures are created, one which involves h.

BC1 := proc(a,b)
(1 + a)*b - 3*a
end proc;
BC2 := proc(a,b)
(1 + h(a,b)[1])*h(a,b)[2] - 3*h(a, b)[1] - h(a,b)[1]^2 + 0.5
end proc;

And then the set of points (a,b) is to be plotted which simultaneously satisfy BC1=0 and BC2=0.

with(plots):
implicitplot([BC1(a,b)=0,BC2(a,b)=0], a=-5..1, b=-11..7, color=[black,red],
legend=["BC1(a,b)=0","BC2(a,b)=0"]);

Thanks for any help anyone can provide. The explanation needs to start off in simple terms - my head is spinning from all of the Maple descriptions in Maple terms and jargon. I'm not getting a foot in the door that way.

Best wishes

Mikey