Unanswered Questions

This page lists MaplePrimes questions that have not yet received an answer

 

For many years I succesfully used the command:

Lambda := ImportMatrix(LambdaFile, delimiter = "", datatype = string);

 

but for some txt files I now got the following error in Maple 2016:
Error, (in ImportMatrix) cannot interpret file

The same code still runs without problems at all in previous versions of Maple.

The strange thing is that other txt files can be still be imported in Maple 2016 without problems.

I will upload two files:

ULSlx3.txt returns an error message

ULStd3.txt no problems

ULSlx3.txt

ULStd3.txt

complete code:

restart;
with(LinearAlgebra); with(Statistics);
interface(rtablesize = infinity);
with(Typesetting):
interface(typesetting=extended):

LambdaFile := "C:/path/ULSlx3.txt";
Lambda := Matrix(5, 1);

in the whatsnew there is no information on changes with respect to the ImportMatrix command, although there is some (unrelated) information on Importing Data:

Importing Data
By default, the Import command now returns a DataFrame when importing from Excel, CSV, DIF, and TSV file formats, and returns a DataSeries when importing from ODS, SXC, and TSV file formats. Use the output option to specify a different format. For example, Import(origin, output=Matrix).

 

I have no clue what is wrong with my code and why some text files can be imported as before whereas other files returns an error message.

greetings Harry

In using Maple there are many ways to complete a command on a function. Using shortcuts in the worksheet/document you can enter the command on the line rather than using the drop down menus or clickable math menu.  I would like to see what the shortcut command are for the packages in Maple.  There are so many, I am using the LinearAlgebra package and have seen Dr. Lopez use " ||A||2 to determine the Euclidean Norm of A.  But where does this use get described in the help or examples of other shortcut usage for Maple. I've seen the shortcut commands for Documents in General, but the use of shortcut commands for other packages  don't seem to discuss the usage of such shortcuts.

Is there a document that documents these shortcuts.

 

I am curious, can simplify/siderels be executed in mod p by some equivalent Maple function call?

 

With the following equation

eqn:=y=1/2+(1/2)*erf((1/2)*sqrt(2)*(x-mu)/sigma)-exp(-lambda*(x-mu)+(1/2)*lambda^2*sigma^2+ln(1/2-(1/2)*erf((1/2)*sqrt(2)*(lambda^2*sigma^2-lambda*(x-mu))/(lambda*sigma))));

and with

x:=solve(eqn,x) assuming sigma > 0, lambda > 0;

I got the following solution

x := -(1/2)*(-lambda^2*sigma^2-2*lambda*mu+2*RootOf(-exp(_Z)*erf((1/4)*sqrt(2)*(lambda^2*sigma^2+2*_Z)/(lambda*sigma))+exp(_Z)+erf((1/4)*sqrt(2)*(-lambda^2*sigma^2+2*_Z)/(lambda*sigma))+2*y-1))/lambda;

In order to get rid of RootOf I gave the command:

allvalues(%);

However, RootOf did not disappear. How should I proceed? 

 

hi

if possible to convert matlab file in to maple fie program??convert_to_maple_program.txt

thanks

 

this is the matlab is it possible to rewrite it in simple maple code

J = rand()+1e-10;

function [M, num, E] = ising(N,J)

B = 0;

M = []; % The total magnetic field of the system

E = []; % The total energy of the system

randTol = 0.1; % The tolerance, dampens the spin flip process

% First we generate a random initial configuration

spin = (-1).^(round(rand(N)));

% Then we let the system evolve for a fixed number of steps

for i=1:1000,

% Calculating the total spin of neighbouring cells

neighbours = circshift(spin, [ 0 1]) + ...

circshift(spin, [ 0 -1]) + ...

circshift(spin, [ 1 0]) + ...

circshift(spin, [-1 0]);

% Calculate the change in energy of flipping a spin

DeltaE = 2 * (J*(spin .* neighbours) + B*spin);

% Calculate the transition probabilities

p_trans = exp(-DeltaE);

% Decide which transitions will occur

transitions = (rand(N) < p_trans ).*(rand(N) < randTol) * -2 + 1;

