Preben Alsholm

13728 Reputation

22 Badges

20 years, 248 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

You have two different delta's it appears. You are assigning to one delta[min] and using another in the definition of A in the cosine. The output prints the latter delta the same as the former though.

Solution: Enter the two delta's in the same way (or much to be preferred in my opinion: don't use the default 2D input but use 1D input).

Write down the sum (A) of the areas of twe two circles using d as the diameter of one of the circles and 20 - d as the diameter of the other. Find the maximal value of A as a function of d.

plot([seq([7*a*t -t^2, t^5-(3+a)*t^3-3,t=-2..2],a=-3..3)]);

or you could try something like this

plots:-animate(plot,[[7*a*t -t^2, t^5-(3+a)*t^3-3,t=-2..2]],a=-3..3,frames=15,trace=14);

Maybe LinearFit in the Statistics package could be useful:

m:=Statistics:-LinearFit([1, x], Matrix(bdata), x, output=solutionmodule);
m:-Results();
R:=m:-Results("residuals");

According to the help page for testeq, "testeq may also return FAIL if it cannot find an appropriate modulus that works after seven trials."

So try

restart;
u1:=Y*(1-h*p1^Phi)*(1-t)+sum(Y*(1-t)/(1+r)^s, s = 1 .. infinity);
u2:=Y*(1-h*p1^Phi+1/r)*(1-t);
debug(testeq);
testeq(u1,u2);

#You will see 7 FAILs


If I understand your intensions maybe the following can be used. Notice that the most likely failure of fsolve is to return unevaluated. Returning NULL only happens if no solution exists as in fsolve(exp(x)=0,x).

restart;
f1 := x-> R*T*(x*ln(x)+(1-x)*ln(1-x))+Omega[l]*x*(1-x);
g1 := x-> (1-x)*SfA*(T-TfA)+x*SfB*(T-TfB)+R*T*(x*ln(x)+(1-x)*ln(1-x))+Omega[s]*x*(1-x);
TfA := 800; TfB := 1200; SfA := 10; SfB := 10; R := 8.3; Omega[l] := 0; Omega[s] := 0;
equ1 := (f1(x1)-g1(x2))/(x1-x2) = diff(f1(x1), x1);
equ2 := (f1(x1)-g1(x2))/(x1-x2) = diff(g1(x2), x2);
X1:=Vector(); #For keeping x1-values
X2:=Vector(); #For keeping x2-values
F:=Vector(); #For keeping f1-values
G:=Vector(); #For keeping g1-values
for T from 755 to 1199 do
ans:=fsolve({equ1,equ2},{x1=0..1,x2=0..1});
if not type(ans,specfunc(anything,fsolve)) then
X1(T),X2(T):=op(subs(ans,[x1,x2]));
F(T):=f1(X1[T]);
G(T):=g1(X2[T])
end if
end do:
#The first success seems to happen for T=801:
ArrayTools:-SearchArray(X1,1);
X1[801];
plot(X1,X2);
#Instead of producing tg in the loop I do it outside:
SL:=(F-G)/~(X1-X2);
TG:=SL*~(x-~X1)+F;
TG[801..810];
plots:-pointplot([seq([X1[T],T],T=801..1199)]);
plots:-pointplot([seq([X2[T],T],T=801..1199)]);
plots:-display(%%,%);

#To examine what is going on with fsolve it may help to look at this animation:

plots:-animate(plots:-implicitplot,[[equ1,equ2,x1=x2],x1=0..1,x2=0..1,grid=[50,50],gridrefine=2],T=790..1200);

How do you want to measure the change in the solution? Obviously the change depends on the independent variable as illustrated in this simple example:

ode:=diff(y(x),x)=a*y(x);
dsolve({ode,y(0)=1});
Y:=unapply(rhs(%),a);
combine(expand((Y(a+d*a)-Y(a))/Y(a)));

