MaplePrimes Questions

How can we manage them?

During the last few days
@Rana47 https://www.mapleprimes.com/questions/236758-HPM-Error-Invalid-Input
@SHIVAS https://www.mapleprimes.com/questions/236755-How-To-Run-Or-Implement-HPM-Method-In-Maple
@Madhukesh J K https://www.mapleprimes.com/questions/236747-Error-In-The-Program-HPM

have both asked a similar question on the same topic (HPM) and uploaded both quite the same code (same name of variables, same commands and same syntax errors).
This reveals an obvious close proximity of these three OP.

Given the extreme resemblance of the three threads, my guess is that there is a single person behind those three login names who expects that asking the same question from different login names will prevent the moderators from moving the new thread to an old one, and thus keeping his question in the foreground?

Am I on the wrong track (in which case I humbly ask the three OPs to excuse my words[1])
If not, how can we prevent this type of behaviour?

[1] but, as it is likely that they are then close colleagues from the same lab they should coordinate not to ask the same question three times.

Why does Maple 2023.x not evaluate to Phi := -b in the following example?

> restart:
> z:=-a*exp(-I*b):
> Phi:=simplify(evalc(argument(z)));
               Phi := arctan(a sin(b), -a cos(b))

Since Maple forms the main value of arctan(y, x), would have to be
Phi=arctan(a sin(b), -a cos(b))=arctan((a sin(b))/(-a cos(b)))=arctan(-tan(b))=-b.

Is the full evaluation not implemented for some reason or what did I miss?

Hi everyone, I am trying to reproduce the results using the HPM method in Maple for ODE. Later, will use these results for my original problem.  The problem has power N as an exponent; when I fixed N some to a numeric number, then I get some equation, but this equation is not similar as reported in the paper, I do not want to fix N to some numeric number.  I am attaching my Mplae worksheet and some pictures of the problem that I want to reproduce. Could anyone help me reproduce all the equations as it is reported in the paper, please have a look at my worksheet. There are 4 pictures, and their name is according to sequence .....................

HPM-Help.mw

 

I installed Maple 2023.1 update and immediately noticed a problem with the worksheet editor.

Specifically, the editor seems to be replacing "<" with "!" in the maple code. I first noticed the problem with code copied from the maple code editor into a worksheet, but then noticed the same problem with code on another worksheet which was loaded from file. Thus, it seems the problem is actually in the worksheet editor and not the copy paste function.  Note that the problem occurred immediately on reloading files after I restarted maple from the update. Normally, when this occurs, it starts after Maple has been loaded for an hour or more. Fortunately, when I restarted Maple and reloaded files, the problem seems to have cleared itself.

I have attached images showing the maple screen with the error, and also the specific code copied from the code editor to a worksheet for comparison.  I have also attached the worksheets in which I saw the problem. For now my goto workaround is to save and restart because the problem does not seem to corrupt the actual files even when I save them.

 

Attachments: chain.mw  chain2.mw

Mathematica has a benchmarking package that allows you to evaluate your computer's performance with respect to other computers with different specs.
I was wondering if there was a similar script/package for maple?

Hi dear users!

I hope everyone is fine here. I want to compute the NULL SPACE vector V2[1], V2[2], V2[3],... of matrices MatrixEquationAgain2[1], MatrixEquationAgain2[2], MatrixEquationAgain2[3]... for different values of M. Kindly see my attached file where I struggled a lot but failed to evaluate it. Kindly help me to compute it. Thanks in advance

NULL_SPACE.mw

According to print - Maple Help (maplesoft.com),

calling print[N] instead of print where N is an integer between -2 and +3, temporarily overrides the prettyprint interface variable.

However, I find that 

print[-2]();
Error, prettyprint must be an integer in the range 0..3
print[-1]();
Error, prettyprint must be an integer in the range 0..3

Also, 

interface(prettyprint = -2);
Error, (in interface) prettyprint must be an integer in the range 0..3
interface(prettyprint = -1);
Error, (in interface) prettyprint must be an integer in the range 0..3

Did I miss something?

Dear experts

I am interested in solving the following differential equation numerically

diff(eta(k,t),t,t) + gamma*diff(eta(k,t),t) + omega^2*eta(k,t) + (3/4)*k*omega*eta(k,t)*eta(k,t) + (3/2)*k*eta(k,t)*(omega*eta(k,t) + (3/4)*k*eta(k,t)*eta(k,t)) + (omega*gamma*eta(k,t) + (3/2)*k*eta(k,t)*(gamma*eta(k,t)))*(diff(eta(k,t),t) + gamma*eta(k,t))/(omega*eta(k,t) + (3/4)*k*eta(k,t)*eta(k,t)) = 0;