% Perform the transitions

spin = spin .* transitions;

% Sum up our variables of interest

M = sum(sum(spin));

E = -sum(sum(DeltaE))/2; % Divide by two because of double counting

% Display the current state of the system (optional)

image((spin+1)*128);

xlabel(sprintf('J = %0.2f, M = %0.2f, E = %0.2f', J, M/N^2, E/N^2));

set(gca,'YTickLabel',[],'XTickLabel',[]);

axis square; colormap bone; drawnow;

end

% Count the number of clusters of 'spin up' states

[L, num] = bwlabel(spin == 1, 4);

############################# 

hi.please help me for remove error'' 

Error, illegal use of an object as a name''

 

thanks

PLATE.mw

   

Parse:-ConvertTo1D, "first argument to _Inert_ASSIGN must be assignable"

Error, illegal use of an object as a name

"restart:Digits :=15: beta:=10:alpha:=100: xi:=.5: upsilon:=0.2841945289:n:=3: aa:=1:b:=1:N_x:=0.4:N_y:=0.4:N_xy:=0: hl2:=1:mu:=65.8e9:E:=169e9: delta0:=1:delta1:=1: mus:=3:D1:=2;h:=1: lambda:=0.1: D2:=5:A1:=-2:A2:=-2:A3:=-6:A4:=7:A5:=7:A6:=7:A7:=7:A8:=8:A9:=7:A10:=7:A11:=1: A12:=1:tau:=4.730040745:t:=0: g2:=sin(theta):g3:=cos(theta):g1:=cos(theta):a:=0.0:with(Student[Calculus1]): a1:=evalf((A1*ApproximateInt(g3^2,theta=a..1,method=simpson)  ) ) : a2:= evalf(A2*ApproximateInt(g3*((&DifferentialD;)^2)/((&DifferentialD;theta)^2)g3,theta=a..1,method=simpson)): a3:=evalf(A3*ApproximateInt(g3*g3,theta=a..1,method=simpson)) : a4:=evalf(A4*ApproximateInt(g3*g3,theta=a..1,method=simpson)) :a5:=evalf(A5*ApproximateInt(g3^2,theta=a..1,method=simpson)) : a6:=evalf(A6*ApproximateInt(((&DifferentialD;)^2)/((&DifferentialD;theta)^2)g3*g3,theta=a..1,method=simpson)) :a7:=evalf(A7*ApproximateInt(g3*g3,theta=a..1,method=simpson)): a8:=evalf(A8*ApproximateInt(g3^2,theta=a..1,method=simpson)):a9:=evalf(ApproximateInt(A9*(g3*g3 )     ,theta=a..1,method=simpson)) :a10:=evalf(A10*ApproximateInt(g3*g3,theta=a..1,method=simpson)):a11:=evalf(ApproximateInt(1,theta=a..1,method=simpson)):a12:=evalf(ApproximateInt(1*(1-1/2 (1)),theta=a..1,method=simpson)):dsys3 := { f3(x)*(a1)+ f3(x)*(a2)  +((&DifferentialD;)^2)/((&DifferentialD;x)^2) f3(x)*(a3) +f3(x)*a4+ f3(x)*(a5) +((&DifferentialD;)^2)/((&DifferentialD;x)^2) f3(x)*(a6) +f3(x)*a7= ((&DifferentialD;)^2)/((&DifferentialD;x)^2) f3(x) *(a8)   + a9*(&DifferentialD;)/(&DifferentialD;x) f3(x) +f3(x)*a10+ a11+a12  , f3(1) =0,f3(0) =0 , D^(1)(f3)(1) = 0, D^(1)(f3)(0)=0,D^(3)(f3)(1) = 0, D^(3)(f3)(0)=0}    :dsol5 := dsolve(dsys3, 'maxmesh'=2024, numeric,abserr=.0001, range=0..1, output=listprocedure):fy3:= eval(f3(x),dsol5):with(CurveFitting):fy33:=PolynomialInterpolation([[0,fy3(0)],[.1,fy3(0.1)],[.2,fy3(0.2)],[0.3,fy3(0.3)],[.4,fy3(0.4)],[.5,fy3(0.5)],[0.6,fy3(0.6)],[0.7,fy3(0.7)],[0.8,fy3(0.8)],[0.9,fy3(0.9)],[1,fy3(1)]],x): d1:=A1*ApproximateInt(((&DifferentialD;)^6)/((&DifferentialD;x)^6)fy33*fy33,x=a..1,method=simpson)   :d2:= A2*ApproximateInt(((&DifferentialD;)^4)/((&DifferentialD;x)^4)fy33*fy33 ,x=a..1,method=simpson)   :d3:=A3*ApproximateInt(((&DifferentialD;)^2)/((&DifferentialD;x)^2)fy33*fy33,x=a..1,method=simpson): d4:= A4*ApproximateInt(fy33*fy33,x=a..1,method=simpson):d5:=A5*ApproximateInt(((&DifferentialD;)^4)/((&DifferentialD;x)^4)fy33*fy33,x=a..1,method=simpson)  : d6:=A6*ApproximateInt(((&DifferentialD;)^2)/((&DifferentialD;x)^2)fy33*fy33,x=a..1,method=simpson)    :d7:=A7*ApproximateInt(fy33*fy33,x=a..1,method=simpson)  :d8:=A8*ApproximateInt(((&DifferentialD;)^2)/((&DifferentialD;x)^2)fy33*fy33,x=a..1,method=simpson)      :d9:=ApproximateInt(A9*(((&DifferentialD;)^1)/((&DifferentialD;x)^1)fy33*fy33 )   ,x=a..1,method=simpson) :d10:=A10*ApproximateInt(fy33*fy33,x=a..1,method=simpson)    :d11:=evalf(ApproximateInt(1,theta=a..1,method=simpson)):d12:=evalf(ApproximateInt(1*(1-1/2 (1)),theta=a..1,method=simpson))  : d sys4 := { h3(theta)*(d1)+((&DifferentialD;)^2)/((&DifferentialD;theta)^2) h3(theta)*(d2)+((&DifferentialD;)^4)/((&DifferentialD;theta)^4) h3(theta)*(d3)+ ((&DifferentialD;)^6)/((&DifferentialD;theta)^6) h3(theta)*(d4)+h3(theta) *(d5)+ h3(theta) *(d6) +((&DifferentialD;)^4)/((&DifferentialD;theta)^4) h3(theta)*(d7)= h3(theta)*(d8)  +d9*(&DifferentialD;)/(&DifferentialD;theta) h3(theta)  +((&DifferentialD;)^2)/((&DifferentialD;theta)^2) h3(theta)*(d10)  +d11+d12   ,h3(1) = 0,h3(0) = 0 , D^(1)(h3)(1) = 0, D^(1)(h3)(0)=0,D^(3)(h3)(1) = 0, D^(3)(h3)(0)=0}  :dsol6 := dsolve(dsys4, 'maxmesh'=2024, abserr=.0001, range=0..1, numeric, output=listprocedure):g33:= eval(h3(theta),dsol6):with(CurveFitting):g3:=PolynomialInterpolation([[0,g33(0)],[.1,g33(0.1)],[.2,g33(0.2)],[0.3,g33(0.3)],[.4,g33(0.4)],[.5,g33(0.5)],[0.6,g33(0.6)],[0.7,g33(0.7)],[0.8,g33(0.8)],[0.9,g33(0.9)],[1,g33(1)]],theta):"

 

 

