Joe Riel

9660 Reputation

23 Badges

20 years, 4 days

MaplePrimes Activity


These are answers submitted by Joe Riel

I don't see a problem.  It works fine here.  If you want to be crude, a brute-force attack will quickly solve this cipher (there are only 53 keys):

for i to 53 do    
    printf("%s\n", Caesar(cipher,i));
end do;

There is, however, a niftier approach.  Note the occurrence of the double GG and the ending G.  Presumably G is not the space character, because one wouldn't expect two in a row, nor at the end.  So let's compare common doubles with common word endings:

common doubles, in order of occurrence:  LTSEPORFCD
common endings, in order of occurrence: ESTDNROY

Because they occur near the fronts of both lists, the letters t, s, and e seem likely candidates for the letter G.  Check those three.  With a Caesar cipher you only need to know one character to decrypt the cipher. 

 

I suspect that your original equation is incorrect.  The symbol omega is generally used for natural frequency; if that is the case here, then your units do not work out.  To see that, just substitute a generic expression for omega, 1/R/C into the equation:

z := R*omega^2*C^2/(omega^2*C^2+R^2)+I*(R^2*omega*C+omega^3*C^2*L+R*omega^2*C^2/(omega^2*C^2+R^2):
subs(omega=1/R/C,z);
map(normal,%);
                                    4          2
                           R      (R  C + L + R  C) I
                         ------ + -------------------
                              4                4
                         1 + R       R C (1 + R )

 

which cannot be correct, the denominator, 1+R^4, has mixed units.  It isn't too hard to show that there is no value of omega for which this is correct:

evalc((Re-Im)(z)):
factor(%);
                                      2        2
                            omega C (R  + omega  C L)
                          - -------------------------
                                      2  2    2
                                 omega  C  + R

This can only make sense if the units of C and L are the same...

You could use the is procedure and RealRange.

is(3 in RealRange(2,4));
                                           true
rngs := [RealRange(2,Open(4)), RealRange(4,6)]:
select(rng -> is(3 in rng), rngs);
                                    [RealRange(2,Open(4))]

Here's a Maple procedure that enciphers/deciphers using an affine cipher with a given alphabet.

affine := proc(plain :: string
               , a :: integer
               , b :: integer
               , alphabet :: string
               , { decipher :: truefalse := false }
              ) :: string ;
uses StringTools;
local m, x, shift, to_alphabet;

    m := length(alphabet);
    ASSERT(igcd(a,m)=1);  # a and m are coprime

    shift := [seq(modp(a*x+b,m), x=0..m-1)];
    to_alphabet := cat(seq(alphabet[x+1], x in shift));

    if decipher then
        CharacterMap(to_alphabet, alphabet, plain);
    else
        CharacterMap(alphabet, to_alphabet, plain);
    end if;

end proc:

The cipher text has 74 characters.  Average English word length is about 5 characters, and each word has a space, so we expect 74/6 ~ 12 spaces. 

with(StringTools):
cipher := "fmw segjaweoouanerj a ceyqrype aswaheoaqbrqabeafrua eeaojerf afmjeayperjpu":
sort([CharacterFrequencies(cipher)], (a,b)->(rhs(a)>rhs(b)));
   ["e" = 12, "a" = 12, "r" = 6, " " = 6, "j" = 5, "o" = 4, "f" = 4, "y" = 3,
    "w" = 3, "u" = 3, "q" = 3, "p" = 3, "s" = 2, "m" = 2, "b" = 2, "n" = 1,
    "h" = 1, "g" = 1, "c" = 1]:

So we expect that either "a" or "e" in the cipher corresponds to the space character, and the other one is the "e".  Let a and b be the constants in the affine algorithm.  Then there are two possiblities:

eqs1 := {a*0+b=1, a*5+b=5}: # space(0) -> a(1), e(5) -> e(5)
eqs2 := {a*0+b=5, a*5+b=1}: # space(0) -> e(5), e(5) -> space(0)

msolve(eqs1, 27);
                                {a = 17, b = 1}

msolve(eqs2, 27);
                                {a = 10, b = 5}

 

Do you really want equality for the conditions and not the inequality (<)?  The nonzero portion of the graph has zero-measure, you cannot expect Maple to usefully plot such a function.

The call plot(pmf_x(q), q=0..4) gets evaluated to plot(delta(x), x=0..4), which won't plot unless delta is assigned and returns numeric values.  You could do plot(pmf_x, 0..4), however, I expect that to generate a straight line of zero.

You can use pointplot to plot the individual plots of interest.

Do you mean

plot3d(sqrt(x*z), x=0..1,z=0..1, filled);

That fills from the surface to the xz plane.

One aspect the OP needs to consider is that an internal block will have less than 3 digits if the leading digits are 0. For example:

 ListTools:-Reverse(convert(12010678,base,1000)); 
                                          [12, 10, 678]
 
There isn't much that can be done about that, unless strings are used.

As acer says, there are many ways to do this.  Here's a simpler approach

ListTools:-Reverse(convert(12345678,base,1000));
                                              [12, 345, 678]

Hmm.  Has convert/base always failed with negative integers?

convert(-123456, base, 1000);
                                               [-456, -123]

Try

F2 := expand(F1) assuming k>4;
                       F2 := -1/2 ln(k - 4) + ln(s + 5)

invlaplace(F2,s,t);
                                                           1 - exp(-5 t)
       -1/2 ln(k - 4) Dirac(t) + invlaplace(ln(s), s, t) + -------------
                                                                 t

You need to initialize a value to zero and then increment it in the loop.

rsum := proc(L::list)
local sm, x;
   sm := 0;     # this will store the partial sums
   for x in L do
      sm := sm + 1/x;
   end do;
  return sm;
end proc:

 

The usual way to combine plots is with the plots[display] command:

with(plots):
display(pointplot(...), pointplot(...));

 

E := <M,<0,0,0,1>^%T>;

A for loop (a specialization of a do loop) is terminated with "end do".  Actually, the "do" following the "end" is not needed, and you could use the older form "od" instead of "end do".

Standard technique for a substitution cipher is to compare the relative frequencies in the message to that of the target language, English.  You can use StringTools:-CharacterFrequencies to do that.  Here I'll create a string that has the characters sorted in terms of their relative frequency (assume S is assigned the ciper):

with(StringTools):
relorder := cat(map(lhs,sort([CharacterFrequencies(S)], (a,b)->(rhs(a)>rhs(b))))[]);
                  " ABUWNMeXPrKaZSJyDC'zOL."wnlh,"

For English, not including punctuation, the expectation is "etaonisrh..."

For this short a message we don't expect a particularly good match, but, because Acer has already given us the key, we can see that the actual order of the translated characters in the plain text is

         " teahinrlosdvwpmTyc'Sgu."IJRB,"
First 88 89 90 91 92 93 94 Last Page 90 of 114