where eta(x,t) is the Fourier transform of zeta(x,t) and plot of zeta(x,t) is the goal. I think FFT method can help but I failed in running and applying this method on the equation above.
Initial conditions are

f= 0.28
C = 1/L*0.2/f*tanh(L/f)
L=20
amp = 0.5e-2
zeta0 = amp/cosh(f*x)/cosh(f*x)-C

and u0 as initial velocity can be 0 or an arbitrary function such as 
u0 =2*amp/cosh(f*x)/cosh(f*x)*f*tanh(f*x)

I would appreciate it if one could help me.

How do I add the solve command to the end?

Download Zakobi.mw

I am getting errors while applying the HPM method.
I have attached the maple file.

HPM.mw

Please help me to get the solution.

Thanks in advance.

I'd like to reproduce Initial Value DDE of Neutral Type in Maple.
The differential equation is: 

deq := D(y)(t) = 2*cos(2*t)*y(t/2)^(2*cos(t)) + ln(D(y)(t/2)) - ln(2*cos(t)) - sin(t): # with y(0) = 1 and known D(y)(0)

Unfortunately, if I type valid initial values, Maple will simply generate , and yet if I just give a partial initial condition, Maple will display and only return incorrect results. 
 

restart;

interface(version)

`Standard Worksheet Interface, Maple 2023.1, Windows 10, July 7 2023 Build ID 1723669`

(1)

deq := (D(y))(t) = 2*cos(2*t)*y((1/2)*t)^(2*cos(t))+ln((D(y))((1/2)*t))-ln(2*cos(t))-sin(t)

RealDomain:-solve(subs(t = 0, y(0) = 1, deq), (D(y))(0))

2, -LambertW(-2*exp(-2))

(2)

dsolve({deq, y(0) = 1, (D(y))(0) = (2, -LambertW(-2*exp(-2)))[1]}, 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

Error, (in dsolve/numeric/DAE/initial) too many initial conditions, the following are not needed: {D(y)(0) = 2}

 

dsolve({deq, y(0) = 1, (D(y))(0) = (2, -LambertW(-2*exp(-2)))[2]}, 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

Error, (in dsolve/numeric/DAE/initial) too many initial conditions, the following are not needed: {D(y)(0) = -LambertW(-2*exp(-2))}

 

dsn := dsolve({deq, y(0) = 1}, 'type' = 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

plots['odeplot'](dsn, 0 .. 2*Pi)NULL

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

 

`[Length of output exceeds limit of 1000000]`

 

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

 

 


 

Download ndelay.mw

The output is wrong. Note that "y(0) = 1" is insufficient to uniquely specify a solution, as "D(y)(0)" can be either -LambertW(-2/exp(2)) or 2. But Maple does not allow sufficient constraints here. How do I avoid such an unexpected behavior?

Hi,

I wonder about how to generate the classical table of the standard normal distribution. Ideas ?

Many thanks

 

Here is a test: 

For small matrices, apart from the first call, the performance is almost perfect (🎉!). 
As a comparison, an equivalent test may be performed in modern Python:

As you can see, for 1024×1024, 2048×2048, 4096×4096, 8192×8192, and 16384×16384 matrices, Maple's performance gets pretty poor. Is the FFT procedure not well optimized for larger matrices? I do have read the Fourier Transforms in Maple, yet I cannot find any information on this subject. 
In accordance with the following output 

showstat(DiscreteTransforms::FFT_complex8, 3):

FFT_complex8 := proc()
       ...
   3   :-DiscreteTransforms:-FFT_complex8 := LinkExternal('hw_FFT',2003);
       ...
end proc

it appears that the code hasn't been developed for 20 years. Is it possible to improve the performance of the FFT built into Maple in order that the computation on such a 2¹⁴×2¹⁴ matrix can be achieved in about twenty seconds (rather than in two minutes)?

Note. For these matrices, exact transform results (see below) can be obtained symbolically.

for n from 0 to 12 do
    m := LinearAlgebra:-HankelMatrix(<$ (1 + 1 .. 2**n + 2**n)>, datatype = complex[8], shape = []): gc();
    print(n, andseq(abs(_) < HFloat(1, -10, 2), _ in SignalProcessing:-FFT(m, normalization = none, inplace = true) - Matrix(2^n, <2^(2*n)*(2^n + 1), <'2^(2*n - 1)*(:-cot((k - 1)/2^n*Pi)*I - 1)' $ 'k' = 1 + 1 .. 2^n>>, shape = symmetric, storage = sparse, datatype = complex[8])) (* faster than `rtable_scanblock` and `ArrayTools:-IsZero` and much faster (🎊!) than `comparray` and `verify/Matrix` with testfloat *) )
od:
 = 
                            0, true

                            1, true

                            2, true

                            3, true

                            4, true

                            5, true

                            6, true

                            7, true

                            8, true

                            9, true

                            10, true

                            11, true

                            12, true

However, the main goal is to test the numerical efficiency of Maple's fast Fourier transform algorithm.

Down below I am sharing with you the question and what I wrote as a solution so far. It includes the commands, functions, outputs, and errors. I am struggling with fixing my errors as I have tried numerous ways to correct them. However, I either get new errors or previous errors. Was wondering if someone can look at it and provide me advice, and a possible solution to the problem. 

In this question, you are given a cypher that was obtained using a Vigenere cypher, care of question 2, and are asked to decipher it.  You will use the approach outlined in Section 5.2 of the text.  There are two steps:  1)  Determine the key length by finding the shift which produces the maximum number of coincidences, 2)  use frequency analysis on the subsequences obtained by selecting symbols from the cypher at multiples of the key length to determine the key.  The details of these steps will be outlined below.  You will be asked to write several maple procedures that assist in this process.

restart;
with(StringTools):

with(LinearAlgebra):
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky";
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveol\

  qlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvv\

  zhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgy\

  klhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvoji\

  komtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhha\

  pdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpv\

  euzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyin\

  ky"


n := Length(cstr);
                            n := 429


a)  Determine the key length.  Write a Maple function to determine the key length given the ciphertext obtained from a Vigenere cipher with unknown key using a specified alphabet.  Use one of the methods outlined in section 5.2 of the text: the Kasiski test (using trigrams) or the index of coincidence test. For the Kasiski test, the key length is suggested by the greatest common divisor of the distances between most of the repeated trigrams. For the index of coincidence test, construct the subsequences described in part (b) for various values of 
k;
. The 
k;
 value that yields the highest average index of coincidence of these subsequences most likely is the key length. 

