MaplePrimes Questions

Search Questions:

Latest Questions Latest Questions Feed

U(x,t)= 2/3f(x+t)+1/3f(x-2t)+(1/3pi)(sin(pi(x+t))+(1/3pi)(sin(pi(x-2t)),

f(x)=1-x,abslutex<1, zero otherwise

Why the command

 

coeff(sum(x^i,i=0..999)^500,x,2) prints

 

Error, unable to compute coeff??

 

I believe, that memory/cpu issues are not a relevant answer here.

 

Already

coeff(sum(x^i,i=0..998)^500,x,2) gives the correct result.

Even

coeff(sum(x^i,i=0..998)^500,x,200) is ok.

How do I compute coeffs of longer sums?Or why this limitation is imposed by Maple Server?

I am trying to plot sequence like:

arrayZ[1]:=NULL;
arrayZ[2]:=5;
arrayZ[3]:=NULL;
arrayZ[4]:=NULL;
arrayZ[5]:=8;

...

arrayZ[3000]:=1111;
data:=[seq([n,arrayZ[n]], n=1..3000)]:
t1:=plot(data, style=point, symbol = solidcircle, color= red):
plots[display]({t1});

but get incorrect first argument error. How to fix this?

PS. In original sequence instead of null I have constant value, but I don't want it in my plot.


Good day,

How can this be corrected ''Error, (in dsolve/numeric/bvp) initial Newton iteration is not converging'' see the worksheet here VT.mw

Acer, 

Thanks. This request from me comes from the need that Maple does not have a real DAE solver. (It converts ODEs to DAEs and then solves, which fails for nonlinear and most non-trivial DAEs).

Your question is valid. For situations which can be compiled (i.e, no Heaviside or functions that can't be compiled) at hardware floats, I would like to have a Newton Raphson solver. Some parameters (time values) change when you integrate DAEs, which means that there is a need to solve the same set of nonlinear equations again and again for minor changes in parameters.

While LinearSolve is fast, evaluating F and Jac for a large system of equations can kill the speed. I am attaching an example for Newton wherein F, Jac and a linear solver is compiled. But the Newton procedure is not. If we can compile the Newton procedure also, it will be much more faster.

Also, having a compiled code with parametric form will help in optimization. 

restart:

Digits:=15;

Digits := 15

(1)

N:=4;

N := 4

(2)

f:=array([seq(evalf(-2*x[i]+x[i]^2+0.99/i^2),i=1..N)]);

f := Vector[row](4, {(1) = -2.*x[1]+x[1]^2+.99, (2) = -2.*x[2]+x[2]^2+.247500000000000, (3) = -2.*x[3]+x[3]^2+.110000000000000, (4) = -2.*x[4]+x[4]^2+0.618750000000000e-1})

(3)

fsolve({f[1],f[2],f[3],f[4]},{x[1]=1.2,x[2]=1,x[3]=0,x[4]=0});

{x[1] = .900000000000000, x[2] = .132532421355126, x[3] = 1.94339811320566, x[4] = 0.314314686094742e-1}

(4)

 

eqsA := [seq(F[i]=f[i],i=1..N)]:

irform2 := StatSeq(seq(Assign(op(i)),i=eqsA)):

prccons:= codegen[intrep2maple](Proc(Parameters(x::Array,F::Array),irform2)):

f3:=Compiler:-Compile(prccons):

 

 

x0:=Vector([seq(1/2,i=1..N)],datatype=float[8]);

x0 := Vector(4, {(1) = .500000000000000, (2) = .500000000000000, (3) = .500000000000000, (4) = .500000000000000})

(5)

f0:=Vector([seq(0,i=1..N)],datatype=float[8]);

f0 := Vector(4, {(1) = 0., (2) = 0., (3) = 0., (4) = 0.})

(6)

eqsJ := [seq(seq(Jac[i,j]=evalf(diff(f[i],x[j])),j=1..N),i=1..N)];

eqsJ := [Jac[1, 1] = -2.+2.*x[1], Jac[1, 2] = 0., Jac[1, 3] = 0., Jac[1, 4] = 0., Jac[2, 1] = 0., Jac[2, 2] = -2.+2.*x[2], Jac[2, 3] = 0., Jac[2, 4] = 0., Jac[3, 1] = 0., Jac[3, 2] = 0., Jac[3, 3] = -2.+2.*x[3], Jac[3, 4] = 0., Jac[4, 1] = 0., Jac[4, 2] = 0., Jac[4, 3] = 0., Jac[4, 4] = -2.+2.*x[4]]

(7)

 

irformJ := StatSeq(seq(Assign(op(i)),i=eqsJ)):

prcconsJ:= codegen[intrep2maple](Proc(Parameters(x::Array,Jac::Array),irformJ)):

J3:=Compiler:-Compile(prcconsJ):

 

 

j0:=Matrix(1..N,1..N,datatype=float[8]):

 Following linear sovler algorithm is basiclly from dsolve/numeric/SC

.

 

 

s3:=proc(n::posint, A::Array( datatype = float[ 8 ] ) , ip::Array( datatype = integer[ 4 ] ),b::Array( datatype = float[ 8 ] ) )
local i::integer, j::integer, k::integer, m::integer, t::float;
      ip[n] := 1;
      for k to n-1 do
        m := k;
        for i from k+1 to n do
          if abs(A[m,k]) < abs(A[i,k]) then
            m := i
           end if
         end do;
        ip[k] := m;
        if m <> k then
          ip[n] := -ip[n]
         end if;
       t := A[m,k];
       A[m,k] := A[k,k];
       A[k,k] := t;
       if t = 0 then
         ip[n] := 0;
         #return ip
         end if;
       for i from k+1 to n do
         A[i,k] := -A[i,k]/t
         end do;
       for j from k+1 to n do
         t := A[m,j];
         A[m,j] := A[k,j];
         A[k,j] := t;
         if t <> 0 then
           for i from k+1 to n do
             A[i,j] := A[i,j]+A[i,k]*t
             end do
           end if
         end do
       end do;
     if A[n,n] = 0 then
       ip[n] := 0
       end if;
     #ip[n]
      if ip[n] = 0 then
        error "The matrix A is numerically singular"
       end if;
      if 1 < n then
        for k to n-1 do
          m := ip[k];
          t := b[m];
          b[m] := b[k];
          b[k] := t;
          for i from k+1 to n do
           b[i] := b[i]+A[i,k]*t
           end do
         end do;
       for k from n by -1 to 2 do
         b[k] := b[k]/A[k,k];
         t := -b[k];
        for i to k-1 do
           b[i] := b[i]+A[i,k]*t
           end do
         end do
       end if;
     b[1] := b[1]/A[1,1];
return;
end proc:

s3c:=Compiler:-Compile(s3):

 

 

x0:=Vector(N,[seq(0.5,i=1..N)],datatype=float[8]);

x0 := Vector(4, {(1) = .500000000000000, (2) = .500000000000000, (3) = .500000000000000, (4) = .500000000000000})

(8)

f0;

Vector(4, {(1) = 0., (2) = 0., (3) = 0., (4) = 0.})

(9)

j0:=Matrix(1..N,1..N,datatype=float[8]);

j0 := Matrix(4, 4, {(1, 1) = 0., (1, 2) = 0., (1, 3) = 0., (1, 4) = 0., (2, 1) = 0., (2, 2) = 0., (2, 3) = 0., (2, 4) = 0., (3, 1) = 0., (3, 2) = 0., (3, 3) = 0., (3, 4) = 0., (4, 1) = 0., (4, 2) = 0., (4, 3) = 0., (4, 4) = 0.})

(10)

10

(11)

Newton:=proc(x0,f0,j0,N)
global f3,s3c;
local xnew,err,xold,ip,i::integer;
ip:=Vector(N,[seq(1,i=1..N)],datatype=integer[4]);
err:=10;
xold:=x0;
while err>1e-8 do
f3(xold,f0);
J3(xold,j0);
s3c(N,-j0,ip,f0);
xnew:=xold+f0;
err:=max(abs(f0))/N;
xold:=xnew;
end:
xnew;
end proc;

 

Newton := proc (x0, f0, j0, N) local xnew, err, xold, ip, i::integer; global f3, s3c; ip := Vector(N, [seq(1, i = 1 .. N)], datatype = integer[4]); err := 10; xold := x0; while 0.1e-7 < err do f3(xold, f0); J3(xold, j0); s3c(N, -j0, ip, f0); xnew := xold+f0; err := max(abs(f0))/N; xold := xnew end do; xnew end proc

(12)

Compiler:-Compile(Newton);

Error, (in CodeGeneration:-IssueError) cannot analyze non-integer range boundary args[4]

 

t11:=time():Newton(x0,f0,j0,N);time()-t11;

Vector(4, {(1) = .900000000000000, (2) = .132532421355126, (3) = 0.566018867943396e-1, (4) = 0.314314686094742e-1})

0.

(13)


Download NewtonRaphsoncompileattempt.mws

d2u/dt2-(2*d2u/x2)+d2u/dxdt=0    

initial condition: u(x,0)=1-x, abslute x<1   Ut(x,0)=cos(pix), bslute x<1 

B.C U(-4,t)=U(4,t)=0,   delta x=0.1, delta t=0.025, range 0..4                                      

Hi all,

I have been trying to figure out why when I run my 'code' maple keeps building up memory. I am currently writing X number of inequalities and plotting the results. I begin the script with the  'restart' command to clear the memory of any previous runs. But this does nothing to the memory allocated. I check with my 'task manager' window.

I've been scouring the internet for similar issues and basically is this a software problem? how can this be avoided?

'restart' does clear the variables but doesn't seem to make the freed up memory accessible.

- pJ

What is the correct mode of using dsolve/numeric/compile with Grid package?

I've tried a lot of different, but only one turned out to be working is by using Grid:-Seq(dsolve..., i=1).

For example:

...

dsol := Grid:-Seq(dsolve(dsys, numeric, parameters = [bb, qq, prf0, `p&theta;f0`], compile = true, optimize = true, output = listprocedure, maxfun = 0), i = 1):

dsol3 := proc (tt) try dsol[3](tt) catch "cannot evaluate the solution further": tt = 0. end try end proc:

st := time[real]():

A := Array([Grid:-Seq([seq(op(2, [dsol[1](parameters = [b[i, j], q[i, j], pr[i, j], `p&theta;`[i, j]]), rhs(dsol3(-10^6))]), j = 1 .. sz[2])], i = 1 .. sz[1])]);

time[real]()-st;

example.mw

But this mode not stable and causing to this error very often:

Error, (in dsolve/numeric/SC/preproc) unable to post-link (rc=31), please try again, and if that fails check that your Windows SDK installation is up to date, and compatible with your Windows compiler

How I can fix this problem?

Hallo:

I am trying to find the inverse fourier transform given a vector (of real) as input. I get the following error message:

Error, (in DiscreteTransforms:-InverseFourierTransform) entries of input data must all evaluate to complex floats, got '[.7644453211]'

I am unable to understand this message. I would much appreciate help to resolve this issue.

Thanks

Hi all

Assume that we have following special matrix(Namely ATilde) for arbitrary vectore  z=[a0,a1,a2,a1*,a2*]:
atild.mws

and we want to use this as a general function for other arbitrary vector. is ther any way?

for example z1=[x,y,t,s,u]?

thanks for any help

best wishes

 

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department

Hi all,
can you help in that please?
How can I use this small procedure (root_of_cheb) as a sub-procedure in  the next procedure (EvalInt) ?
is it possible?

restart:
root_of_cheb:=proc(n)
   local xk,b,k:
   xk:=(k,n)->cos((2*k-1)*Pi/(2*n));
   sort([seq(evalf(xk(k,n)),k=1..n)]):
end:
EvalInt:=proc(f,n)
   local xk:
   xk:=(k,n)->cos((2*k-1)*Pi/(2*n));
   evalf((Pi/n)*add(f(xk(i,n)),i=1..n)):
end:

Thank you

Hi all,

Hope all to be in good health.

I have written following program to obtain minimum  under som constraints but it doesn't work due to some unknown error.

can any one help me?

Program1.mws

 

best wishes

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department


print(`output redirected...`); # input placeholder
   d ph                                                     
   ---- = (1 - yc) pc + yh prj + urd prd + ugd pgd - yc ph,
    dt                                                      

     d pc                        d pa               
     ---- = yc ph - (2 - yc) pc, ---- = pc ya - pf,
      dt                          dt                

     d prj                 d prd                     
     ----- = pa yrj + prj, ----- = pa yrd - prd urd,
      dt                    dt                       

     d pgd                     
     ----- = pa ygd - pgd ugd,
      dt                       

     d pf                                          
     ---- = (1 - ygd - yrj - yrd) pa + (1 - yh) prj
      dt                                           
ics := ph(0) = 1, pc(0) = 0, pa(0) = 0, prj(0) = 0, prd(0) = 0, pgd(0) = 0, pf(0) = 0;
print(`output redirected...`); # input placeholder
   ph(0) = 1, pc(0) = 0, pa(0) = 0, prj(0) = 0, prd(0) = 0,

     pgd(0) = 0, pf(0) = 0

 

i write this equations in maple

but i get this error

 

Error, (in dsolve) ambiguous input: the variables {pa, pc, pf, pgd, ph, prd, prj} and the functions {pa(0), pc(0), pf(0), pgd(0), ph(0), prd(0), prj(0)} cannot both appear in the system

can anyone help me?

 

 

with(PDEtools);
Es := 0.117108e12;
Ef := 0.78125e11;
l := 0.150e-6;
s := 0.500000e-3;
f := 0.5898334197e-6;
o := 0.9e-5;
d := 0.10e-17;
cb := 0.1e7/(19.9);
R := 8.3144621;
T := 298;





PDE := diff(u(x, t), t)-(diff(u(x, t)+o^2*Es*cb*u(x, t)^2/(9*R*T), x, x)) = 0;
IBC := {u(1, t) = 1, u(x, 0) = 0, (D[1](u))(1, t) = l*f/(d*cb)};
S := pdsolve(PDE, IBC, numeric, time = t, range = 0 .. 1, timestep = 0.1e-4, spacestep = 0.1e-6);
p1 := S:-plot(t = .1, numpoints = 100);
Error, (in pdsolve/numeric/plot) unable to compute solution for t>HFloat(0.0):
matrix is singular
p2 := S:-plot(t = .2, numpoints = 50, color = green);
Error, (in pdsolve/numeric/plot) unable to compute solution for t>HFloat(0.0):
matrix is singular
p3 := S:-plot(t = .3, numpoints = 50, color = blue);
Error, (in pdsolve/numeric/plot) unable to compute solution for t>HFloat(0.0):
matrix is singular
plots[display]({p1, p2, p3});
Error, (in plots:-display) expecting plot structures but received: {p1, p2, p3}


i have 3 equations that i need help graphing, i have tried but do not know much about maple.

the equations are x= sin u [7+cos((u/3)-2v)+2cos((u/3)+v)], y=cos u [7+cos((u/3)-2v)+2cos((u/3)+v)],

and z=sin((u/3)-2v)+2sin((u/3)+v) the limits are u from -pi to pi, and v is also from -pi to pi. please help

5 6 7 8 9 10 11 Last Page 7 of 1161