``

 

Download PLATE.mw

Hi

Hope a nice day for all

restart;

#  *%   define the product of between two operators, and q real number
a*%b = q*b*%a+1;

# First I would like to give a simple for

 a^n*%b;
# and                                    
a*%b^n;

them deduce a general for                                      

b^n*%a^k*%b^N*%a^K-q^(k*N-n*K)*b^N*%a^K*%b^n*%a^k;

 where n, k and k greater than 1 and  n geater than k

Simplification.mw

 

Thanks for your help


 


How can i over come convergence error, i am unable to apply approxsoln appropriately and continouation as well. regards

N := 5;

-(1/2)*Pr*n*x*(diff(f(x), x))*(diff(theta(x), x))-(1/2)*Pr*(n+1)*f(x)*(diff(theta(x), x))-(1/2)*(n+1)*(diff(diff(theta(x), x), x))+Pr*gamma*((1/4)*(n^2-3*n+3)*x^2*(diff(f(x), x))*(diff(diff(f(x), x), x))*(diff(theta(x), x))+(1/4)*(2*n^2+5*n+3)*f(x)*(diff(f(x), x))*(diff(theta(x), x))+(1/4)*n(n+1)*x*f(x)*(diff(diff(f(x), x), x))*(diff(theta(x), x))+(1/4)*(2*n^2+3*n-3)*x*(diff(f(x), x))^2*(diff(theta(x), x))+(1/4)*(n-1)*x^2*(diff(diff(f(x), x), x))*(diff(theta(x), x))+(1/2)*n*(n+1)*x*f(x)*(diff(f(x), x))*(diff(diff(theta(x), x), x))+(1/4)*(n^2-1)*(diff(f(x), x))^2*(diff(theta(x), x))+(1/4)*(n+1)^2*f(x)^2*(diff(diff(theta(x), x), x))+(1/4)*(n-1)^2*x^2*(diff(f(x), x))^2*(diff(diff(theta(x), x), x))) = 0