KasiskiTest := proc(str)
  local i, j, n, trigrams, distances, gcds, freqs;
  n := StringTools:-Length(str);
  trigrams := table();
  distances := table();
  gcds := table();
  freqs := table();
  for i from 1 to n-2 do
    trigrams[str[i..i+2]] := [op(trigrams[str[i..i+2]]),i];
  end do;
  for j in trigrams do
    if nops(trigrams[j]) > 1 then
      distances[j] := map(diff,trigrams[j]);
      gcds[j] := igcd(op(distances[j]));
      freqs[gcds[j]] := freqs[gcds[j]] + 1;
    end if;
  end do;
  return maxloc(freqs);
end;

IndexCoincidenceTest := proc(str)
  local i, k, n, m, L, C, Convert, IC, avgIC;
  Convert := table();  n := StringTools:-Length(str);  
  for i from 1 to n do
    Convert[str[i]] := i-1;
  end do;
  L := Letter2Number(str,Convert); 
  IC := [];
  avgIC := [];
  for k from 1 to n/2 do
    C := [];
    for i from 1 to k do
      C[i] := seq(L[i+j*k],j=0..floor((n-i)/k));
    end do;
    IC[k] := map(DotProduct,C,C)/nops(C)^2;
    avgIC[k] := add(IC[k])/k;
  end do;
  return maxloc(avgIC);
end;

KasiskiTest(cstr);


                         maxloc(freqs)

IndexCoincidenceTest(cstr);
Error, (in IndexCoincidenceTest) expression sequences cannot be assigned to lists


b) Construct subsequences of the cypher by selecting characters at multiples of the key length.  I.E.  If k is the key length, then construct subsequences:  c1 = cstr[1],cstr[1+k],...,cstr[1+n/k],...,ck = cstr[k],cstr[2*k],...,cstr[floor(n/k)*k].  

Maple hint:  use seq and cat to form these strings.

cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky";
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveol\

  qlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvv\

  zhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgy\

  klhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvoji\

  komtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhha\

  pdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpv\

  euzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyin\

  ky"

