Jabz

433 Reputation

5 Badges

15 years, 340 days

MaplePrimes Activity


These are answers submitted by Jabz

Thank u everyone who posted a reply i a,m very grateful 4 ur assistance

restart:
n:=3:
s:=Matrix([[5,2,-1],[3,7,3],[-1,-4,6]]);
b:=[2,-1,1];

X:=[0,0,0];
Itr:=0:
while Itr > 0.01 do
su:=0:
for i from 1 to n do
for j from 1 to n do
if i <> j then
su:=su + s[i,j]*X[j];
fi:
od;

X[i]:=(b[i]-su)/s(i,i);

od;
Itr:=Itr + 1;
end do;
 

 

 

Without Itr (Iteration) this is what the program produces:
 

restart:
n:=3:
s:=Matrix([[5,2,-1],[3,7,3],[-1,-4,6]]);
b:=[2,-1,1];

X:=[0,0,0];

su:=0:
for i from 1 to n do
for j from 1 to n do
if i <> j then
su:=su + s[i,j]*X[j];
fi:
od;

X[i]:=(b[i]-su)/s(i,i);

od;
 

                                      X1:=2/5

 

                                    X2=-11/35

 

                                   X3:= -37/210
                                  

The X1 value is correct  but the X2 & X3 values are not. I need help in succesfully getting the method to work for all values. When i remove the 'Itr' from my code and set i=j I get the following:


restart:
n:=3:
s:=Matrix([[5,2,-1],[3,7,3],[-1,-4,6]]):
b:=[2,-1,1]:
N:=5:
X:=[0,0,0];

su:=0:
for i from 1 to n do
for j from 1 to n do
if i = j then
su:=su + (s[i,j]*X[j]);
fi:
od;

X[i]:=(b[i]-su)/s(i,i);
od;

end do;



                            X:=     [0, 0, 0]


                            X1:=2/5

                            X2:=-1/7

                            X3:=1/6
 

These answers are correct but i cant get the program to do a loop. They are the first iteration values. {please Sm1 help}

 

Thanx for ur help Joe and pagan much appriciated.

oh yh x,y,z represents numbers 2,3,7. 
 

i hav tried doing but it dont work am really stuck

for a from 1 to 100 do
    if a:= a / 2 or a/3
        then     print(null)
   else     print(a)
   end if;
od;

How do i open the file as letters (not ascii numbers)?


restart:
outputfile:="C:\\Users\\x\\Desktop\\test3.txt":
with(FileTools[Text]):
ReadLine(outputfile);

                         "[104, 101, 108, 108, 111]"

 

convert(%,bytes);

 

                                        [91, 49, 48, 52, 44, 32, 49, 48, 49, 44, 32, 49, 48, 56, 44, 32, 49, 48, 56,44, 32, 49, 49, 49, 93]

 

but

convert([104,101,108,108,111],bytes);

                                   "hello"

 

These are the  question i was asked

Q.1. Write a procedalure that takes a list of characters as input and returns a corresponding list of ASCII values as output

Q.2.i)Write a prcedure that takes as its 3 inputs 2 positive integers a and b and a list of numbers. Each element of the returned list should consist of the corresponding element of the input list, raised to the power of b and taken modulo a.

Q2. ii) Check that if your procedure is used to encrypt a list of numbers with parameters a=33 and b= 3 and then encrypt the result with parameters a=33 and b=3, the final list matches the original list.

 

Thank you

Hi all the discussions above have procedures.

Is it possible to code in Newton's Method without using procedures?

1 2 Page 2 of 2