Carl Love

Carl Love

28110 Reputation

25 Badges

13 years, 118 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

What you've posted is not a differential equation.

@patrickfitzpatrick Please let me know whether the all-solutions code that I posted works adequately for you. In particular, Does it produce all solutions in a reasonable time for all the cases that you're interested in?

@acer Unfortunately, workbook .maple files don't work on MaplePrimes.

@Carl Love The algorithm for the all-solutions problem and its Maple implementation are in an Answer below, and I'm quite pleased with them.

@patrickfitzpatrick Both Kitonum's and my code give one solution--not all solutions--for a given n. I am working on an algorithm to efficiently find all solutions. It should take me a few hours.  

@Masooma The version released in 2018 is called "Maple 2018". There was also a version released several years earlier (2014?) called "Maple 18". Which of these two do you have? The command kernelopts(version) will tell you.

Why do you have size=[600,300] if you want another size?

@Masooma The only part of your code above that makes sense is the first line:

F := proc (x) options operator, arrow; x-2*f(x)/(D(f))(x) end procyou

It's more commonly written simply as

F:= x-> x - 2*f(x)/D(f)(x)

All the stuff with algsubs does nothing, and I don't know what you're trying to accomplish. The thing that you wrote with a second derivative could be meaningful, but it doesn't seem relevant to your goal of iterating the first function F.

By the way, what version of Maple are you using? I could retrofit my code to an earlier version if you need that.

@Masooma In order for the order of convergence to be 2, must be the known multiplicity of the root (many thanks to Acer and VV for providing clarity on this). So, if we use m=2, and the root has multiplicity 2, then the order of convergence will be 2. If you apply my order-of-convergence approximator (code given above) to such a situation, you'll get an order very close to 2. The polynomial examples that you gave earlier do not have roots of multiplicity 2:

(x-1)^3                                   m=3
(x^2+2*x+1)^5 = (x+10)^10   m=10

What size n are you interested in expressing as a sum of 4 squares? The algorithm that I gave below works reasonably efficiently (say, <= 16 milliseconds) for of many hundreds of bits. It may get bogged down if n has two or more large, distinct prime factors on the order of, say, a hundred bits. This slowness is just due to finding the prime factorization of n. If you need to work with such n, I'll implement the Rabin & Shallit algorithm (from the paper mentioned below), which doesn't use the prime factorization of and has average time complexity O(log(n)^2*log(log(n))).

Yes, it's easy. What do you want to be the time parameter of the animation--perhaps the standard deviation? You'd likely get better pedagogy---if that's your purpose---from an Explore command than from a dedicated animation.

@vv Yes, that's the paper that I was looking for. Thank you for posting it.

When I first read this Post, I quickly suspected that the order of the permutation would be a fairly easy closed-form function of its length and that the number of disjoint cycles would be small regardless of  length; however, neither of those seem to be true. Given that, it would seem odd that Order(P(n)) <= n for all n. Has someone proven that? Below, I've verified it up to n=4096.

Here are some explorations:

Some explorations viewing the Arabic Cipher as a permutation

Author: Carl Love <carl.j.love@gmail.com> 19-Sep-2019

restart
:

Procedures

#Create Arabic Cipher permutation:
ACperm:= (n::posint)->
   (h-> ListTools:-Interleave(
      `if`(n::odd, [-[$-h-1..-1], [$h+2..n]], [[$h+1..n], -[$-h..-1]])[]
   ))(iquo(n,2))
:

#Apply Cipher to a string:
ACapply:= (s::string)-> StringTools:-Permute(s, ACperm(length(s))):

#order of the permutation:
ACorder:= (n::posint)-> ilcm(nops~(convert(ACperm(n), 'disjcyc'))[]):
#number of disjoint cycles in the permutation:
ACndjc:= (n::posint)-> nops(convert(ACperm(n), 'disjcyc')):

Examples

ACperm(14);

[8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1]

ACapply("AlbertEinstein");

"iEntsrteebilnA"

ACorder(14);

14

ACndjc(14);

1

seq([n, ACndjc(n)], n= 1..16);

[1, 0], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 2], [8, 2], [9, 1], [10, 2], [11, 1], [12, 2], [13, 2], [14, 1], [15, 3], [16, 3]

Plots

N:= 2..2^12: #range of string lengths
plotopts:=
   style= point, symbol= solidcircle, symbolsize= 3, gridlines= false,
   color= "Bright ReddishPurple", size= [800,500], axes= frame
:

Orders:= [seq([n, ACorder(n)], n= N)]:

plot(Orders, plotopts, title= "Order vs. Length");