(1)

bc := (D(theta))(0) = -Bi*(1-theta(0)), theta(N) = 0, f(0) = 0, (D(f))(0) = 0, (D(f))(N) = 1;

(D(theta))(0) = -Bi*(1-theta(0)), theta(5) = 0, f(0) = 0, (D(f))(0) = 0, (D(f))(5) = 1

(2)

a1 := dsolve(subs(beta = .1, n = .5, Pr = 10, gamma = .1, Bi = 50, {bc, eq1, eq2}), numeric, method = bvp[midrich], abserr = 10^(-8), output = array([seq(.1*i, i = 0 .. 10*N)]))

Error, (in dsolve/numeric/BVPSolve) initial Newton iteration is not converging

 

``

 

Download ehtasham.mwehtasham.mw

Dear All

Using Lie algebra package in Maple we can easily find nilradical for given abstract algebra, but how we can find all the ideal in lower central series by taking new basis as nilradical itself?

Please see following;

 

with(DifferentialGeometry); with(LieAlgebras)

DGsetup([x, y, t, u, v])

`frame name: Euc`

(1)
Euc > 

VectorFields := evalDG([D_v, D_v*x+D_y*t, 2*D_t*t-2*D_u*u-D_v*v+D_y*y, t*D_v, D_v*y+D_u, D_t, D_x, D_x*t+D_u, 2*D_v*x+D_x*y, -D_t*t+2*D_u*u+2*D_v*v+D_x*x, D_y])

[_DG([["vector", "Euc", []], [[[5], 1]]]), _DG([["vector", "Euc", []], [[[2], t], [[5], x]]]), _DG([["vector", "Euc", []], [[[2], y], [[3], 2*t], [[4], -2*u], [[5], -v]]]), _DG([["vector", "Euc", []], [[[5], t]]]), _DG([["vector", "Euc", []], [[[4], 1], [[5], y]]]), _DG([["vector", "Euc", []], [[[3], 1]]]), _DG([["vector", "Euc", []], [[[1], 1]]]), _DG([["vector", "Euc", []], [[[1], t], [[4], 1]]]), _DG([["vector", "Euc", []], [[[1], y], [[5], 2*x]]]), _DG([["vector", "Euc", []], [[[1], x], [[3], -t], [[4], 2*u], [[5], 2*v]]]), _DG([["vector", "Euc", []], [[[2], 1]]])]

(2)
Euc > 

L1 := LieAlgebraData(VectorFields)

