Preben Alsholm

13728 Reputation

22 Badges

20 years, 252 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

Taking a look at the procedures BesselJ and `evalf/BesselJ` it appears clear that the problem is in `evalf/BesselJ`.

To see the procedures do

showstat(BesselJ);
showstat(`evalf/BesselJ`);

In the first, BesselJ, you see from the first 5 lines:

showstat(BesselJ,1..5);

that what is returned from BesselJ(-3.0,0) or BesselJ(-3,0.) is in fact `evalf/BesselJ`(-3.0,0);

Now look at the lines 7..13 in `evalf/BesselJ`:
showstat(`evalf/BesselJ`,7..13);
There is a problematic statement that says if x=0 then
res := `if`(v = 0,1.+`if`(type([v, x],('list')('float')),0,0.*I),x^v);

In our case v:=-3.0 and x:=0. , so since v<>0, res evaluates to 0.^(-3.0) , which evaluates to Float(infinity).

Note: It should be pointed out that the result of evalb(0=0.); is true

@Kitonum The extraneous lines disappear (of course) when you add the option 'style=point' to the plot P.

We can conclude that here plot connects points which we don't want connected.

If you change the parametrization so it makes a continuous curve, e.g. by going counter clockwise like the following then everything should be fine.

Sq:= t-> piecewise(t < 1, [t,0], t < 2, [1,t-1], t < 3, [3-t,1], [0,4-t]):

@rlopez One looks in vain in the help for type for the type 'known'.

It is known (no pun intended) to the system from the start, however.
`type/known`evaluates to And(function, `PDEtools/known_function`).

restart;
`type/known`;
showstat(`type/PDEtools/known_function`);
## diff is considered known:
type(diff(y(x),x),known);


@catrapato In one procedure of mine I used the following method here exemplified with your system:

restart;
odex[1] := cos(x)*(diff(y[1](x), x, x))+(K^2)*sinh((1/10)*x+1)*y[2](x)+y[1](x)+exp(-x)-1:
odex[2] := (diff(y[2](x), x, x))/(1+x)+(K^2)*exp((1/10)*x+1)*y[1](x)/(1+x)-y[2](x)+erf(-x)-1:

vars:=remove(has, indets(indets({odex[1],odex[2]},specfunc(diff)),function), diff);
x:=op(op~(1,vars)); #Finding the independent variable

## The method proposed by Robert Lopez works at least as well:
Q:=indets(indets({odex[1],odex[2]},'specfunc'('anything','diff')),'And'('function','Not'('known')));


Presumably there is one more ode, one involving y[2] ?

In any case the given ode is taken out of context if y[1] and y[2] are both supposed to be unknown.

@Markiyan Hirnyk Presumably there is one more ode, one involving y[2].

In any case the given ode is taken out of context if y[1] and y[2] are both supposed to be unknown.

@vv Using numerical calculation of the infinite series:

restart;
S:=convert(hypergeom([2/3,2/3,2/3],[-1/3,4/3],z),FormalPowerSeries);
evalf[50](eval(S,z=99/100));

    -138.99623131713330917549791383444227380249824260753


@Damon Now the link is visible and works.

@Damon I cannot see any attachment, can you?

@farahnaz (1) My guess is that the minimal omega2 is 0.956187059957532*10^13, but it is just a guess.

(2) I wrote:
   To get the successes you can do:
   indices(res);

and that is what gives you the successful attempts in the do loop.
No assignment is made to res[b] when dsolve results in an error. By doing indices(res) you will see which b's resulted in an assignment of a table element res[b] to the table res.
Note: If res is just a name, then the assignment res[xxx]:=89; implicitly creates a table whose only index at this point is xxx and whose only entry is 89.

@farahnaz Not too surprising there are other eigenvalues. E.g. a smaller eigenvalue omega2 = 0.956187059957532*10^13.
To find it (and in general for this system) it makes sense to scale omega2 since it is so large.
The reason is that abserr is also measured against the enormous omega2. This makes solution impossible with small abserr.
So the suggestion is to replace omega2 by omega2*10^13:
Thus the new system newsys2S is:

newsys2S:=subs(omega2=10^13*omega2,newsys2);
##Now do

res:=dsolve(newsys2S union bcs union {bcs2,(D@@2)(h2)(1)=10^(-7)}, numeric,approxsoln = [omega2 = 1, h1(theta) = -6*theta*(1-theta), h2(theta) = 1e-5*theta*(1-theta)(1/2-theta), h3(theta) = theta*(1-theta), h4(theta) = -theta*(1-theta)], abserr = 1e-4,initmesh=256);

