Preben Alsholm

13471 Reputation

22 Badges

20 years, 218 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

In both solve commands change the derivative of f4(x) to diff(f4(x), x$3) as that is the highest order derivative of f4 appearing in sys as well as in newsys.
I recognize your code as my code given to (I presume) a fellow student of yours for a similar system. You need to understand why you change from sys to newsys.

#### Note (edited)
It appears that you need to differentiate sys[4] also in order to solve for the highest derivatives:

newsys := {sys[1], sys[3], sys[5], sys[6], diff(sys[2], x), diff(sys[4], x)};

Obviously, the definition of bcs2 should contain the undifferentiated versions of the ones differentiated above.

I don't think that the two equations determine functions ya(x), yc(x).
I'm assuming that E and f are constants (and that by pi you mean Pi).

restart;
eq1:=(1-Pi*x/2)*(f/2/E)*yc-1/3=Int(t^4/sqrt((t^2-(f/2/E)*yc)^2+ya^2),t=0..1);
eq2:=x^2*yc*(1-Pi*x/2)-1/3=Int(t^4/sqrt((t^2-x^2*yc)^2+ya^2),t=0..1);
subs(yc=2*E/f*y1,eq1);
subs(yc=y2/x^2,eq2);
eq:=subs(y2=y,%);
##
Suppose for a given x there is a solution (ya,yc) to the system {eq1, eq2}.
Then y1 = yc*f/(2*E) and y2=yc*x^2 both satisfy eq above.
SUPPOSE that actually eq has a unique solution for y for given x and ya. If that is so then y1=y2, i.e.  yc*f/(2*E) =yc*x^2. Now yc=0 does not satisfy eq1 or eq2. Thus f/(2*E) =x^2, contradicting the assumption that f and E are constants (assuming of course that you want to do this for more than just one x).

I shall only give graphical evidence of unique solution to eq for given x and ya:
We may restrict ourselves to ya>=0.
Notice further that any solution y to eq is positive if x < 2/Pi and negative if x > 2/Pi.
#First a couple of test plots:
plots:-implicitplot(eval(eq,x=0),ya=0..4,y=0..2,gridrefine=2);
plots:-implicitplot(eval(eq,x=1),ya=-2..2,y=-2..2,gridrefine=2);
#Animations. You can adjust as you please, the number of frames in particular.
use plots in
  animate(implicitplot,[eq,ya=0..2,y=0..2],x=-3..2/Pi-.1,frames=15)
end use;
use plots in
  animate(implicitplot,[eq,ya=0..2,y=-4..0],x=2/Pi+.1..3,frames=5)
end use;

#It appears that for each given x and ya there is a uniquely given yc.

Is this what you are trying to do?

dsol2:=`union`(dsol[]);
eval(eq2,dsol2);

Not surprising that you get diff(s(t),t).
The same is obtained by
odetest(dsol,eq2);
which basically evaluates either eq2 (as here) or the difference between the left and right hand sides of the ode as in this case
odetest(dsol,eq2=diff(s(t),t));

Of course for eq3 and eq4 you get the same as for eq2:

eval([eq2,eq3,eq4],dsol2);
odetest(dsol,[eq2,eq3,eq4]);
odetest(dsol,[eq2,eq3,eq4]=~diff(s(t),t));

When you do

dsolve({Teq,UEQ});

you get a result that gives you 3 different solutions for T(eta):

1. T(eta) = 0, which you cannot use because of your boundary conditions
2. T(eta) = _C3*eta+_C4
3. A complicated looking expression giving T(eta) in terms of a RootOf. Out of this one you are surely not going to get an analytic answer.

u(eta) is given as an unevaluated double integral involving T(eta).

So the best (or only) hope is for T(eta) = _C3*eta+_C4 to give us an expression for u(eta) where the integrals can be computed.
By using the boundary conditions we get T(eta) = eta.
After that we try

dsolve(eval(UEQ,T(eta)=eta));

We notice that we no longer have a double integral, but an integral, which Maple cannot do as it stands:
value(%);

