## 215 Reputation

3 years, 258 days

## Comparing the graphics for some real val...

Maple

Dear there,

for 2d graphics:
for alpha=0.3,  when we run the code, we get a graphics of function UU(0.5,t)

and after restarting the code

for alpha=1 when we run the code again, we get a graphic of function UU(0.5,t).

QUESTION 1: So, I want to display these two graphs together in one graph (2d).

And also for 3d graphics:

for alpha=0.3,  when we run the code, we get a graphics of function UU(x,t)

and after restarting the code

for alpha=1 when we run the code again, we get a graphic of function UU(x,t).

QUESTION 2: I want to display these two graphs together in one graph (3d).

```restart:
with(orthopoly):
with(LinearAlgebra):
with(plots):
interface(rtablesize=20):
k:=2:
M:=2:
K:=2^(k-1):
N:=K*M:

alpha:=1:

alpha1:=alpha:
beta:=1:
lambda:=(m,alpha1,beta)->sqrt((2*m+alpha1+beta+1)*GAMMA(2*m+alpha1+beta+1)*m!/(2^(alpha1+beta+1)*GAMMA(m+alpha1+1)*GAMMA(m+beta+1)));
psii:=(n,m,x)->piecewise((n-1)/K <= x and x <= n/K,  2^(k/2) *lambda(m,alpha1,beta)*simplify(JacobiP(m,alpha1,beta,2^(k)*x-2*n+1)), 0);
local i,j: psi:=(x)->Array([seq(seq(psii(i,j,x),j=0..M-1),i=1..K)] ):

w:=(n,x)->(1+x)^(1/gama-1):
omega:=(n,x)->w(n,2^(k)*x-2*n+1):

psi:=t->Matrix(N,1,[seq(seq(psii(i,j,t),j=0..M-1),i=1...K)] ):

for i from 1 to N do
X[i]:=evalf((2*i-1)/((2^k)*M)):
end do:

for i from 1 to N do
T[i]:=evalf((2*i-1)/((2^k)*M)):
end do:

for i from 1 to N do
r[i]:=evalf(psi(T[i])):
end do:
Phi_mxm:=Matrix([seq(r[i],i=1...N)]);

P:=proc(k,M,nn) local PB,m,i,p,j,xi;
m:=M*(2^(k-1)):
xi:=(i,n)->((i+1)^(n+1)-2*i^(n+1)+(i-1)^(n+1));
PB:=Matrix(m,m):
for i from 1 to m do
p:=0:
for j from 1 to m do
if i=j then PB[i,j]:=1;
fi:
if i<j then p:=p+1:
PB[i,j]:= xi(p,nn);
fi:
end do;
p:=1:
end do:
PB:=1/m^nn/GAMMA(nn+2)*PB;

return PB;
end proc:
PP:=alpha->Phi_mxm.P(k,M,alpha).MatrixInverse(Phi_mxm);

key:=4:
rho:=1:
mmm:=1:
sigma:=1:

u_exact:=(x,t)-> 1/(1+exp(sqrt(key/6)*x-(5/6)*key*t))^2 ;
f1:=unapply(u_exact(x,0),x):
g1:=unapply(u_exact(0,t),t);
g2:=unapply(u_exact(1,t),t);

U:=Matrix( N,N,symbol=u);
wwxx:= diff(f1(x),x,x)+(psi(x)^+.U.PP(alpha).psi(t))(1):
wwt:= diff(g1(t),t)+x*(diff(g2(t),t)-diff(g1(t),t)-(psi(1)^+.PP(2)^+.U.psi(t))+psi(x)^+.PP(2)^+.U.psi(t))(1) :
ww:= f1(x)+g1(t)-g1(0)+x*(g2(t)-g2(0)-g1(t)+g1(0)-(psi(1)^+.PP(2)^+.U.PP(alpha).psi(t)))(1)+(psi(x)^+.PP(2)^+.U.PP(alpha).psi(t))(1) :

MC:=unapply(wwt -rho*wwxx -key*ww .(1-(1/mmm)*ww^sigma ),x,t):

PDEson:=Matrix(N,N):

for i from 1 to N do
for j from 1 to N do
PDEson(i,j):=simplify(
evalf(

MC(X[i],T[j])

)
)=0:
end do:
end do:
coz:=fsolve({seq(seq(PDEson(i,j),i=1..N ),j=1..N )}):
U:=subs(op(coz),U):

UU:=(x,t)->evalf(f1(x)+g1(t)-g1(0)+x*(g2(t)-g2(0)-g1(t)+g1(0)-(psi(1)^+.PP(2)^+.U.PP(alpha).psi(t)))(1)+(psi(x)^+.PP(2)^+.U.PP(alpha).psi(t))(1)):

with(plots):
graphic_3D:=plot3d(UU(x,t),x=0..1,t=0..1,color=gray);

graphic_2D:=plot(UU(0.5,t),t=0..1);

```

## Adjusting the range of the axes in 3D pl...

Maple

Suppose that we have a 3D plot in Maple like above. How can we adjust the ranges of the axes as follows?

• The ranges of axes x and axes t must be decimal like (0.1, 0.2 ,...,1)
• The range of axes z must be scientific as figure above.

Maple sometimes automatically does it but sometimes doesn't it. I don't understand the logic behind it.

## Exporting the 3D Maple graphics to the t...

Maple

I want to export the Maple graphics to LATEX in high resolution.

I can export the 2D Maple graphics to LATEX by clicking the right button of the mouse and exporting the graphics as .eps (Encapsulated PostScript). No problem.

But in 3D Maple graphics, after adding the graphics to the latex and compiling it, I live some problems. For example, when I open the pdf file of the latex file, adobe reader stops working or I can' t zoom in the 3d graphics if it is opened. (I think this may be due to the style of the graphics)

I have three 3d graphics in my maple code.mw ( includes graphic of exact solution, both exact and numerical solution in one figure and also error graphics)

Can you help me add these graphics to latex in high resolution and understandable style? (Because the comparison of the exact and numerical solution in one figure is important. Which style do you prefer?)

## Finding optimal values of some parameter...

I wrote a code.mw for a numerical method for a PDE. (You can find the numerical method, exact solution and error between them in the code.)

The method depends on parameters k, M, which are any positive integers, and also depends on teta, beta>-1 which are real numbers.

According to the used method,

when k and M increase, we expect that the error (exact-numeric) generally decreases.

In the code, I selected k=2, M=2, teta=1 and beta=1. And so k=2, M=2, CPU time is low. Error is not bad.

But for k=4, M=3 and also for bigger values of them, CPU time is high. I can' t get the solution.

Question 1:

I don't know, but it may be possible to simplify the code in order to calculate for k=4, M=4?

Question 2:

I want to find optimal values of teta and beta for minimizing the error between numerical and exact solution, when k=2, M=2, or k=3, M=1 etc.

How can we write a Maple code for finding optimal values of teta and beta?

## Creating a table...

Maple
```restart:
N:=3:
for i from 1 to N do
x[i]:=evalf((2*i-1)/(N)) :
end do:
for i from 1 to N do
t[i]:=evalf((2*i-1)/(N)) :
end do:
f:=unapply(x*t,x,t);
g:=unapply(x^2*t,x,t);
```

Question 1: We have two functions f and g as above. How can we create a table which contains merged cells as follows by Maple?

Question 2:  How to convert or export the table to LATEX?

 1 2 3 4 5 6 7 Last Page 1 of 14
﻿