Items tagged with exact


ans := dsolve(eq);

I thought I would share some code for computing sparse matrix products in Maple.  For floating point matrices this is done quickly, but for algebraic datatypes there is a performance problem with the builtin routines, as noted in

Download spm.txt

The code is fairly straightforward in that it uses op(1,A) to extract the dimensions and op(2,A) to extract the non-zero elements of a Matrix or Vector, and then loops over those elements.  I included a sparse map function for cases where you want to map a function (like expand) over non-zero elements only.

# sparse matrix vector product
spmv := proc(A::Matrix,V::Vector)
local m,n,Ae,Ve,Vi,R,e;
n, m := op(1,A);
if op(1,V) <> m then error "incompatible dimensions"; end if;
Ae := op(2,A);
Ve := op(2,V);
Vi := map2(op,1,Ve);
R := Vector(n, storage=sparse);
for e in Ae do
n, m := op(1,e);
if member(m, Vi) then R[n] := R[n] + A[n,m]*V[m]; end if;
end do;
return R;
end proc:
# sparse matrix product
spmm := proc(A::Matrix, B::Matrix)
local m,n,Ae,Be,Bi,R,l,e,i;
n, m := op(1,A);
i, l := op(1,B);
if i <> m then error "incompatible dimensions"; end if;
Ae := op(2,A);
Be := op(2,B);
R := Matrix(n,l,storage=sparse);
for i from 1 to l do
Bi, Be := selectremove(type, Be, (anything,i)=anything);
Bi := map2(op,[1,1],Bi);
for e in Ae do
n, m := op(1,e);
if member(m, Bi) then R[n,i] := R[n,i] + A[n,m]*B[m,i]; end if;
end do;
end do;
return R;
end proc:
# sparse map
smap := proc(f, A::{Matrix,Vector})
local B, Ae, e;
if A::Vector then
B := Vector(op(1,A),storage=sparse):
B := Matrix(op(1,A),storage=sparse):
end if;
Ae := op(2,A);
for e in Ae do
B[op(1,e)] := f(op(2,e),args[3..nargs]);
end do;
return B;
end proc:

As for how it performs, here is a demo inspired by the original post.

n := 674;
k := 6;
A := Matrix(n,n,storage=sparse):
for i to n do
  for j to k do
    A[i,irem(rand(),n)+1] := randpoly(x):
  end do:
end do:
V := Vector(n):
for i to k do
  V[irem(rand(),n)+1] := randpoly(x):
end do:
C := CodeTools:-Usage( spmv(A,V) ):  # 7ms, 25x faster
CodeTools:-Usage( A.V ):  # 174 ms
B := Matrix(n,n,storage=sparse):
for i to n do
  for j to k do
    B[i,irem(rand(),n)+1] := randpoly(x):
  end do:
end do:
C := CodeTools:-Usage( spmm(A,B) ):  # 2.74 sec, 50x faster
CodeTools:-Usage( A.B ):  # 2.44 min
# expand and collect like terms
C := CodeTools:-Usage( smap(expand, C) ):

I try to find the exact (symbolic) value of


I tried 'simplify' with different options and 'convert'. It would be pi=3.141... as numerical approximation suggests.

Many thanks.

EF.3.mwHi, I want to ask that how to find the exact solution of equation without applying any technique


Good day.

How to avoid float(undefined) for v3, v4,v5 in this problem.

Thank you in advance.







where, A1, A2, A3, L, S are all constants.

i get an exact solution but is there any way around to get a more compact solution?



hey friends am stuck with some code. My code is correct and am trying to find exact solution but not able to see output. Please kindly check it and let me know

hi friends am using maple 13 which is unable to find exact solutions for pdes

because for exact solution i should have maple 15 but am not able to install that so please can anyone of u can find exact sloution for me of the pde

pde := diff(U(x, y), x, x)-3*(diff(U(x, y), y, y))+16 = 0 where boundary conditions are

U=0 on x=1,-1

U=0 on x=1,-1

diff(U(x, y), y) = -U on y=1, -1< x

diff(U(x, y), y) = U on y=-1, -1< x

Can we find exact solution of PDE with help of maple?

If it is yes the please let me how to write commands for parabolic pde 

ut=k uxx with boundary conditions u(0,t)=u(l,t)=0 and initial condition u(x,0)=e-x



> eq1:=n=(k[f1]^3+k[f2]^3)/6/Pi^2;

> eq2:=e*V=h_bar^2/2/m*(k[f2]^2-k[f1]^2);

> solve({eq1,eq2},{k[f1],k[f2]});

in the final command i get a very messy numerical&symbolic results like

{k[f1] = 1016612041.*


I am usign dsolve for maple to give my a fuction z(t) . Maple solves the differential equation but i want maple to give me the exact number for specific t values z(60) and so on. But maple is given as an answer z(60) and not a number 

Can someone help me to generate the same, identical grpah over several periods in x-axis? In exact term, I mean that I need to plot a periodical grpah, that repeats itself over the interval? It is like given a periodical function and now have to draw it many times...(function can be any form, not only sine and cosine)

Like when I type


it gives


but if I type


it gives


I want it to consider 0.5 as 1/2, because sometimes I make computations on large equations and I want to have access to the symbolic output, not the numeric output.

Page 1 of 1