#The derivative of the solution y(x) w.r.t. a may be found without first finding y(x) like this:

diff(subs(y(x)=y(a,x),ode),a);
odew:=subs(diff(y(a,x),a)=w(x),y(a,x)=y(x),%);
dsolve({ode,odew,y(0)=1,w(0)=0});
#so relative to y(x) the derivative is:
subs(%,w(x)/y(x));

Overload does seem to fail with the seq qualifier. Here is a simple example.

restart;
S:=overload( [
proc(s::seq(posint),n::name) option overload;
print("proc1");
NULL
end proc,
proc(s::seq(posint),n::string:="blah") option overload;
print("proc2");
NULL
end proc
] );

S(1,2,x);
S(4,5,"x");
S(1,x);
S(1,"s");

How do you expect "-0.25g" to be parsed? You need to introduce a multiplication sign, if that is what you want.

A:=((StringTools:-Substitute)~)~(A,"g","*g");

After that you can do the loop, but you may want to save the parsed version in a matrix, so do:

B:=Matrix(4,24);

and replace parse(A[j, i]) by

B[j,i]:=parse(A[j, i])

When using assume(n::posint) an 'escaped local' variable appearing as n~ is created. Later when you do it again, another one is created, but it prints the same. The solution: Do it only once.

Try this simple example

restart;
assume(n::posint);
X:=n;
assume(n::posint);
Y:=n;
X+Y;

#and finally, if you copy the output from X+Y and paste it as input, it is entered as n+n, and the n appearing here will be the global n pointing to the local variable made with the last assume. Thus both occurrences of n in n+n will refer to the same variable.

Does the problem have a solution at all?

The closest I came was using the exact solver after which I only used the Cauchy data on y=0.

The solution found happens to satisfy the boundary condition on x=0, but not the boundary condition on x=2.

restart;
pde := diff(u(x, y), x,x)+4*diff(u(x, y),y,y)= -x*y;
ibc := {u(0, y) = 0, u(2, y) = 0, u(x, 0) = x*(4-x^2), D[2](u)(x, 0) = 0};
res:=pdsolve(pde);
eq1:=eval(rhs(res),y=0)=x*(4-x^2);
eq2:=eval(diff(rhs(res),y),y=0)=0;
eq1a:=diff(eq1,x);
solve({eq2,eq1a},{D(_F1)(-2*I*x),D(_F2)(2*I*x)});
expand(%);
subs(x=z/2/I,%);
map~(int,%,z);
#Constant omitted
select(has,%,_F1);
subs(z=-z,op(%));
%*(-1);
f1:=unapply(subs(%,_F1(z)),z);
eval(res,{_F1=f1,_F2=-f1});
SOL:=expand(%);
pdetest(SOL,[pde,op(ibc)]);
plot3d(rhs(SOL),x=0..2,y=0..1,axes=boxed);

You can use matrixplot from the plots package:

plots:-matrixplot(A,axes=boxed);

But you can also do:

plot3d([x, y, 'A'[round(x), round(y)]], x = 1 .. 32, y = 1 .. 32,axes=boxed);

Notice the unevaluation quotes around A (try removing them).

There is some confusion here. Try

p(.2)(.1);
plot(p(.2)(y),y=-1..1);
plot3d(p(x)(y),x=0..1,y=-1..1,axes=boxed);
animate(plot,[p(x),0..1],x=0..1);

I'm using Windows, but tried the command line interface there. I needed the usual semicolon

2+2;

I don't think you will get anywhere using solve. With fsolve, however, it is easy:

fsolve(BesselJ(0,x)=0,x=0..3);

You can also do

evalf(RootOf(BesselJ(0, _Z),2.1));

where the second argument singles out a root near 2.1. To see what is going on you can try
restart;
printlevel:=10;
evalf(RootOf(BesselJ(0, _Z),2.1));


First 115 116 117 118 119 120 121 Last Page 117 of 160