Subsequences := proc(str,k)
  local i, n, C, S;
  n := StringTools:-Length(str);
  C := [];
  S := [];
  for i from 1 to k do
    C[i] := seq(str[i+j*k],j=0..floor((n-i)/k));
    S[i] := cat(op(C[i]));
  end do;
  return S;
end;

Warning, (in Subsequences) `j` is implicitly declared local
 Subsequences := proc (str, k) local i, n, C, S, j; n := 

    StringTools:-Length(str); C := []; S := []; for i to k do 

    C[i] := seq(str[i+j*k], j = 0 .. floor((n-i)/k)); S[i] := 

    cat(op(C[i])) end do; return S end proc


Subsequences(cstr,4);
Error, (in Subsequences) expression sequences cannot be assigned to lists


c) Calculate the character frequencies in the substrings formed from (b).  You should construct a list F=[f1/n,...,ft/n], where fi is the number of occurrences of symbol i in the string and n is the number of symbols in the string, and t is the number of symbols in the alphabet.  Don't forget that you can use evalf() to get a floating point approximation to the fractions fi/n, and you can use CountCharacterOccurrences() from the StringTools package to obtain the number of occurrences of the ith symbol. For the alphabet use a,...,z.  See question 1.

alphabet := Iota("a".."z");
            alphabet := "abcdefghijklmnopqrstuvwxyz"

CharacterFrequencies := proc(str,alphabet)
  local i, n, t, F, C;
  n := StringTools:-Length(str);
  t := StringTools:-Length(alphabet);
  F := [];
  C := StringTools:-CountCharacterOccurrences(str);
  for i from 1 to t do
    F[i] := evalf(C[alphabet[i]]/n);
  end do;
  return F;
end;

Error, attempting to assign to `StringTools:-CharacterFrequencies` which is protected
alphabet := "abcdefghijklmnopqrstuvwxyz";
S := Subsequences(cstr,4);
CharacterFrequencies(S[1],alphabet);

            alphabet := "abcdefghijklmnopqrstuvwxyz"

Error, (in Subsequences) expression sequences cannot be assigned to lists
Error, (in StringTools:-CharacterFrequencies) first argument must be a string


d) Determine the Ceasar shifts for the 5 subsequences from (b) and hence determine the key.  This is done by comparing the frequencies computed in (c) with the standard English letter probabilities given in the list FE.

You are to write a function FindShift(F1,F2) which takes as input F1 = the standard frequencies and F2 = the shifted frequencies.  The function FindShift(F1,F2) find the shift 
                              "s"

 which minimizes the error between the two lists of frequencies.  I.E.  For each possible shift 
                  "s=0,1,...,25 = nops(F1), "

compute the sum of the squares of the difference F1[i]-F2[i+s mod 26].  Find the value of 
                              "s"

 that minimizes this sum.  This will be the most likely shift.

Note that in the above sum, you will need to correct the indexing due to the fact that Maple indexes lists and arrays starting at 1 rather than 0.

Use the function FindShift to find the key used to create the cypher cstr.

FE := [0.8167000000e-1, 0.1492000000e-1, 0.2782000000e-1, 0.4253000000e-1, .1270200000, 0.2228000000e-1, 0.2015000000e-1, 0.6094000000e-1, 0.6966000000e-1, 0.1530000000e-2, 0.7720000000e-2, 0.4025000000e-1, 0.2406000000e-1, 0.6749000000e-1, 0.7507000000e-1, 0.1929000000e-1, 0.9500000000e-3, 0.5987000000e-1, 0.6327000000e-1, 0.9056000000e-1, 0.2758000000e-1, 0.9780000000e-2, 0.2360000000e-1, 0.1500000000e-2, 0.1974000000e-1, 0.7400000000e-3];
[0.08167000000, 0.01492000000, 0.02782000000, 0.04253000000, 

  0.1270200000, 0.02228000000, 0.02015000000, 0.06094000000, 

  0.06966000000, 0.001530000000, 0.007720000000, 0.04025000000, 

  0.02406000000, 0.06749000000, 0.07507000000, 0.01929000000, 

  0.0009500000000, 0.05987000000, 0.06327000000, 0.09056000000, 

  0.02758000000, 0.009780000000, 0.02360000000, 0.001500000000, 

  0.01974000000, 0.0007400000000]


FindShift := proc(F1,F2)
  local i, s, n, t, S, M;
  n := nops(F1);
  t := nops(F2);
  S := [];
  for s from 0 to n-1 do
    S[s+1] := add((F1[i]-F2[(i+s) mod t + 1])^2,i=1..n);
  end do;
  M := minloc(S);
  return M[2]-1;