The above looks interesting from a number-theoretical perspective. What forms the lines? (I'll leave that question aside for now.) Also note that the order is always less than or equal to the length.

plot(
   `[]`~(ListTools:-Enumerate((`/`@op)~(Orders))), plotopts,
   symbolsize= (trunc@(1+log[2])@`/`@op)~(Orders),
   title= "Length/Order vs. Length"
);

Ndjc:= ACndjc~([$N]):

plot(
   `[]`~(ListTools:-Enumerate(Ndjc)), plotopts,
   symbolsize= (trunc@(1+log[2]))~(Ndjc),
   title= "Number of disjoint cycles vs. Length"
);

The above two plots are oddly similar, yet definitely different. The disjoint-cycles-vs-length looks statistically interesting.

The data in the two lists below is the same, just sorted differently. The left side of each equation is a number of disjoint cycles and the right side is the number of distinct lengths for which that number of cycles was attained.  

NLvsNdjc:= Statistics:-Tally(Ndjc):

NLvsNdjc__byNdjc:= sort(NLvsNdjc, key= [lhs,rhs]);

[1 = 590, 2 = 275, 3 = 489, 4 = 233, 5 = 217, 6 = 190, 7 = 232, 8 = 169, 9 = 145, 10 = 74, 11 = 93, 12 = 109, 13 = 114, 14 = 81, 15 = 44, 16 = 59, 17 = 48, 18 = 50, 19 = 54, 20 = 58, 21 = 39, 22 = 54, 23 = 42, 24 = 20, 25 = 23, 26 = 16, 27 = 19, 28 = 20, 29 = 32, 30 = 19, 31 = 26, 32 = 32, 33 = 24, 34 = 19, 35 = 9, 36 = 17, 37 = 11, 38 = 12, 39 = 5, 40 = 10, 41 = 13, 42 = 18, 43 = 15, 44 = 6, 45 = 6, 46 = 12, 47 = 3, 48 = 16, 49 = 7, 50 = 5, 51 = 2, 52 = 8, 53 = 8, 54 = 14, 55 = 4, 56 = 8, 57 = 12, 58 = 5, 59 = 3, 60 = 4, 62 = 11, 63 = 9, 64 = 3, 66 = 3, 67 = 3, 68 = 3, 69 = 1, 70 = 4, 71 = 7, 72 = 9, 73 = 3, 74 = 3, 76 = 4, 78 = 2, 79 = 2, 80 = 1, 81 = 2, 82 = 4, 83 = 1, 84 = 1, 85 = 1, 86 = 2, 88 = 5, 89 = 1, 90 = 3, 91 = 1, 92 = 1, 93 = 3, 94 = 1, 95 = 1, 96 = 2, 98 = 1, 100 = 2, 102 = 1, 104 = 2, 105 = 4, 106 = 2, 107 = 1, 111 = 2, 112 = 3, 114 = 1, 115 = 1, 117 = 4, 118 = 3, 119 = 2, 122 = 1, 123 = 2, 129 = 1, 130 = 1, 134 = 2, 142 = 1, 146 = 2, 147 = 1, 155 = 1, 156 = 2, 158 = 2, 161 = 1, 167 = 1, 172 = 1, 178 = 2, 179 = 1, 186 = 1, 201 = 2, 315 = 2]

NLvsNdjc_byNL:= sort(NLvsNdjc, key= [rhs,lhs]);

[69 = 1, 80 = 1, 83 = 1, 84 = 1, 85 = 1, 89 = 1, 91 = 1, 92 = 1, 94 = 1, 95 = 1, 98 = 1, 102 = 1, 107 = 1, 114 = 1, 115 = 1, 122 = 1, 129 = 1, 130 = 1, 142 = 1, 147 = 1, 155 = 1, 161 = 1, 167 = 1, 172 = 1, 179 = 1, 186 = 1, 51 = 2, 78 = 2, 79 = 2, 81 = 2, 86 = 2, 96 = 2, 100 = 2, 104 = 2, 106 = 2, 111 = 2, 119 = 2, 123 = 2, 134 = 2, 146 = 2, 156 = 2, 158 = 2, 178 = 2, 201 = 2, 315 = 2, 47 = 3, 59 = 3, 64 = 3, 66 = 3, 67 = 3, 68 = 3, 73 = 3, 74 = 3, 90 = 3, 93 = 3, 112 = 3, 118 = 3, 55 = 4, 60 = 4, 70 = 4, 76 = 4, 82 = 4, 105 = 4, 117 = 4, 39 = 5, 50 = 5, 58 = 5, 88 = 5, 44 = 6, 45 = 6, 49 = 7, 71 = 7, 52 = 8, 53 = 8, 56 = 8, 35 = 9, 63 = 9, 72 = 9, 40 = 10, 37 = 11, 62 = 11, 38 = 12, 46 = 12, 57 = 12, 41 = 13, 54 = 14, 43 = 15, 26 = 16, 48 = 16, 36 = 17, 42 = 18, 27 = 19, 30 = 19, 34 = 19, 24 = 20, 28 = 20, 25 = 23, 33 = 24, 31 = 26, 29 = 32, 32 = 32, 21 = 39, 23 = 42, 15 = 44, 17 = 48, 18 = 50, 19 = 54, 22 = 54, 20 = 58, 16 = 59, 10 = 74, 14 = 81, 11 = 93, 12 = 109, 13 = 114, 9 = 145, 8 = 169, 6 = 190, 5 = 217, 7 = 232, 4 = 233, 2 = 275, 3 = 489, 1 = 590]

plot(
   [[lhs,rhs]]~(NLvsNdjc), plotopts, axis[1,2]= [mode= log],
   symbolsize= (trunc@(1+log[2])@rhs)~(NLvsNdjc),
   title= "log(Attainments) vs. log(Number of disjoint cycles)"
);

Statistics:-Histogram(Ndjc, axes= frame, gridlines= false);

 


 

Download ArabicCipher.mw

  

I suppose the problem could be done in Maple. Matlab's fminsearch seems equivalent to parts of Maple's third-party DirectSearch package. I need details of "Pareto front" to proceed.

@Masooma I am happy to help further if you is still need it. Newton's method and its variations are an area of expertise of mine. I still don't see any merit to your method x-> x - 2*f(x)/D(f)(x) whether for ordinary or repeated roots.

First 252 253 254 255 256 257 258 Last Page 254 of 710