Items tagged with algorithm algorithm Tagged Items Feed

I faced a very large eigenproblem during my research. The square matrix under consideration is of size more than 2^30 times 2^30. I have tried to deal with this problem by the QR algorithm with double implicit shift (more precisely, the Francis double step QR algorithm). I'm a very beginner of programming, but I tried as follows:

--------------------------------------------------------------------------------------------------

A := Matrix([[7, 3, 4, -11, -9, -2], [-6, 4, -5, 7, 1, 12], [-1, -9, 2, 2, 9, 1], [-8, 0, -1, 5, 0, 8], [-4, 3, -5, 7, 2, 10], [6, 1, 4, -11, -7, -1]]):
H := HessenbergForm(A):
p:=6:  
for p while p>2 do: 
q:=p-1: 
s:=H(q,q)+H(p,p):  
t:=H(q,q)*H(p,p)-H(q,p)*H(p,q): 
x:=(H(1,1))^(2)+H(1,2)*H(2,1)-s*H(1,1)+t: 
y:=H(2,1)*(H(1,1)+H(2,2)-s): 
z:=H(2,1)*H(3,2): 
for k from 0 to p-3 do:  
V:=Vector([x,y,z]):   
P:=Transpose(HouseholderMatrix(1/(Norm(V+exp(argument(V(1))*I)*Norm(V,2)*Vector(3,shape=unit[1]),2))*(V+exp(argument(V(1))*I)*Norm(V,2)*Vector(3,shape=unit[1])))):   
r:=max(1,k):
H[k+1..k+3,r..6]:=MatrixMatrixMultiply(Transpose(P),SubMatrix(H,[k+1..k+3],[r..6])):  
r:=min(k+4,6):
H[1..r,k+1..k+3]:=MatrixMatrixMultiply(SubMatrix(H,[1..r],[k+1..k+3]),P):   
x:=H(k+2,k+1):
y:=H(k+3,k+1):   
if k<3 then z:=H(k+4,k+1):   
end if: 
od: 
P:=GivensRotationMatrix(Vector([x,y]),1,2): 
H[q..p,p-2..6]:=MatrixMatrixMultiply(Transpose(P),SubMatrix(H,[q..p],[p-2..6])): 
H[1..p,p-1,p]:=MatrixMatrixMultiply(SubMatrix(H,[1..p],[p-1,p]),P): 
if abs(H(p,q))<10^(-20)*(abs(H(q,q))+abs(H(p,p))) then    H(p,q):=0: p:=p-1:q=p-1:  
elif abs(H(p-1,q-1))<10^(-20)*(abs(H(q-1,q-1))+abs(H(q,q))) then    H(p-1,q-1):=0: p:=p-2:q:=p-1:  
end if:  od:
--------------------------------------------------------------------------------------------------

It seemed that replacing 0 in a Hessenberg matrix by a non-zero element is not allowed. How can I remedy this?