end;

 FindShift := proc (F1, F2) local i, s, n, t, S, M; n := 

    nops(F1); t := nops(F2); S := []; for s from 0 to n-1 do 

    S[s+1] := add((F1[i]-F2[(`mod`(i+s, t))+1])^2, i = 1 .. n) 

    end do; M := minloc(S); return M[2]-1 end proc


with(StringTools);
alphabet := "abcdefghijklmnopqrstuvwxyz";
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky";
FE := [0.8167000000e-1, 0.1492000000e-1, 0.2782000000e-1, 0.4253000000e-1, .1270200000, 0.2228000000e-1, 0.2015000000e-1, 0.6094000000e-1, 0.6966000000e-1, 0.1530000000e-2, 0.7720000000e-2, 0.4025000000e-1, 0.2406000000e-1, 0.6749000000e-1, 0.7507000000e-1, 0.1929000000e-1, 0.9500000000e-3, 0.5987000000e-1, 0.6327000000e-1, 0.9056000000e-1, 0.2758000000e-1, 0.9780000000e-2, 0.2360000000e-1, 0.1500000000e-2, 0.1974000000e-1, 0.7400000000e-3];
Subsequences := proc(str,k)
  local i, n, C, S;
  n := StringTools:-Length(str);
  C := [];
  S := [];
  for i from 1 to k do
    C[i] := seq(str[i+j*k],j=0..floor((n-i)/k));
    S[i] := cat(op(C[i]));
  end do;
  return S;
end;
CharacterFrequencies := proc(str,alphabet)
  local i, n, t, F, C;
  n := StringTools:-Length(str);
  t := StringTools:-Length(alphabet);
  F := [];
  C := StringTools:-CountCharacterOccurrences(str);
  for i from 1 to t do
    F[i] := evalf(C[alphabet[i]]/n);
  end do;
  return F;
end;
FindShift := proc(F1,F2)
  local i, s, n, t, S, M;
  n := nops(F1);
  t := nops(F2);
  S := [];
  for s from 0 to n-1 do
    S[s+1] := add((F1[i]-F2[(i+s) mod t + 1])^2,i=1..n);
  end do;
  M := minloc(S);
  return M[2]-1;
end;
S := Subsequences(cstr,4);
F := map(CharacterFrequencies,S,alphabet);
Shifts := map(FindShift,FE,F);
KeyLetters := map(Number2Letter,Shifts,alphabet);
Key := cat(op(KeyLetters));

[Anagrams, AndMap, ApproximateSearch, ApproximateSearchAll, 

  ArithmeticMean, Border, BorderArray, BorderLength, CamelCase, 

  Capitalize, CaseJoin, CaseSplit, Center, Centre, Char, 

  CharacterFrequencies, CharacterMap, Chomp, Chop, CommonPrefix, 

  CommonSuffix, Compare, CompareCI, Compress, 

  CountCharacterOccurrences, Decode, DecodeEntities, Delete, 

  DeleteSpace, DifferencePositions, Drop, EditDistance, Encode, 

  EncodeEntities, Entropy, Escape, Exchange, 

  ExpandCharacterClass, ExpandTabs, Explode, Fence, Fibonacci, 

  Fill, FirstFromLeft, FirstFromRight, FormatMessage, FormatTime, 

  FromByteArray, Generate, GenerateIdentifier, Group, 

  HammingDistance, HammingSearch, HammingSearchAll, Has, 

  HasASCII, HasAlpha, HasAlphaNumeric, HasBinaryDigit, 

  HasControlCharacter, HasDigit, HasGraphic, HasHexDigit, 

  HasIdentifier, HasIdentifier1, HasLower, HasOctalDigit, 

  HasPrintable, HasPunctuation, HasSpace, HasUpper, HasVowel, 

  Hash, Implode, Indent, IndexOfCoincidence, Insert, Iota, 

  IsASCII, IsAlpha, IsAlphaNumeric, IsAnagram, IsBalanced, 

  IsBinaryDigit, IsConjugate, IsControlCharacter, IsDerangement, 

  IsDigit, IsEodermdrome, IsGraphic, IsHexDigit, IsIdentifier, 

  IsIdentifier1, IsLower, IsMonotonic, IsOctalDigit, 

  IsPalindrome, IsPeriod, IsPermutation, IsPrefix, IsPrimitive, 

  IsPrintable, IsPunctuation, IsSorted, IsSpace, IsSubSequence, 

  IsSuffix, IsUpper, IsVowel, Join, Kasiski, LeftFold, 

  LeftRecursivePathOrder, Length, LengthSplit, Levenshtein, 

  LexOrder, LongestCommonSubSequence, LongestCommonSubString, 

  LowerCase, LyndonFactors, Map, MatchFence, MaxChar, 

  MaximalPalindromicSubstring, Metaphone, MinChar, 

  MinimumConjugate, MonotonicFactors, NGrams, NthWord, OrMap, 

  Ord, OtherCase, Overlap, PadLeft, PadRight, ParseTime, 

  PatternCanonicalForm, PatternDictionary, PatternEquivalent, 

  Period, Permute, PrefixDistance, PrimitiveRoot, Random, 

  Randomize, Readability, RegMatch, RegSplit, RegSub, RegSubs, 

  Remove, Repeat, Repeats, RevLexOrder, Reverse, RightFold, 

  RightRecursivePathOrder, Rotate, Search, SearchAll, Select, 

  SelectRemove, Sentences, Shift, ShortLexOrder, 

  ShortRevLexOrder, SimilarityCoefficient, Snarf, Sort, 

  SortPermutation, Soundex, Split, Squeeze, Stem, StringBuffer, 

  StringSplit, SubString, Subs, Substitute, SubstituteAll, 

  SuffixDistance, Support, SyllableLength, Tabulate, Take, 

  ThueMorse, ToByteArray, Trim, TrimLeft, TrimRight, Uncompress, 

  Unique, UpperCase, Visible, WildcardMatch, WordContaining, 

  WordCount, WordEnd, WordStart, Words, WrapText]


            alphabet := "abcdefghijklmnopqrstuvwxyz"

cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveol\

  qlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvv\

  zhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgy\

  klhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvoji\

  komtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhha\

  pdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpv\

  euzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyin\

  ky"


FE := [0.08167000000, 0.01492000000, 0.02782000000, 

  0.04253000000, 0.1270200000, 0.02228000000, 0.02015000000, 

  0.06094000000, 0.06966000000, 0.001530000000, 0.007720000000, 

  0.04025000000, 0.02406000000, 0.06749000000, 0.07507000000, 

  0.01929000000, 0.0009500000000, 0.05987000000, 0.06327000000, 

  0.09056000000, 0.02758000000, 0.009780000000, 0.02360000000, 

  0.001500000000, 0.01974000000, 0.0007400000000]


Warning, (in Subsequences) `j` is implicitly declared local
 Subsequences := proc (str, k) local i, n, C, S, j; n := 

    StringTools:-Length(str); C := []; S := []; for i to k do 

    C[i] := seq(str[i+j*k], j = 0 .. floor((n-i)/k)); S[i] := 

    cat(op(C[i])) end do; return S end proc


Error, attempting to assign to `StringTools:-CharacterFrequencies` which is protected
 FindShift := proc (F1, F2) local i, s, n, t, S, M; n := 

    nops(F1); t := nops(F2); S := []; for s from 0 to n-1 do 

    S[s+1] := add((F1[i]-F2[(`mod`(i+s, t))+1])^2, i = 1 .. n) 

    end do; M := minloc(S); return M[2]-1 end proc


Error, (in Subsequences) expression sequences cannot be assigned to lists
                             F := 

Error, invalid input: FindShift uses a 2nd argument, F2, which is missing
KeyLetters := Number2Letter(Shifts, "abcdefghijklmnopqrstuvwxyz")

            Key := Shiftsabcdefghijklmnopqrstuvwxyz


e) Decipher cstr using the key found in (d) and your DecryptVigenere routine from question 2.  Note that the encrypted text will have blanks removed.