_DG([["LieAlgebra", "L1", [11]], [[[1, 3, 1], -1], [[1, 10, 1], 2], [[2, 3, 2], -1], [[2, 5, 4], 1], [[2, 6, 11], -1], [[2, 7, 1], -1], [[2, 8, 4], -1], [[2, 9, 5], -1], [[2, 9, 8], 1], [[2, 10, 2], 1], [[3, 4, 4], 3], [[3, 5, 5], 2], [[3, 6, 6], -2], [[3, 8, 8], 2], [[3, 9, 9], 1], [[3, 11, 11], -1], [[4, 6, 1], -1], [[4, 10, 4], 3], [[5, 10, 5], 2], [[5, 11, 1], -1], [[6, 8, 7], 1], [[6, 10, 6], -1], [[7, 9, 1], 2], [[7, 10, 7], 1], [[8, 9, 4], 2], [[8, 10, 8], 2], [[9, 10, 9], 1], [[9, 11, 7], -1]]])

(3)
Euc > 

DGsetup(L1)

`Lie algebra: L1`

(4)
L1 > 

MultiplicationTable("LieTable"):

L1 > 

N := Nilradical(L1)

[_DG([["vector", "L1", []], [[[1], 1]]]), _DG([["vector", "L1", []], [[[2], 1]]]), _DG([["vector", "L1", []], [[[4], 1]]]), _DG([["vector", "L1", []], [[[5], 1]]]), _DG([["vector", "L1", []], [[[6], 1]]]), _DG([["vector", "L1", []], [[[7], 1]]]), _DG([["vector", "L1", []], [[[8], 1]]]), _DG([["vector", "L1", []], [[[9], 1]]]), _DG([["vector", "L1", []], [[[11], 1]]])]

(5)
L1 > 

Query(N, "Nilpotent")

true

(6)
L1 > 

Query(N, "Solvable")

true

(7)

Taking N as new basis , how we can find all ideals in lower central series of this solvable ideal N?

 

Download [944]_Structure_of_Lie_algebra.mw

Regards

I have Maple 2016 on Ubuntu 16.04.  I get an error message when attempting to plot with an x11 device, that means I have missing fonts.

I do not get this error message on Ubuntu14.04, so, I think the difference is in fonts installed.

plotsetup(x11)

> plot([sin(x),cos(x)],x=-Pi..Pi);
> Maple X driver failure:BadName (named color or font does not exist)Warning: Cannot convert string "-adobe-helvetica-bold-r-normal--14-*" to type FontStruct
Warning: Cannot convert string "-adobe-helvetica-medium-r-normal--14-*" to type FontStruct

I have xfonts-100dpi and xfonts-75dpi installed.

Any idea what fonts I need to fix this?

 

Tom Dean

i'm using maple in a research but i want to add a recursive function h_m(t) in 2 case : if m is integer positive and not, 
la formule est donnée comme suit :  if (mod(m,1) = 0  and m>0) then  h:=proc(m,t)  local  t ;  h[0,t]:=t ;   for  i from -4 to  m  by  2 do  h [m,t]:= h[0, t]-(GAMMA(i/(2)))/(2*GAMMA((i+1)/(2)))*cos(Pi*t)*sin(Pi*t)  od:  fi:  end; 
  if (mod(m,1) = 0  and m>0) then  h:=proc(m,t)  local  t ;  h[0,t]:=t ;   for  i from -4 to  m  by  2 do  h [m,t]:= h[0, t]-(GAMMA(i/(2)))/(2*GAMMA((i+1)/(2)))*cos(Pi*t)*sin(Pi*t)  od:  fi:  end;
and i wanna to know how to programmate a Gaus Hypegeometric function. Thank You

 

Hi

We know determinant of a square matrix A[ij] (i,j ∈ {1,2,3}) is equal to the following expression

det(A) = 1/6 * e[ijk] * e[pqr] * A[ip] * A[jq] * A[kr] 

in which e[ijk] is a third order Tensor (Permutation notation or Levi-Civita symbol) and has a simple form as follows:

e[mnr] = 1/2 * (m-n) * (n-r) * (r-m).

The (i,j) minor of A, denoted Mij, is the determinant of the (n − 1)×(n − 1) matrix that results from deleting row i and column j of A. The cofactor matrix of A is the n×n matrix C whose (i, j) entry is the (i, j) cofactor of A,

C[ij]= -1 i+j * M[ij]