Plus, can anyone tell me the problem of the above thing(it's not really a programming...;( ), please?

I would also appreciate it if someone let me know a better idea for a huge eigenproblem.

Thanks in advance.

In this paper we will demonstrate the importance of using simple to complex algorithms applied to complex systems in civil and mechanical engineering. In order to develop solutions that developers need to be involved in issues of advanced dynamic computer science. We show how is that with the Maple scientific program and through component-based algorithms can generate power then then be inserted into specific algorithms. Will form patterns with movements of rotation and revolution of their axes, in each case to model and analyze the curves thereof comprising. With these modelalos and curve analysis we can predict manufacturing costs, freight, inter alia estrcturas which they can be used with the correct use of Maplesoft.

 

IX_Fast_2016.pdf

Solid_Algorithms_applied_in_complex_3D_structures_for_Civil_Engineering_with_Maplesoft.mw

(in spanish)

Lenin Araujo Castillo

 

 

 

 

Hello everbody!

Jacobi:=proc(A::Matrix,b::Vector,x,epsilon,m)  

uses LA=LinearAlgebra;  

local      i,k,n:= LA:-RowDimension(A),    

        x:= Vector(LA:-RowDimensions(A)),    

        p:= Vector(LA:-RowDimensions(A));  

k:=1;

 while  k<=n do      

       for i to n while i<>j do          

          x[i]:=1/(A[i,i])*(-add(A[i,j]*p[j],j=1..n)+b[i]);       end do;      

        if abs(x-p)<epsilon do return x; end if;    

       k:=k+1;    

       p:=x;

 end do;  

x;  

end proc:

Hello! I have written a algorithm. Can you help me find errors? thank you very much. sorry, my English is not very good!

LL:=proc(A::Matrix)
uses LA= LinearAlgebra;
local i, j, k, n:= LA:-RowDimension(A),
L:= Matrix(LA:-Dimensions(A));
L[1,1]:=sqrt(A[1,1]);
for j from 2 to n do
L[j,1]:=(A[j,1])/(L[1,1]);
end do;
for i from 2 to n-1 do
L[i,i]:=(A[i,i]-add(L[i,k]^(2),k=1..i-1))^(1/(2));
for j from i+1 to n do
L[j,i]:=(1/L[i,i])*(A[j,i]-add(L[j,k]*L[i,k],k=1..i-1));
end do;
end do;
L[n,n]:=(A[n,n]-add((L[n,k])^(2),k=1..n-1)^(1/(2));
L;

hello eveyone! sorry, my English is not very good

I writed Neville algorithm

I want to creat a table(or a matrix) Q with

example:

f:=X->2^X;

with value of X: -2,1,0,1,2

-2   1/4

-1    1/2

0    1

1    2

2     4

I want to approximate f at x=0.5 by Neville

then:   for i:=2,...,n   (that case is 5)

             for j:=2,...i

 

                  Q[i,j]=(x-X[i-j])*Q[i,j-1]-(x-X[i])*Q[i-1,j-1])/(X[i]-X[i-j])

       output(Q)

this is:

-2  1/4     0       0            0          0

-1  1/2     0.875  0           0           0

0  1         1.25   1.3475    0           0

1  2         1.5    1.4375   1.421875  0

2  4         1      1.375      1.40625  1.412109375


do you understand my mind? sorry, my English is not very good

Regards

   sunflower

f:=proc(x)
return 2^x
n:=5
M:=-2,-1,0,1,2
P:=1
for k to n+1 do
L:=1
for i to n+1 do
if i<>k then
L:=L*(x-M[i])/(M[k]-M[i]); end if; end do;
P:=P+f(M[k])*L;
end do;
I write Lagran algorithm. sorry, my english is not very good

Wonder if this can be accomplished in Maple.

so I have a list of 100 items labeled {1..100} of various value {$100, $160, $220, ......  , }

the task is to distribute these items among 3 people A,B,C so they get an approximately equal share.

Adding the values and dividing by 3 gives the dollar total to aim for. 

This post has C.Love procedure for evenly sized groups

 http://www.mapleprimes.com/questions/200480-Product-Grouping

but what i want is a method for different sized groups. ie 25 items for A, 35 for B and 40 for C (user defined).

additionally there is a fixed constraint: A has been bequeathed items 1,4,8; B items 2 and 20; C item 50.

 

restart:
S:= {3, 4, 5, 6, 8, 9, 28, 30, 35}:
SL:= [A,B,C,D,E,F,G,H,I]:
assign(Labels ~ (S) =~ SL); #Create remember table.
AllP:= [seq(P, P= Iterator:-SetPartitions(S, [[3,3]], compile= false))]:
lnp:= evalf(ln((`*`(S[]))^(1/3))):

Var:= proc(P::({list,set}(set)))
local r:= evalf(`+`(map(b-> abs(ln(`*`(b[]))-lnp), P)[]));
end proc:

Min:= proc(S::{list,set}, P::procedure)
local M:= infinity, X:= (), x, v;
     for x in S do
          v:= P(x);
          if v < M then  M:= v;  X:= x  end if
     end do;
     X
end proc:

ans:= Min(AllP, Var);
              [{3, 9, 35}, {4, 8, 28}, {5, 6, 30}]
subsindets(ans, posint, Labels);
               [{I, A, F}, {B, E, G}, {C, D, H}]

 

 

ABSTRACT. In this paper we demonstrate how the simulation of dynamic systems engineering has been implemented with graphics software algorithms using maple and MapleSim. Today, many of our researchers the computational modeling performed by inserting a piece of code from static work; with these packages we have implemented through the automation components of kinematics and dynamics of solids simple to complex.

It is very important to note that once developed equations study; recently we can move to the simulation; to thereby start the physical construction of the system. We will use mathematical and computational methods using the embedded buttons which lie in the dynamics leaves and viewing platform cloud of Maplesoft and power MapleNet for online evaluation of specialists in the area. Finally they will see some work done; which integrate various mechanical and computational concepts implemented for companies in real time and pattern of credibility.

 

Selasi_2015.pdf

(in spanish)

 

Lenin Araujo Castillo

 

 

Not homework (from the telly): A gallery takes a concave polygon shape with a square pillar in the centre. security cameras can do a 360 degree sweep but they can't see around corners. The cameras have to be attached to the walls. What is the fewest number of cameras such that they can see everywhere in the gallery?

I got as far as drawing it in Maple.

polygon_cameras.mw

there is an algorithm -which supposedly finds the optimal solutuion- breaking the object into triangular shapes. that gets an answer:  4 cameras.

EDIT 11/10

this is based on Fisk's short proof. See Markiyan's wiki ref below.

1.first stand on on a corner and scan clockwise around the room. Any two corners passed creates one triangle.

Repeat for every corner

 

2. Pick three colours and allocate each color to each corner of each triangle.

sometimes you will end up with a triangle which has 2 corners of the same colour. This one has two blue corners

 

This triangle must be broken in two and add a green dot

3.finally the algorithm places cameras on the colour which occurs least.

But by experimenting with more complex shapes (convex polygons) you can cover the gallery with 3.

 

In Maple anyone?

 

Hello everyone, 

 

I'm currently taking a Chaos and Fractal Geometry class that did not have a pre-req of computer programming or knowledge of Maple, but I am apparently the only person in the class who has not taken a class/does not have this knowledge so my professor really flew by teaching the material. My sob story aside, I was hoping you great people would be able to help me out with (what are apparently) really basic procedures and plots while I try to read up on how to actaully do it myself (if anyone has a good supplement to recommend, I'm all ears!). Anyway, here are the one's that I'm stumped on:

  • "Write a Maple proc L that takes as input two lists and returns as output a set containing the terms they have in common (not necessarily in the same position). For example, L([1, 3, x, 5],[2, x, 5, 2, 1, 8]) should return [1, x, 5]."
    I'm thinking this is going to use some form of the intersection command, but I cannot for the life of me figure out how to set up the syntax
  • "Write a Maple program that implements the Euclidean algorithm to compute the gcd(x, y) for any natural numbers x, y (except x = y = 0). Your program should not just compute the gcd, but should do so by implementing the Euclidean algorithm directly (i.e. proc(x,y) RETURN(gcd(x,y)) end; is not what I am looking for here! :) )."
    If only he would've let me do the easy one :(
  • "Write a Maple program to plot the Pythagorean spiral. The program should take a single positive integer n as an argument and plot the spiral until the side of length n is reached"
    Not even a clue on how to approach this one. 

 