with(StringTools);
[Anagrams, AndMap, ApproximateSearch, ApproximateSearchAll, 

  ArithmeticMean, Border, BorderArray, BorderLength, CamelCase, 

  Capitalize, CaseJoin, CaseSplit, Center, Centre, Char, 

  CharacterFrequencies, CharacterMap, Chomp, Chop, CommonPrefix, 

  CommonSuffix, Compare, CompareCI, Compress, 

  CountCharacterOccurrences, Decode, DecodeEntities, Delete, 

  DeleteSpace, DifferencePositions, Drop, EditDistance, Encode, 

  EncodeEntities, Entropy, Escape, Exchange, 

  ExpandCharacterClass, ExpandTabs, Explode, Fence, Fibonacci, 

  Fill, FirstFromLeft, FirstFromRight, FormatMessage, FormatTime, 

  FromByteArray, Generate, GenerateIdentifier, Group, 

  HammingDistance, HammingSearch, HammingSearchAll, Has, 

  HasASCII, HasAlpha, HasAlphaNumeric, HasBinaryDigit, 

  HasControlCharacter, HasDigit, HasGraphic, HasHexDigit, 

  HasIdentifier, HasIdentifier1, HasLower, HasOctalDigit, 

  HasPrintable, HasPunctuation, HasSpace, HasUpper, HasVowel, 

  Hash, Implode, Indent, IndexOfCoincidence, Insert, Iota, 

  IsASCII, IsAlpha, IsAlphaNumeric, IsAnagram, IsBalanced, 

  IsBinaryDigit, IsConjugate, IsControlCharacter, IsDerangement, 

  IsDigit, IsEodermdrome, IsGraphic, IsHexDigit, IsIdentifier, 

  IsIdentifier1, IsLower, IsMonotonic, IsOctalDigit, 

  IsPalindrome, IsPeriod, IsPermutation, IsPrefix, IsPrimitive, 

  IsPrintable, IsPunctuation, IsSorted, IsSpace, IsSubSequence, 

  IsSuffix, IsUpper, IsVowel, Join, Kasiski, LeftFold, 

  LeftRecursivePathOrder, Length, LengthSplit, Levenshtein, 

  LexOrder, LongestCommonSubSequence, LongestCommonSubString, 

  LowerCase, LyndonFactors, Map, MatchFence, MaxChar, 

  MaximalPalindromicSubstring, Metaphone, MinChar, 

  MinimumConjugate, MonotonicFactors, NGrams, NthWord, OrMap, 

  Ord, OtherCase, Overlap, PadLeft, PadRight, ParseTime, 

  PatternCanonicalForm, PatternDictionary, PatternEquivalent, 

  Period, Permute, PrefixDistance, PrimitiveRoot, Random, 

  Randomize, Readability, RegMatch, RegSplit, RegSub, RegSubs, 

  Remove, Repeat, Repeats, RevLexOrder, Reverse, RightFold, 

  RightRecursivePathOrder, Rotate, Search, SearchAll, Select, 

  SelectRemove, Sentences, Shift, ShortLexOrder, 

  ShortRevLexOrder, SimilarityCoefficient, Snarf, Sort, 

  SortPermutation, Soundex, Split, Squeeze, Stem, StringBuffer, 

  StringSplit, SubString, Subs, Substitute, SubstituteAll, 

  SuffixDistance, Support, SyllableLength, Tabulate, Take, 

  ThueMorse, ToByteArray, Trim, TrimLeft, TrimRight, Uncompress, 

  Unique, UpperCase, Visible, WildcardMatch, WordContaining, 

  WordCount, WordEnd, WordStart, Words, WrapText]


alphabet := "abcdefghijklmnopqrstuvwxyz";
            alphabet := "abcdefghijklmnopqrstuvwxyz"

cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky";
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveol\

  qlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvv\

  zhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgy\

  klhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvoji\

  komtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhha\

  pdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpv\

  euzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyin\

  ky"


Key := [19, 4, 18, 19];
                     Key := [19, 4, 18, 19]

DecryptVigenere := proc(str,key,alphabet)
  local i, n, m, L, K, C, Convert, plain;
  Convert := table();  n := StringTools:-Length(alphabet);  
  for i from 1 to n do
    Convert[alphabet[i]] := i-1;
  end do;
  L := Letter2Number(str,Convert); 
  K := Letter2Number(key,Convert);
  m := nops(K);
  C := [];
  for i from 1 to nops(L) do
    C := [op(C),L[i]-K[i mod m + 1] mod n];
  end do;  
  plain := Number2Letter(C,alphabet);
  return plain;
end;
DecryptVigenere := proc (str, key, alphabet) local i, n, m, L, 

   K, C, Convert, plain; Convert := table(); n := StringTools:-L\

  ength(alphabet); for i to n do Convert[alphabet[i]] := i-1 

   end do; L := Letter2Number(str, Convert); K := Letter2Number(\

  key, Convert); m := nops(K); C := []; for i to nops(L) do C 

   := [op(C), `mod`(L[i]-K[(`mod`(i, m))+1], n)] end do; plain 

   := Number2Letter(C, alphabet); return plain end proc