A-1=CT/det(A)

The general form of Levi-Civita symbol is as bellow:

 

I want to write a program for finding inverse of (NxN) matrix:

N=2 →

restart;
N := 2:
with(LinearAlgebra):
f := (1/2)*(sum(sum(sum(sum((m-n)*(p-q)*A[m, p]*A[n, q], q = 1 .. 2), p = 1 .. 2), n = 1 .. 2), m = 1 .. 2)):
A := Matrix(N, N, proc (i, j) options operator, arrow; evalf((37*i^2+j^3)/(2*i+4*j)) end proc):
f/Determinant(A);

N=3 →

restart;
N := 3:
with(LinearAlgebra):
f := (1/24)*(sum(sum(sum(sum(sum(sum((m-n)*(n-r)*(r-m)*(p-q)*(q-z)*(z-p)*A[m, p]*A[n, q]*A[r, z], m = 1 .. N), n = 1 .. N), r = 1 .. N), p = 1 .. N), q = 1 .. N), z = 1 .. N)):
A := Matrix(N, N, proc (i, j) options operator, arrow; 10*i^2/(20*i+j) end proc):
f/Determinant(A);

The results of above programs are equal to 1 and validation of method is observed.

If we can write the general form of determinant then we can find the inverse of any square non-singular matrices.

Now I try to write the mentioned program.

restart;
with(linalg):
N := 7:
Digits := 40:
e := product(product(signum(a[j]-a[i]), j = i+1 .. N), i = 1 .. N):
ML := product(A[a[k], b[k]], k = 1 .. N):
s[0] := e*subs(`$`(a[q] = b[q], q = 1 .. N), e)*ML:
for i to N do
s[i] := sum(sum(s[i-1], a[i] = 1 .. N), b[i] = 1 .. N)
end do:
A := Matrix(N, N, proc (i, j) options operator, arrow; evalf((3*i+j)/(i+2*j)) end proc): # arbitrary matrix
CN:=simplify(s[N]/det(A));

Therefore det(A)= CN-1 * e[a1,a2,..an] * e [b1,b2,.., bn] * A[a1,b1] * A[a2,b2] * ... * A[an,bn].

The correction coefficient is CN(for N)/CN(for N-1) = N!/(N-1)! =N.

restart:
with(linalg): N := 4: Digits := 20:
e := product(product(signum(a[j]-a[i]), j = i+1 .. N), i = 1 .. N):
ML := product(A[a[k], b[k]], k = 1 .. N):
s[0] := e*subs(`$`(a[q] = b[q], q = 1 .. N), e)*ML:
for r to N do s[r] := sum(sum(s[r-1], a[r] = 1 .. N), b[r] = 1 .. N) end do:
A := Matrix(N, N, proc (i, j) options operator, arrow; evalf((3*i+2*j)/(i+2*j)) end proc):
DET:=S[N]:
for x to N do for y to N do
e := product(product(signum(a[j]-a[i]), j = i+1 .. N-1), i = 1 .. N-1):
ML := product(AA[a[k], b[k]], k = 1 .. N-1):
S[0, x, y] := e*subs(`$`(a[q] = b[q], q = 1 .. N-1), e)*ML:
for r to N-1 do S[r, x, y] := sum(sum(S[r-1, x, y], a[r] = 1 .. N-1), b[r] = 1 .. N-1) end do:
f[y, x] := (-1)^(x+y)*subs(seq(seq(AA[t, u] = delrows(delcols(A, y .. y), x .. x)[t, u], t = 1 .. N-1), u = 1 .. N-1), S[N-1, x, y])
end do: end do:
Matrix(N, N, f)/(DET)*(24/6);
A^(-1);

CN for N=4 and N=3 is 24 and 6 respectively i.e. CN(4)/CN(3)=24/6.

When I use bellow procedure the error "(in S) bad index into Matrix" is occurred.

Please help me to write this algorithm by using procedure.

Thank you 