You can try
dsolve({eval(UEQ,T(eta)=eta),D(u)(1)=0,u(0)=L*D(u)(0)}); #You don't get anything
dsolve({eval(UEQ,T(eta)=eta),u(0)=L*D(u)(0)}); #You do get something but an integral is still there
dsolve({eval(UEQ,T(eta)=eta),D(u)(1)=0}); #Also here you get an integral
############
## Numerical solution:
gama1:=0.2:
rhop:=5180:
rhobf:=998.2:
a[mu1]:=39.11:
b[mu1]:=533.9:
a[k1]:=7.47:
b[k1]:=0:
L:=1: N_bt:=1: #Not supplied by you.
res:=dsolve({Teq,UEQ,D(u)(1)=0,u(0)=L*D(u)(0),T(1)=1,T(0)=0},numeric);
plots:-odeplot(res,[eta,T(eta)-eta],0..1);
## In this case we do get a solution where T(eta) = eta. See note below ******
#This gives us not much of a hint as to the form of the value of the integral for u:
plots:-odeplot(res,[eta,u(eta)],0..1);
res(0);
res(1);
####
***Note: This is not surprising in view of the result of
`dsolve/numeric/bvp/convertsys`({Teq,UEQ},{D(u)(1)=0,u(0)=L*D(u)(0),T(1)=1,T(0)=0},[T,u],eta,l);
Or the result of:
solve(Teq,diff(T(eta),eta,eta));


If you just want to see the values of i+n as they are computed, you can set printlevel to 2:
restart;
printlevel; #Default value 1
printlevel:=2:
for i from 0 to 10 do
  for n from 0 to 10 do
    i+n
  end do
end do;

##Alternatively, use an explicit print statement, i.e. replace i+n by print(i+n).

restart;
for i from 0 to 10 do
  for n from 0 to 10 do
    print(i+n)
  end do
end do;

I tried
?inert command

where % was mentioned and a link given to value:

?value

I also tried
? %

The page that came up was about the ditto operators, but at the left value (%) was listed as the second entry.

About piecewise.
For the active (non-inert) form to work every other argument has to be a relation or a boolean combination of inequalities, as is stated in the help page for piecewise:
?piecewise

`` is a name, not a relation or of type boolean. The following returns false:

type(``,{relation,boolean});

and this returns true:
type(``,name);

The following version is certainly not simple, but has the advantage of using just one add:

restart;
a:=Matrix([[1,2],[3,4]]):
add(cat('a',b)*cat(f,b),b=indices(a));
evalindets(%,name,eval@parse);
A:=Array(1..2,2..5,0..6,(i,j,k)->i*j*k);
add(cat('A',b)*cat(f,b),b=indices(A));
evalindets(%,name,eval@parse);

I don't know of a way to specify names of arbitrary constants in advance.
But the names can be changed afterwards.
Either by simple assignment e.g.  _C1:=A; _C2:=B; or by the following method which I illustrate in a simple example.

restart;
ode1:=diff(x(t),t)=1+x(t);
ode2:=diff(y(t),t)=2+y(t);
dsolve(ode1); #Uses _C1
dsolve(ode2); #Uses _C1
res:=dsolve({ode1,ode2}); #Uses _C1 and _C2
##Changing names to A and B:
indets(res,name) minus indets({ode1,ode2},name)=~{A,B};
res2:=eval(res,%);

You cannot obtain your desired names by assigning in advance of using dsolve as in _C1:=A; _C2:=B;
because dsolve will not use assigned names.

In the following code I try finding a solution for which phi=0, UF=0, UTF=0.
In view of the difficulty in finding a solution to the original problem, this might be of interest.

I start with your definitions of the equations and the approxsoln GUESS.

systotal:=subs(NBT=NBBT,{ueq2,Teq,eq3,eq4,eq5,eq6,eq7,U(0)=0,UF(0)=0,UT(0)=0,UFT(0)=0,((-cbf*rhobf+cp*rhop)*UF(1)+ rhobf*cbf*U(1))/10000=p2,(((-cbf*rhobf+cp*rhop)*UFT(1)+ rhobf*cbf*UT(1)))/(p2*10000)=T_Bulk,UF(1)=Phiavg*U(1),D(u)(0)=0,u(1)=-lambda*D(u)(1),D(T)(0)=0,phi(0)=phi0,D(T)(1)=1}):
###
sys,bcs:=selectremove(has,systotal,diff):
sys:=fnormal(sys);
#res:=dsolve(sys union bcs,numeric,approxsoln=GUESS,method=bvp[midrich]); #FAILURE