DecryptVigenere(cstr,Key,alphabet);
Number2Letter([Letter2Number("eqjyvxvgiuphmrrrgzhvwrrukmrtijfbto\

  didtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjt\

  hitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvl\

  oiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnf\

  jnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxu\

  asvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhys\

  lgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvp\

  bonjsoabcizotysxztyinky", Convert)[1]

   + 25 Letter2Number([19, 4, 18, 19], Convert)[2], Letter2Number("eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky", 

  Convert)[2] + 25 Letter2Number([19, 4, 18, 19], Convert)[1]], 

  "abcdefghijklmnopqrstuvwxyz")

f) Decipher the Vigenere ciphers from Computer Problems 8 and 9 from Section 2.14 of the text.


xkju:= "xkjurowmllpxwznpimbvbqjcnowxpcchhvvfvsllfvxhazityxohulxqojaxelxzxmyjaqfs\
tsrulhhucdskbxknjqidallpqslluhiaqfpbpcidsvcihwhwewthbtxrljnrsncihuvffuxvoukjlj\
swmaqfvjwjsdyljogjxdboxajultucpzmpliwmlubzxvoodybafdskxgqfadshxnxehsaruojaqfpf\
kndhsaafvulluwtaqfrupwjrszxgpfutjqiynrxnyntwmhcukjfbirzsmehhsjshyonddzzntzmpli\
lrwnmwmlvuryonthuhabwnvw";
ocwy:= "ocwyikoooniwugpmxwktzdwgtssayjzwyemdlbnqaaavsuwdvbrflauplooubfgqhgcscmgz\
latoedcsdeidpbhtmuovpiekifpimfnoamvlpqfxejsmxmpgkccaykwfzpyuavtelwhrhmwkbbvgtg\
uvtefjlodfefkvpxsgrsorvgtajbsauhzrzalkwuowhgedefnswmrciwcpaaavogpdnfpktdbalsis\
urlnpsjyeatcuceesohhdarkhwotikbroqrdfmzghgucebvgwcdqxgpbgqwlpbdaylooqdmuhbdqgm\
yweuik";
xkju := "xkjurowmllpxwznpimbvbqjcnowxpcchhvvfvsllfvxhazityxohulx\

  qojaxelxzxmyjaqfstsrulhhucdskbxknjqidallpqslluhiaqfpbpcidsvcih\

  whwewthbtxrljnrsncihuvffuxvoukjljswmaqfvjwjsdyljogjxdboxajultu\

  cpzmpliwmlubzxvoodybafdskxgqfadshxnxehsaruojaqfpfkndhsaafvullu\

  wtaqfrupwjrszxgpfutjqiynrxnyntwmhcukjfbirzsmehhsjshyonddzzntzm\

  plilrwnmwmlvuryonthuhabwnvw"


ocwy := "ocwyikoooniwugpmxwktzdwgtssayjzwyemdlbnqaaavsuwdvbrflau\

  plooubfgqhgcscmgzlatoedcsdeidpbhtmuovpiekifpimfnoamvlpqfxejsmx\

  mpgkccaykwfzpyuavtelwhrhmwkbbvgtguvtefjlodfefkvpxsgrsorvgtajbs\

  auhzrzalkwuowhgedefnswmrciwcpaaavogpdnfpktdbalsisurlnpsjyeatcu\

  ceesohhdarkhwotikbroqrdfmzghgucebvgwcdqxgpbgqwlpbdaylooqdmuhbd\

  qgmyweuik"


 

 

Q1: Why does Maple use the bar as a delimiter for certain elliptic expressions and the comma for others?

Is that in line with: Gradshteyn and Ryzhik (G&R) and in the popular "Handbook of Mathematical Functions" edited by Abramowitz and Stegun (A&S), as stated in help(JacobiAM)?      

Q2: Can I have the comma instead of the vertical bar for the Jacobian functions?

Q3: If not, how to get a bit more space between the symbols and the bar for better readability?

 

interface(version)

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

(1)

FunctionAdvisor(relate, EllipticF, InverseJacobiSN)

EllipticF(z, k) = InverseJacobiSN(z, k)

(2)

Typesetting:-EnableTypesetRule(Typesetting:-SpecialFunctionRules)

{}

(3)

EllipticF(z, k) = InverseJacobiSN(z, k)

EllipticF(z, k) = InverseJacobiSN(z, k)

(4)

NULL


 

Download Argument_delimiter.mw

First 63 64 65 66 67 68 69 Last Page 65 of 2308