Thanks again to any and all help/recommendations you can make. I really appreciate it!

Bubble := proc (X::list)

local n, i, j, t;

n := nops(X);

if n = 0 then ERROR("empty list") end if;

for i to n-1 do

   for j to n-i do

      if X[j+1] < X[j] then

          t := X[j];

          X[j] := X[j+1];

          X[j+1] := t;

      end if;

   end do;

end do;

print(X);

end proc

 

I make bubble sort algorithm. but i can't find 'illegal use of a formal parameter'.

I want to test linearly dependence of a polynomial f on a list of polynomials F by additional condition on parametric coefficients of linear parametric polynomial (linear for variables not parameters). Please note that:

  1. The polynomialand the members of are always homogenous in the variables.
  2. The coefficients of f, the coefficients of the members of F are all always polynomials in the parameters or contant and the members of N and W are all always polynomials in the parameters.

 

For example let

and

(a,b,c,d,e,h are parameters and A1,A2,A3 are variables).

If I use PolyLinearCombo(F,f,{A1,A2,A3}) (see http://www.mapleprimes.com/questions/204469-How-Can-I-Find-The-Coefficients-Of-Linear#comment217621)then its output is false,[].

Now we let to condition sets for parameters as the following:

N:=[ebc+ahd]

W:=[a,c]

The elements of N must be zero means that ebc+ahd=0

and the elements of W are non-zero that is a<>0 and c <>0.

Let a=b=c=d=h=1 and e=-1. This specialization satisfy in the above condition sets N and W. By this specialization we have:

and

Now if I use PolyLinearCombo(F,f,{A1,A2,A3}) then its output is true,[-1,1].

By this additional two condition sets I have to check that whether f is linearly independent of F or not. How can I do this without specialization? In fact I want an algorithm that its input is (null condition N, not-null condition W, list of polynomials F, a polynomial f, the set of variables) and its output is true and coefficients if f is linearly dependent of F w.r.t. null and not-null conditions N and W, else its output is false.

If the name of new procedure is ExtPolyLinearCombo and 

N:=[ebc+ahd]

W:=[a,c]

I want the output of

ExtPolyLinearCombo(N,W,F,f,{A1,A2,A3}) be true,[coefficients]

Thank you very much in advance.

 

 

Hi all,

Please help in writing finite difference algorithm for a nonlinear PDE using Maple.

for a[j], b[j] known at time n, I want to compute A[j]  for a[j] at time n+1 according to the equation below

EQs:=A[j]-theta*tau*(A[j-1]-2*A[j]+A[j+1])=a[j]+sqrt(a[j])*b[j]*h^2/tau+(1-theta)*tau*(a[j-1]-2*a[j]+a[j+1]) ;

Thanks in advance.

I am trying to understand how maple "isprime" algorithm works. But I can't find anywhere what special_primes means.

 

 showstat(isprime);

isprime := proc(n)
local btor, nr, p, r;
   1   if not type(n,'integer') then
   2     if type(n,('complex')('numeric')) then
   3       error "argument must be an integer"
         else
   4       return 'isprime(n)'
         end if
       end if;
   5   if n < 2 then
   6     return false
       elif member(n,isprime:-special_primes) then
   7     return true
       elif igcd(2305567963945518424753102147331756070,n) <> 1 then
   8     return false
       elif n < 10201 then
   9     return true
       elif igcd(8496969489233418110532339909187349965926062586648932736611545426342203893270769390909069477309509137509786917118668028861499333825097682386722983737962963066757674131126736578936440788157186969893730633113066478620448624949257324022627395437363639038752608166758661255956834630697220447512298848222228550062683786342519960225996301315945644470064720696621750477244528915927867113,n) <> 1 then
  10     return false
       elif n < 1018081 then
  11     return true
       else
  12     r := gmp_isprime(n);
  13     if not r or n <= 5000000000 then
  14       return r
         end if;
  15     nr := igcd(408410100000,n-1);
  16     nr := igcd(nr^5,n-1);
  17     r := iquo(n-1,nr);
  18     btor := modp(('power')(2,r),n);
  19     if cyclotest(n,btor,2,r) = false or irem(nr,3) = 0 and cyclotest(n,btor,3,r) = false or irem(nr,5) = 0 and cyclotest(n,btor,5,r) = false or irem(nr,7) = 0 and cyclotest(n,btor,7,r) = false then
  20       return false
         end if;
  21     if isqrt(n)^2 = n then
  22       return false
         end if;
  23     for p from 3 while numtheory:-jacobi(p^2-4,n) <> -1 do
  24       NULL
         end do;
  25     return evalb(TraceModQF(p,n+1,n) = [2, p])
       end if
end proc

1 2 3 4 5 6 Page 1 of 6