restart; with(linalg): Digits := 40: n := 7:
S := proc (N) local e, ML, s, i:
e := product(product(signum(a[j]-a[i]), j = i+1 .. N), i = 1 .. N):
ML := product(A[a[k], b[k]], k = 1 .. N):
s[0] := e*subs(`$`(a[q] = b[q], q = 1 .. N), e)*ML:
for i to N do s[i] := sum(sum(s[i-1], a[i] = 1 .. N), b[i] = 1 .. N) end do
end proc:
A := Matrix(n, n, proc (i, j) options operator, arrow; evalf((3*i+j)/(i+2*j)) end proc): # arbitrary matrix
CN := simplify(S(n)/det(A))

This is the coding till i do dhe decryption process. 

Do(plaintext=GetProperty("message",value));
Do(plaintext=convert(GetProperty("message",value),name));
Do(plaintextInt = convert(plaintext, bytes));
Do(plaintextBin = `~`[convert](plaintextInt, binary));
Do(plaintextBin2 = map2(nprintf, "%07d", plaintextBin));
Do(n0 = plaintextBin2[]);
Do(length1 = length(n0));
Do(plaintextCode = cat("", plaintextBin2[]));
Do(length2 = length(plaintextCode));
Do(z = convert(plaintextCode, decimal, binary));
Do(z1 = z+1);
Do(z2 = z1+%sk1);
Do(z3 = convert(z2, base, 2));
Do(b = cat("", z3[]));
Do(z4 = length(b));
Do(z5 = [Bits:-GetBits(-z2, -1 .. 0, bits = z4)]);
Do(z6 = cat("", z5[]));
Do(z7 = convert(z6, decimal, binary));
Do(%C = `mod`(Power(z7, %txte), %txtN));
Do(%C1 = `mod`(Power(%sk1, %txte), %txtN));

Do(%m = `mod`(Power(%C, %d), %N));

Do(%sk2=`mod`(Power(%C1,%d),%N));

Then nw i need to decrypt back to the original message with the coding:

Do(z8 = [Bits:-GetBits(-%m,-1 .. 0, bits = z4)]);
Do(c = cat("", z8[]));
Do(z9 = convert(c, decimal, binary));
Do(z10 = z9-sk2);
Do(z11 = z10-1);
Do(z12 = [Bits:-GetBits(z11, -1 .. 0, bits = length2)]);
Do(d = cat("", z12[]));
Do(plaintextBin2 = [StringTools:-LengthSplit(d, length1)]);
Do(plaintextInt2 = `~`[convert](plaintextBin2, decimal, binary));
Do(%message1 = convert(plaintextInt, bytes));

when i execute the program it shows the error

so how should I solve this as although i think that it should be problem of parsing the number z4 in the sentence that i highlighed, but whenever i correct it it still can't work.Thus anyone who know please help.Thanks.

 

I need to do Huffman Coding by using Document Tools thus i can produce user interface by using coding that referred in this post by Alec Mihailovs. Below is the coding and Document Tools interface:

Do(plaintext=GetProperty("message2",value));
Do(plaintext=convert(GetProperty("message2",value),name));
Do(Freq = proc (message) options operator, arrow; map(proc (x) options operator, arrow; rhs(x) = lhs(x) end proc, {StringTools:-CharacterFrequencies(message)}) end proc);
Do(Fr = Freq(plaintext));
Do(HuffmanTree = proc (message) options operator, arrow; if nops(message) <= 1 then rhs(message[]) else procname(`union`(message[3 .. -1], {lhs(message[1])+lhs(message[2]) = [rhs(message[1]), rhs(message[2])]})) end if end proc);
Do(HT = HuffmanTree(Fr));
Do(HuffmanCoding = proc (message, r := "") if message::string then message = r else procname(message[1], cat(r, 0)), procname(message[2], cat(r, 1)) end if end proc);
Do(HD = HuffmanCoding(HT));
Do(C = table([HD]));
Do(HC = cat(map(proc (x) options operator, arrow; C[x] end proc, StringTools:-Explode(message))[])

It still can get result for first part of the coding.During execute the second part of the coding(as bolded), it produces error ,the error show below.So how should I modified so that the error won't pop out @Alec Mihaivols

 

First 161 162 163 164 165 166 167 Last Page 163 of 334