#Setting phi=0, UTF = 0, UF = 0:
eval(sys,{UF=0,UFT=0,phi=0,phi0=0});
sys4:=select(has,%,diff);
eval(bcs,{UF=0,UFT=0,phi=0,phi0=0});
remove(has,%,T_Bulk);
select(hastype,%,function);
bcs4:=remove(has,%,U(1));
nops(bcs4);
GUESS4:=remove(has,GUESS,{T_Bulk,UFT,UF,phi0,phi});
res4:=dsolve(sys4 union bcs4 union {T(0)=0},numeric,approxsoln=GUESS4,method=bvp[midrich]);
plots:-odeplot(res4,[[eta,T(eta)],[eta,u(eta)],[eta,U(eta)],[eta,UT(eta)]],0..1,thickness=3,legend=[T,u,U,UT]);
res4(0);

Solve as a system in one call to dsolve as in

dsolve({eg1,eq2, x(0)=0, ...(fill in inits) },numeric);

But give us your code instead of images so we don't have to type.

Here is another and rather simple minded approach.
It discretizes y and for the integral it simply uses a Riemann integral with fixed interval length d.
It is in need of refinement. But for now here it is:

restart;
eq2:=y(t)=1-h*Int(JacobiTheta3(0,exp(-Pi^2*(t-s)))*y(s)^4,s=0..t); #Better
eq:=y[i]=1-h*Sum(JacobiTheta3(0,exp(-Pi^2*(t[i]-s[j])))*y[j]^4*d,j=1..i-1);
h:=0.65e-4;
d:=.01;
for i from 0 to 100 do t[i]:=i*d; s[i]:=i*d end do:
eqs:=[seq(eq,i=1..100)]:
eqs:=value(%):
res:=fsolve(eqs);
L:=eval([seq([t[i-1],y[i]],i=1..100)],res);
plot(L);

Use an Array instead:

x:=Array(0..2,[1,2,3]);

x[0];

The cause is to be found in the package VectorCalculus. Try the whole worksheet starting with restart and comment out with(VectorCalculus) and BasisFormat(false).

Then the double summation gives you 3.

I use this package very rarely and, when I do, I use the long form as in VectorCalculus:-Jacobian.

Notice that the package redefines `*`,`+`,`-`,`.`,<,>,<|>  and many more familiar operations or procedures.

I found one solution (so far):

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);



h3 is much smaller than the other three.
plots:-odeplot(sol,[theta,h2(theta)]);


The corresponding omega2 is found from sol(0) to be omega2 = 2.0798272963267560997*10^13. omega is the square root of that.

To find a successful approxsoln I used my own homemade procedure.
Since the system is linear and homogeneous any constant multiple k of (h1,h2,h3,h4) will also be a solution to the ode system for the same omega2. However, the inhomogeneous boundary condition (D@@2)(h2)(1) = 1 wiil have to be adjusted to (D@@2)(h2)(1) = k.
And indeed the following, where the factor k is 10^(-7) also works:
dsolve(newsys2 union bcs union {bcs2,(D@@2)(h2)(1)=10^(-7)}, numeric,approxsoln = [omega2 = 2.08*10^13, h1(theta) = 5*theta*(1-theta)*(1/2-theta), h2(theta) = 0, h3(theta) = 0.7*theta*(1-theta)*(1/2-theta), h4(theta) = 0.5*theta*(1-theta)*(1/2-theta)], abserr = 0.1,initmesh=1024);

You are missing a few multiplication signs.
There are 3 solutions.

restart;
eq1:=y=86:
eq2:=y=-0.0000054527*x^3+0.010903836*x^2+0.0714244709*x+74.18816:
sol:=solve({eq1,eq2},{x,y});
##Graphical check:
plot([rhs(eq1),rhs(eq2)],x=-37..31);
plot([rhs(eq1),rhs(eq2)],x=-37..2010);
plot([rhs(eq1),rhs(eq2)],x=-37..2010,y=0..90);
plot(ln~([rhs(eq1),rhs(eq2)]),x=-37..2010); #The logarithm applied to both

First 54 55 56 57 58 59 60 Last Page 56 of 158