##You find the new eigenvalue here
res(0);

#Of course you have to remember to multiply the value by the scaling factor 10^13.

##The loop now works on the system with scaled omega2. Make the scaling change in the code before the loop. Use Digits=15. Run the loop using abserr=1e-3. In approxsoln change the omega2 guess to omega2=1 (to start with).
To get the successes you can do:
indices(res);
I found 3:
[(D(h2))(1)], [(D(h2))(0)], [((D@@2)(h1))(0)], [((D@@3)(h1))(0)]
To find the corresponding omega2's do
res[(D(h2))(1)](0); #Gives the eigenvalue found earlier 2.07982729632676 (*10^13)
res[(D(h2))(0)](0); #The same
res[((D@@2)(h1))(0)]; #omega2=6.27005104177759 (*10^13)
res[((D@@3)(h1))(0)]; #omega2= 12.5461315012613 (*10^13)
#By changing approxsoln, inparticular the value of omega you will find more eigenvalues.

@farahnaz I think that I already gave the answer to your question 2 in my comment titled "omega".

I don't quite understand question 1. But as I have emphasized in the same comment above: boundary value problems are difficult. I cannot give you a ready made solution which will work for all choices of your parameters.

@farahnaz Do 2 things:

1. Change Digits:=20: to Digits:=15:
  This makes the whole thing go much faster.
2. Add the lines I gave you above at the very bottom. These were the lines:

sol:=dsolve(newsys2 union bcs union {bcs2,(D@@2)(h2)(1)=1}, numeric,approxsoln = [omega2 = 2.08*10^13, h1(theta) = 5*10^7*theta*(1-theta)*(1/2-theta), h2(theta) = 0.05, h3(theta) = 7*10^6*theta*(1-theta)*(1/2-theta), h4(theta) = 5*10^6*theta*(1-theta)*(1/2-theta)], abserr = 0.1,initmesh=1024);

plots:-odeplot(sol,[seq([theta,cat(h,i)(theta)],i=1..4)],thickness=3);

plots:-odeplot(sol,[theta,h2(theta)]);

### Finally, run the whole thing from the restart at the top. Ignore the error messages comming from the loop.
### Once you see the bottom lines working, i.e. when you see that pictures are actually produced, then start cleaning up the mess and that could involve removing the entire loop.
You will want to keep the definition of newsys2, bcs, and bcs2 since they are used at the bottom.


@acer Responding to


But I only know of one way to make such a policy be implemented by the administrators of this site: we members (who currently have the ability to do so) would all have to stop deleting the spam.

I'll give it a try.

@farahnaz The value of omega2 (remember that we replaced omega^2 with omega2) is found by dsolve. I didn't make it up.
What I did do was to give dsolve a start value for omega2. That start value omega2 = 2.08*10^13 was found from using my homemade procedure, which requires an approximate solution.
As an approximate solution in my procedure I actually used the one we previously used:

[omega2 = 1, h1(theta) = theta*(1-theta), h2(theta) = sin(Pi*theta), h3(theta) = theta*(1-theta), h4(theta) = theta^2*(1-theta)^2]

i.e. we were trying to find a solution with zeros only at the end points.

But my procedure found a solution which more resembles the one I subsequently used on dsolve:

[omega2 = 2.08*10^13, h1(theta) = 5*10^7*theta*(1-theta)*(1/2-theta), h2(theta) = 0.05, h3(theta) = 7*10^6*theta*(1-theta)*(1/2-theta), h4(theta) = 5*10^6*theta*(1-theta)*(1/2-theta)]

i.e. a solution with zero(s) also in the interior of the interval.

When I used my own procedure I didn't use a loop nor did I use a try... end try construction. I started with the b found in our previously successful attempt for another (but somewhat similar) system, b=(D@@3)(h2)(1).
My procedure has to solve the total set of boundary conditions for (in this case) 14 unknowns. It couldn't do that when using (D@@3)(h2)(1) so I quite simply tried using (D@@3)(h2)(1) = 1 as the extra condition and had success.
End of story.

My advice is to play with these things. Don't start out with a loop etc. Try one extra condition at a time. Use all the options you know of, try changing them etc.
Boundary value problems are definitely more difficult to deal with than initial value problems.

First 104 105 106 107 108 109 110 Last Page 106 of 230