From stephane.mottelet at utc.fr Wed Apr 6 19:35:53 2022 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Wed, 6 Apr 2022 19:35:53 +0200 Subject: [Scilab-users] Sundials module, macOS preview Message-ID: <23b5ffa5-7050-0c54-0921-71bf920e7ede@utc.fr> Hi all, The next version of scilab will include a new module "Sundials". This module provides new full featured? ODE solvers: arkode(), cvode() and DAE solver ida(), all handling complex numbers and dense/sparse/banded Jacobians. Each solver has specific features, e.g. ida() handles DAE, arkode() handles mixed implicit/explicit Runge-Kutta methods and cvode() can do forward sensitivity computation. The module also includes a general-purpose nonlinear system solver: kinsol(), who takes advantage of the module architecture (parsing, computation engine and SUNDIALS abstraction of various linear solvers). Current help pages can be found @ https://www.utc.fr/~mottelet/scilab/sundials/ and a macOS build including the new module is available at https://www.utc.fr/~mottelet/scilab_for_macOS.html I hope that a Windows build will be available in a near future, but in the meantime, comments from macOS users are welcome ! Enjoy ! -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet From cfuttrup at gmail.com Wed Apr 6 19:58:56 2022 From: cfuttrup at gmail.com (Claus Futtrup) Date: Wed, 6 Apr 2022 19:58:56 +0200 Subject: [Scilab-users] Sundials module, macOS preview In-Reply-To: <23b5ffa5-7050-0c54-0921-71bf920e7ede@utc.fr> References: <23b5ffa5-7050-0c54-0921-71bf920e7ede@utc.fr> Message-ID: Hi St?phane This looks very good! Cheers, Claus On 06-04-2022 19:35, St?phane Mottelet wrote: > Hi all, > > The next version of scilab will include a new module "Sundials". This > module provides new full featured? ODE solvers: arkode(), cvode() and > DAE solver ida(), all handling complex numbers and dense/sparse/banded > Jacobians. Each solver has specific features, e.g. ida() handles DAE, > arkode() handles mixed implicit/explicit Runge-Kutta methods and > cvode() can do forward sensitivity computation. > > The module also includes a general-purpose nonlinear system solver: > kinsol(), who takes advantage of the module architecture (parsing, > computation engine and SUNDIALS abstraction of various linear solvers). > > Current help pages can be found @ > https://www.utc.fr/~mottelet/scilab/sundials/ and a macOS build > including the new module is available at > > https://www.utc.fr/~mottelet/scilab_for_macOS.html > > I hope that a Windows build will be available in a near future, but in > the meantime, comments from macOS users are welcome ! > > Enjoy ! > From fmiyara at fceia.unr.edu.ar Thu Apr 7 05:24:47 2022 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Thu, 7 Apr 2022 00:24:47 -0300 Subject: [Scilab-users] Is this behavior of ifft / isreal correct? Message-ID: <08d13941-132a-0d5d-07e7-3d52c6eba187@fceia.unr.edu.ar> Dear all, Consider M = 16 w = [ones(1,M/4),zeros(1,M/4)] w = [w(1:M/2), 0, conj(w($:-1:2))] v = ifft(w) isreal(v) The first 3 lines defines a real spectrum of a real signal, then the real signal is recovered and finally it is checked whether it is real or not. What puzzles me is that the result is T (true). However, the definition of the ifft() involves complex operations, so at some point the numbers must be converted to a complex representation such as 1. + 0.i so I would expect that the result included 0i so the result of the test should be F. Where is this null imaginary component removed? I don't say this is wrong, but it is perplexing if compared to much more simple operations such as sqrt(%i^4) which yields 1. + 0.i, a complex representation of real scalar 1. Maybe the fftw package is so refined to detect whether the result is actually real and removes the useless 0.i components? Regards, Federico Miyara -- El software de antivirus Avast ha analizado este correo electr?nico en busca de virus. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: From sdr at durietz.se Thu Apr 7 09:18:19 2022 From: sdr at durietz.se (Stefan Du Rietz) Date: Thu, 7 Apr 2022 09:18:19 +0200 Subject: [Scilab-users] Is this behavior of ifft / isreal correct? In-Reply-To: <08d13941-132a-0d5d-07e7-3d52c6eba187@fceia.unr.edu.ar> References: <08d13941-132a-0d5d-07e7-3d52c6eba187@fceia.unr.edu.ar> Message-ID: <2d81aee1-a1f0-0229-993a-d62ca1b13527@durietz.se> Hello Federico, --> isreal(%i^2, %eps) ans = T --> %i^2 == -1 ans = T Regards Stefan On 2022-04-07 05:24, Federico Miyara wrote: > > Dear all, > > Consider > > M = 16 > w = [ones(1,M/4),zeros(1,M/4)] > w = [w(1:M/2), 0, conj(w($:-1:2))] > v = ifft(w) > isreal(v) > > The first 3 lines defines a real spectrum of a real signal, then the > real signal is recovered and finally it is checked whether it is real or > not. > > What puzzles me is that the result is T (true). However, the definition > of the ifft() involves complex operations, so at some point the numbers > must be converted to a complex representation such as > > 1. + 0.i > > so I would expect that the result included 0i so the result of the test > should be F. Where is this null imaginary component removed? > > I don't say this is wrong, but it is perplexing if compared to much more > simple operations such as > > sqrt(%i^4) > > which yields 1. + 0.i, a complex representation of real scalar 1. > > Maybe the fftw package is so refined to detect whether the result is > actually real and removes the useless 0.i components? > > Regards, > > Federico Miyara > > > > > Libre de virus. www.avast.com > > > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From arctica1963 at gmail.com Thu Apr 7 09:50:37 2022 From: arctica1963 at gmail.com (Lester Anderson) Date: Thu, 7 Apr 2022 08:50:37 +0100 Subject: [Scilab-users] Basic query - mprintf Message-ID: Hello all, Very basic query but how do you print all the values from a result via mprintf? e.g. fac = factor(1729) 7 13 19 mprintf('Factors of 1729 are: %d\n', fac) just prints 'Factors of 1729 are: 7 Sorry for the basic question! Cheers Lester -------------- next part -------------- An HTML attachment was scrubbed... URL: From sdr at durietz.se Thu Apr 7 11:30:30 2022 From: sdr at durietz.se (Stefan Du Rietz) Date: Thu, 7 Apr 2022 11:30:30 +0200 Subject: [Scilab-users] Basic query - mprintf In-Reply-To: References: Message-ID: Hello Lester, --> s = msprintf("Factors of 1729 are: "); s = "Factors of 1729 are: " --> fac = msprintf("%d\n", fac')' fac = "7" "13" "19" --> mprintf("%s%s", s, strcat(fac, " ")) Factors of 1729 are: 7 13 19 Regards Stefan On 2022-04-07 09:50, Lester Anderson wrote: > Hello all, > > Very basic query but how do you print all the values from a result via > mprintf? > > e.g. > > fac = factor(1729) > 7 13 19 > > mprintf('Factors of 1729 are: %d\n', fac) > just prints 'Factors of 1729 are:?7 > > Sorry for the basic question! > Cheers > Lester > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From sdr at durietz.se Thu Apr 7 12:01:05 2022 From: sdr at durietz.se (Stefan Du Rietz) Date: Thu, 7 Apr 2022 12:01:05 +0200 Subject: [Scilab-users] Basic query - mprintf In-Reply-To: References: Message-ID: Of course you don't need to make the string s. You have to transpose fac to get a column vector for mprintf and then transpose the column string vector to get a row string vector: --> fac = msprintf("%d\n", fac')' fac = "7" "13" "19" and then concatenate the string so that it works for a variable number of elements in fac: --> mprintf("Factors of 1729 are: %s", strcat(fac," ")) Stefan On 2022-04-07 11:30, Stefan Du Rietz wrote: > Hello Lester, > > --> s = msprintf("Factors of 1729 are:? "); > ?s? = > ? "Factors of 1729 are:? " > --> fac = msprintf("%d\n", fac')' > ?fac? = > ? "7"? "13"? "19" > --> mprintf("%s%s", s, strcat(fac, "? ")) > Factors of 1729 are:? 7? 13? 19 > > Regards > Stefan > > > On 2022-04-07 09:50, Lester Anderson wrote: >> Hello all, >> >> Very basic query but how do you print all the values from a result via >> mprintf? >> >> e.g. >> >> fac = factor(1729) >> 7 13 19 >> >> mprintf('Factors of 1729 are: %d\n', fac) >> just prints 'Factors of 1729 are:?7 >> >> Sorry for the basic question! >> Cheers >> Lester >> >> _______________________________________________ >> users mailing list >> users at lists.scilab.org >> http://lists.scilab.org/mailman/listinfo/users > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users From arctica1963 at gmail.com Thu Apr 7 12:09:58 2022 From: arctica1963 at gmail.com (Lester Anderson) Date: Thu, 7 Apr 2022 11:09:58 +0100 Subject: [Scilab-users] Basic query - mprintf In-Reply-To: References: Message-ID: Thanks all for the solution! Cheers Lester On Thu, 7 Apr 2022 at 11:02, Stefan Du Rietz wrote: > Of course you don't need to make the string s. > > You have to transpose fac to get a column vector for mprintf and then > transpose the column string vector to get a row string vector: > > --> fac = msprintf("%d\n", fac')' > fac = > "7" "13" "19" > > and then concatenate the string so that it works for a variable number > of elements in fac: > > --> mprintf("Factors of 1729 are: %s", strcat(fac," ")) > > Stefan > > > On 2022-04-07 11:30, Stefan Du Rietz wrote: > > Hello Lester, > > > > --> s = msprintf("Factors of 1729 are: "); > > s = > > "Factors of 1729 are: " > > --> fac = msprintf("%d\n", fac')' > > fac = > > "7" "13" "19" > > --> mprintf("%s%s", s, strcat(fac, " ")) > > Factors of 1729 are: 7 13 19 > > > > Regards > > Stefan > > > > > > On 2022-04-07 09:50, Lester Anderson wrote: > >> Hello all, > >> > >> Very basic query but how do you print all the values from a result via > >> mprintf? > >> > >> e.g. > >> > >> fac = factor(1729) > >> 7 13 19 > >> > >> mprintf('Factors of 1729 are: %d\n', fac) > >> just prints 'Factors of 1729 are: 7 > >> > >> Sorry for the basic question! > >> Cheers > >> Lester > >> > >> _______________________________________________ > >> users mailing list > >> users at lists.scilab.org > >> http://lists.scilab.org/mailman/listinfo/users > > _______________________________________________ > > users mailing list > > users at lists.scilab.org > > http://lists.scilab.org/mailman/listinfo/users > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arctica1963 at gmail.com Wed Apr 13 17:36:06 2022 From: arctica1963 at gmail.com (Lester Anderson) Date: Wed, 13 Apr 2022 16:36:06 +0100 Subject: [Scilab-users] Visualising Collatz sequences Message-ID: Hello all, I have prepared a code to generate Collatz sequences based on the even (n/2) and odd ((3n+1)/2) rules. clear function [ns, seq] = collatz(n) // Reference: https://en.wikipedia.org/wiki/Collatz_conjecture //ns =number of steps; seq=Collatz sequence seq(1) = n; // Position an index on the next element of the sequence i = 2; // Repeat the iteration until you find a 1 while seq(i-1) ~= 1 // Use modulo to define even/odd numbers if modulo(seq(i-1), 2) == 0 // Step taken if even seq(i) = seq(i-1)/2; else // Step taken if odd // seq(i) = 3*seq(i-1) + 1 // "3n+1 Collatz" seq(i) = (3*seq(i-1) + 1)/2; // "shortcut form Collatz" end // Increment index i = i+1; end // Find the length of the sequence ns = length(seq); endfunction n = input('Enter a positive integer: ') tic() for i = 1:n [nsi, seqi] = collatz(i); ns(i) = nsi; seq(1:nsi, i) = seqi; end // Find maxima in each Collatz sequence peak_values = max(seq, 'r') t=toc() mprintf('Elapsed time: %4.8f\n',t) What I would like to try is apply a further rule to generate a plot based on the Collatz sequences using left/right angular turn depending on whether the number is odd or even, going in reverse (starting at 1) and branching out. I can easily define the odd/even numbers in the sequence (modulo), but not sure how to apply the angle rotation for the graphic plot. Any pointers would be helpful. Attached an example image by way of reference. On a secondary point, the Collatz conjecture can be applied to negative values, but would be interested to know how the code has to be tweaked. If you stick a negative value in the code as is, it gets stuck in a loop. Thanks Lester -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Collatz_path_plot.png Type: image/png Size: 67094 bytes Desc: not available URL: From stephane.mottelet at utc.fr Wed Apr 13 17:42:39 2022 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Wed, 13 Apr 2022 17:42:39 +0200 Subject: [Scilab-users] Visualising Collatz sequences In-Reply-To: References: Message-ID: Hi, Maybe some hints there: https://community.wolfram.com/groups/-/m/t/558256 hth S. Le 13/04/2022 ? 17:36, Lester Anderson a ?crit?: > Hello all, > > I have prepared a code to generate Collatz sequences based on the even > (n/2) and odd ((3n+1)/2) rules. > > clear > > function [ns, seq] = collatz(n) > // Reference: https://en.wikipedia.org/wiki/Collatz_conjecture > //ns =number of steps; seq=Collatz sequence > seq(1) = n; > // Position an index on the next element of the sequence > i = 2; > > // Repeat the iteration until you find a 1 > while seq(i-1) ~= 1 > ? ? // Use modulo to define even/odd numbers > ? ? if modulo(seq(i-1), 2) == 0 > ? ? ? ? // Step taken if even > ? ? ? ? seq(i) = seq(i-1)/2; > ? ? else > ? ? ? ? // Step taken if odd > ? ? ? ? // seq(i) = 3*seq(i-1) + 1 // "3n+1 Collatz" > ? ? ? ? seq(i) = (3*seq(i-1) + 1)/2; // "shortcut form Collatz" > ? ? end > ? ? // Increment index > ? ? i = i+1; > end > // Find the length of the sequence > ns = length(seq); > endfunction > > n = input('Enter a positive integer: ') > tic() > > for ?i = 1:n > ? ?[nsi, seqi] = collatz(i); > ? ?ns(i) = nsi; > ? ?seq(1:nsi, i) = seqi; > end > > // Find maxima in each Collatz sequence > peak_values = max(seq, 'r') > > t=toc() > mprintf('Elapsed time: %4.8f\n',t) > > What I would like to try is apply a further rule to generate a plot > based on the Collatz sequences using left/right angular turn depending on > whether the number is odd or even, going in reverse (starting at 1) > and branching out. > > I can easily define the odd/even numbers in the sequence (modulo), but > not sure how to > apply the angle rotation for the graphic plot. Any pointers would be > helpful. > > Attached an example image by way of reference. > > On a secondary point, the Collatz conjecture can be applied to > negative values, but would be interested?to know how the code has to > be tweaked. If you stick a negative value in the code as is, it gets > stuck in a loop. > > Thanks > Lester > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet From stephane.mottelet at utc.fr Thu Apr 14 09:46:01 2022 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Thu, 14 Apr 2022 09:46:01 +0200 Subject: [Scilab-users] Visualising Collatz sequences In-Reply-To: References: Message-ID: Hi again, Here is a small code doing the graphic job: function X=anglePath(r, th) cumth = cumsum(th); X = cumsum([0 r.*cos(cumth);0 r.*sin(cumth)], 2); end function N=collatz(n) N = n; while n<>1 if modulo(n,2) == 0 n = n/2; else n = 3*n+1; end N = [n N]; end end a=0.08; e=1.2; clf gcf().color_map=graycolormap(128); for i=1:100 r=collatz(ceil(rand()*2000000000)); X=anglePath(r./(1+r.^1.2),a*%pi*(0.35-modulo(r,2))); plot(0.01+X(1,:),-0.01+X(2,:)); end collatz -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Figure%20n%C2%B00.jpg Type: image/jpeg Size: 43772 bytes Desc: not available URL: From cfuttrup at gmail.com Thu Apr 14 13:12:13 2022 From: cfuttrup at gmail.com (Claus Futtrup) Date: Thu, 14 Apr 2022 13:12:13 +0200 Subject: [Scilab-users] Combinatorics Message-ID: <6ce3fd8a-5ad0-721c-ebc5-7bf762d19476@gmail.com> Dear Scilabers I hope you can help me out. My combinatorics is a bit rusty. So, the spouse has purchased a lock and I wondered how many combinations are available? The lock has 10 push buttons, they are numbered 1-2-3-4-5-6-7-8-9-0. From a programming point of view, any of the numbers can be set on or off, meaning there are 2^10 = 1024 combinations, as far as I can see. I wonder how they are distributed, and how many of the numbers I should activate in the lock to maximize the number of combinations? Let's see, we have: None (none of the buttons are activated), there's exactly 1 combination for this situation. The lock is delivered from the manufacturer in this state. All (all of the buttons are activated), there's exactly 1 combination for this situation as well (no variability). One button pushed. There's obviously 10 possible combinations (push any one of the 10 buttons). Two buttons pushed. There's 10 * 9 / 2 = 45 combinations. Each button can only be pushed once, so once you've selected the first button, there's only 9 left, but also we divide by two because the combination are doubled, I mean for example the combination 1-2 = 2-1 ... the lock doesn't know the difference. If you spread out the possibilities in a 2D plane, it's like ignoring the diagonal (like pushing the same button twice) and also we either ignore the upper or lower triangle. Makes sense? Here starts my trouble. Three buttons pushed. Instead of looking at a 2D plane, I guess you spread out in 3D. The diagonal line is more than that - we have several planes where two of the three numbers are the same (and which are not allowed). To help myself out, I've tried to write all combinations where one of the push buttons is number 1. We select all combinations with the second button being either 2-3-4 and so on, and how many combinations do we then have for the third option? See table below: 1-2-x 8 1-3-x 7 1-4-x 6 1-5-x 5 1-6-x 4 1-7-x 3 1-8-x 2 1-9-0 1 36 We can then do the same for the first button = number 2, and we get : 7 + 6 + 5 + 4 + 3 + 2 + 1 = 28 combinations and so on. We get: 1-x-y 36 2-x-y 28 3-x-y 21 4-x-y 15 5-x-y 10 6-x-y 6 7-x-y 3 8-9-0 1 120 OK, so that was with three buttons pushed. It's always good to know the answer (if it's correct :-/ I hope it is), but it's a tedious process and I was wondering if you could point me to an easy calculation instead? ... Ideally something that expands to 4 and 5 buttons. I can 'invent' a calculation, which could be : =10*9*8/(3*2*1) = 120 ... if this indeed shows the internal workings, I'd like to know why. Sorry my combinatorics is so bad ... I haven't played in this field for a while. Best regards, Claus -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Thu Apr 14 13:38:37 2022 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Thu, 14 Apr 2022 13:38:37 +0200 Subject: [Scilab-users] Combinatorics In-Reply-To: <6ce3fd8a-5ad0-721c-ebc5-7bf762d19476@gmail.com> References: <6ce3fd8a-5ad0-721c-ebc5-7bf762d19476@gmail.com> Message-ID: <2b3253cc-7f30-4300-9387-cf17196ac4c1@utc.fr> Hi, Le 14/04/2022 ? 13:12, Claus Futtrup a ?crit?: > > Dear Scilabers > > I hope you can help me out. My combinatorics is a bit rusty. > > So, the spouse has purchased a lock and I wondered how many > combinations are available? > > The lock has 10 push buttons, they are numbered 1-2-3-4-5-6-7-8-9-0. > > From a programming point of view, any of the numbers can be set on or > off, meaning there are 2^10 = 1024 combinations, as far as I can see. > > I wonder how they are distributed, and how many of the numbers I > should activate in the lock to maximize the number of combinations? > The number of different subsets of k distincts elements of a set composed of n elements is the binomial coefficient (n,k). When n is even, it is maximized for k=n/2. Here -->? nchoosek(10, 5) ?ans? = ?? 252. S. > Let's see, we have: > > None (none of the buttons are activated), there's exactly 1 > combination for this situation. The lock is delivered from the > manufacturer in this state. > > All (all of the buttons are activated), there's exactly 1 combination > for this situation as well (no variability). > > One button pushed. There's obviously 10 possible combinations (push > any one of the 10 buttons). > > Two buttons pushed. There's 10 * 9 / 2 = 45 combinations. Each button > can only be pushed once, so once you've selected the first button, > there's only 9 left, but also we divide by two because the combination > are doubled, I mean for example the combination 1-2 = 2-1 ... the lock > doesn't know the difference. If you spread out the possibilities in a > 2D plane, it's like ignoring the diagonal (like pushing the same > button twice) and also we either ignore the upper or lower triangle. > Makes sense? > > Here starts my trouble. Three buttons pushed. Instead of looking at a > 2D plane, I guess you spread out in 3D. The diagonal line is more than > that - we have several planes where two of the three numbers are the > same (and which are not allowed). > > To help myself out, I've tried to write all combinations where one of > the push buttons is number 1. We select all combinations with the > second button being either 2-3-4 and so on, and how many combinations > do we then have for the third option? See table below: > > 1-2-x 8 > 1-3-x 7 > 1-4-x 6 > 1-5-x 5 > 1-6-x 4 > 1-7-x 3 > 1-8-x 2 > 1-9-0 1 > > 36 > > We can then do the same for the first button = number 2, and we get : > 7 + 6 + 5 + 4 + 3 + 2 + 1 = 28 combinations and so on. We get: > > 1-x-y 36 > 2-x-y 28 > 3-x-y 21 > 4-x-y 15 > 5-x-y 10 > 6-x-y 6 > 7-x-y 3 > 8-9-0 1 > > 120 > > OK, so that was with three buttons pushed. It's always good to know > the answer (if it's correct :-/ I hope it is), but it's a tedious > process and I was wondering if you could point me to an easy > calculation instead? ... Ideally something that expands to 4 and 5 > buttons. > > I can 'invent' a calculation, which could be : =10*9*8/(3*2*1) = 120 > ... if this indeed shows the internal workings, I'd like to know why. > Sorry my combinatorics is so bad ... I haven't played in this field > for a while. > > Best regards, > > Claus > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Thu Apr 14 16:29:11 2022 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Thu, 14 Apr 2022 16:29:11 +0200 Subject: [Scilab-users] Visualising Collatz sequences In-Reply-To: References: Message-ID: <56ad2d8d-e554-29f2-c931-8f5a81773028@utc.fr> You can also enjoy the 3d version: function X=anglePath3(r, th, ph) cumth = cumsum(th); cumph = cumsum(ph); X = cumsum([0 r.*sin(cumph) 0 r.*sin(cumth).*cos(cumph) 0 r.*cos(cumth).*cos(cumph)], 2); end function N=collatz(n) N = n; while n<>1 if modulo(n,2) == 0 n = n/2; else n = 3*n+1; end N = [n N]; end end a=0.1; e=1.3; clf NCOL=512; gcf().color_map=parulacolormap(NCOL); drawlater for i=1:200 r=collatz(grand(1,1,'uin',1,1000000)); m1=modulo(r,4); m2=m1; m1(m1>1)=0; m2(m2<=1)=0; X=anglePath3(r./(1+r.^e),a*%pi*(0.352-modulo(m1,2)),a*%pi*(0.352-modulo(m2,2))); x=rand(3,1)/8; param3d(x(1)+X(1,:),x(2)+X(2,:),x(3)+2*X(3,:)) gce().foreground=min(NCOL,length(r)) end isoview on drawnow Le 14/04/2022 ? 09:46, St?phane Mottelet a ?crit?: > > Hi again, > > Here is a small code doing the graphic job: > > function X=anglePath(r, th) > cumth = cumsum(th); > X = cumsum([0 r.*cos(cumth);0 r.*sin(cumth)], 2); > end > > function N=collatz(n) > N = n; > while n<>1 > if modulo(n,2) == 0 > n = n/2; > else > n = 3*n+1; > end > N = [n N]; > end > end > > a=0.08; > e=1.2; > > clf > gcf().color_map=graycolormap(128); > for i=1:100 > r=collatz(ceil(rand()*2000000000)); > X=anglePath(r./(1+r.^1.2),a*%pi*(0.35-modulo(r,2))); > plot(0.01+X(1,:),-0.01+X(2,:)); > end > -- > St?phane Mottelet > Ing?nieur de recherche > EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable > D?partement G?nie des Proc?d?s Industriels > Sorbonne Universit?s - Universit? de Technologie de Compi?gne > CS 60319, 60203 Compi?gne cedex > Tel : +33(0)344234688 > http://www.utc.fr/~mottelet > > _______________________________________________ > users mailing list > users at lists.scilab.org > https://antispam.utc.fr/proxy/v3?i=Zk92VEFKaGQ4Ums4cnZEUWMTpfHaXFQGRw1_CnOoOH0&r=bHA1dGV3NWJQVUloaWNFUYH-0fCrCfKNwGzaHK3mGAF34Dbd5QpdXfVRjdiNrR7K&f=SlhDbE9uS2laS2JaZFpNWvypxfeihkZF7xphlFhpLfOsI1HEbZ2YCuIwSI8iQL53&u=http%3A//lists.scilab.org/mailman/listinfo/users&k=XRKU -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From heinznabielek at me.com Thu Apr 14 16:49:07 2022 From: heinznabielek at me.com (Heinz Nabielek) Date: Thu, 14 Apr 2022 16:49:07 +0200 Subject: [Scilab-users] Visualising Collatz sequences In-Reply-To: <56ad2d8d-e554-29f2-c931-8f5a81773028@utc.fr> References: <56ad2d8d-e554-29f2-c931-8f5a81773028@utc.fr> Message-ID: <4B745A75-B082-4D68-AC79-8FAF2EAC263B@me.com> Beautiful picture... Heinz > On 14.04.2022, at 16:29, St?phane Mottelet wrote: > > function X=anglePath3(r, th, ph) > > > cumth = cumsum(th); > > > cumph = cumsum(ph); > > > X = cumsum([0 r.*sin(cumph) > > > 0 r.*sin(cumth).*cos(cumph) > > > 0 r.*cos(cumth).*cos(cumph)], 2); > end > > > > function N=collatz(n) > > > N = n; > > > while n<>1 > > > if modulo(n,2) == 0 > > > n = n/2; > > > else > > > n = 3*n+1; > > > end > > > N = [n N]; > > > end > end > > > > a=0.1; > e=1.3; > > > > clf > NCOL=512; > gcf().color_map=parulacolormap(NCOL); > drawlater > for i=1:200 > > > r=collatz(grand(1,1,'uin',1,1000000)); > > > m1=modulo(r,4); > > > m2=m1; > > > m1(m1>1)=0; > > > m2(m2<=1)=0; > > > X=anglePath3(r./(1+r.^e),a*%pi*(0.352-modulo(m1,2)),a*%pi*(0.352-modulo(m2,2))); > > > x=rand(3,1)/8; > > > param3d(x(1)+X(1,:),x(2)+X(2,:),x(3)+2*X(3,:)) > > > gce().foreground=min(NCOL,length(r)) > end > isoview on > drawnow From arctica1963 at gmail.com Thu Apr 14 17:28:09 2022 From: arctica1963 at gmail.com (Lester Anderson) Date: Thu, 14 Apr 2022 16:28:09 +0100 Subject: [Scilab-users] Visualising Collatz sequences In-Reply-To: <56ad2d8d-e554-29f2-c931-8f5a81773028@utc.fr> References: <56ad2d8d-e554-29f2-c931-8f5a81773028@utc.fr> Message-ID: Hi Stephane, Many thanks for the code pointers - graphics look fab! Cheers Lester On Thu, 14 Apr 2022 at 15:29, St?phane Mottelet wrote: > You can also enjoy the 3d version: > > function X=anglePath3(r, th, ph) > cumth = cumsum(th); > cumph = cumsum(ph); > X = cumsum([0 r.*sin(cumph) > 0 r.*sin(cumth).*cos(cumph) > 0 r.*cos(cumth).*cos(cumph)], 2);end > function N=collatz(n) > N = n; > while n<>1 > if modulo(n,2) == 0 > n = n/2; > else > n = 3*n+1; > end > N = [n N]; > endend > a=0.1;e=1.3; > clfNCOL=512;gcf().color_map=parulacolormap(NCOL);drawlaterfor i=1:200 > r=collatz(grand(1,1,'uin',1,1000000)); > m1=modulo(r,4); > m2=m1; > m1(m1>1)=0; > m2(m2<=1)=0; > X=anglePath3(r./(1+r.^e),a*%pi*(0.352-modulo(m1,2)),a*%pi*(0.352-modulo(m2,2))); > x=rand(3,1)/8; > param3d(x(1)+X(1,:),x(2)+X(2,:),x(3)+2*X(3,:)) > gce().foreground=min(NCOL,length(r))endisoview ondrawnow > > > Le 14/04/2022 ? 09:46, St?phane Mottelet a ?crit : > > Hi again, > > Here is a small code doing the graphic job: > > function X=anglePath(r, th) > cumth = cumsum(th); > X = cumsum([0 r.*cos(cumth);0 r.*sin(cumth)], 2);end > function N=collatz(n) > N = n; > while n<>1 > if modulo(n,2) == 0 > n = n/2; > else > n = 3*n+1; > end > N = [n N]; > endend > a=0.08;e=1.2; > clfgcf().color_map=graycolormap(128);for i=1:100 > r=collatz(ceil(rand()*2000000000)); > X=anglePath(r./(1+r.^1.2),a*%pi*(0.35-modulo(r,2))); > plot(0.01+X(1,:),-0.01+X(2,:));end > > > > -- > St?phane Mottelet > Ing?nieur de recherche > EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable > D?partement G?nie des Proc?d?s Industriels > Sorbonne Universit?s - Universit? de Technologie de Compi?gne > CS 60319, 60203 Compi?gne cedex > Tel : +33(0)344234688http://www.utc.fr/~mottelet > > > _______________________________________________ > users mailing listusers at lists.scilab.orghttps://antispam.utc.fr/proxy/v3?i=Zk92VEFKaGQ4Ums4cnZEUWMTpfHaXFQGRw1_CnOoOH0&r=bHA1dGV3NWJQVUloaWNFUYH-0fCrCfKNwGzaHK3mGAF34Dbd5QpdXfVRjdiNrR7K&f=SlhDbE9uS2laS2JaZFpNWvypxfeihkZF7xphlFhpLfOsI1HEbZ2YCuIwSI8iQL53&u=http%3A//lists.scilab.org/mailman/listinfo/users&k=XRKU > > -- > St?phane Mottelet > Ing?nieur de recherche > EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable > D?partement G?nie des Proc?d?s Industriels > Sorbonne Universit?s - Universit? de Technologie de Compi?gne > CS 60319, 60203 Compi?gne cedex > Tel : +33(0)344234688http://www.utc.fr/~mottelet > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From murusov at googlemail.com Fri Apr 15 17:59:09 2022 From: murusov at googlemail.com (Mikhail Urusov) Date: Fri, 15 Apr 2022 17:59:09 +0200 Subject: [Scilab-users] Combinatorics In-Reply-To: <6ce3fd8a-5ad0-721c-ebc5-7bf762d19476@gmail.com> References: <6ce3fd8a-5ad0-721c-ebc5-7bf762d19476@gmail.com> Message-ID: Dear Claus, Just in case you have not got an answer yet: > I can 'invent' a calculation, which could be : =10*9*8/(3*2*1) = 120 ... if this indeed shows the internal workings, I'd like to know why. Sorry my combinatorics is so bad ... I This is right. In general, the formula for the number of k-combinations of n elements is n! / ( k! (n-k)! ). Alternatively, you can write this as n*(n-1)*....*(n-k+1) / (k!). (This is the way you have written it above for n = 10 and k = 3.) The explanation in general is quite similar to this case: > Two buttons pushed. There's 10 * 9 / 2 = 45 combinations. Each button can only be pushed once, so once you've selected the first button, there's only 9 left, but also we divide by two because the combination are doubled, I mean for example the combination 1-2 = 2-1 ... the lock doesn't know the difference. If you spread out the possibilities in a 2D plane, it's like ignoring the diagonal (like pushing the same button twice) and also we either ignore the upper or lower triangle. Makes sense? For example, for n=10 and k=4: If you consider "arrangements", i.e., the combinations, where the order matters (e.g., 1-2-5-7 and 2-7-5-1 are different), then you have 10*9*8*7 such arrangements (for the first button you have 10 variants, for the second one 9 variants, etc), but each "combination" (that is, where the order does not matter) is counted 4! (=1*2*3*4) times (number of permutations of 4 elements), so you need to divide: (10*9*8*7)/(4!). For more information, see https://en.wikipedia.org/wiki/Combination Best regards, Mikhail Am Do., 14. Apr. 2022 um 13:51 Uhr schrieb Claus Futtrup : > Dear Scilabers > > I hope you can help me out. My combinatorics is a bit rusty. > > So, the spouse has purchased a lock and I wondered how many combinations > are available? > > The lock has 10 push buttons, they are numbered 1-2-3-4-5-6-7-8-9-0. > > From a programming point of view, any of the numbers can be set on or off, > meaning there are 2^10 = 1024 combinations, as far as I can see. > > I wonder how they are distributed, and how many of the numbers I should > activate in the lock to maximize the number of combinations? > > Let's see, we have: > > None (none of the buttons are activated), there's exactly 1 combination > for this situation. The lock is delivered from the manufacturer in this > state. > > All (all of the buttons are activated), there's exactly 1 combination for > this situation as well (no variability). > > One button pushed. There's obviously 10 possible combinations (push any > one of the 10 buttons). > > Two buttons pushed. There's 10 * 9 / 2 = 45 combinations. Each button can > only be pushed once, so once you've selected the first button, there's only > 9 left, but also we divide by two because the combination are doubled, I > mean for example the combination 1-2 = 2-1 ... the lock doesn't know the > difference. If you spread out the possibilities in a 2D plane, it's like > ignoring the diagonal (like pushing the same button twice) and also we > either ignore the upper or lower triangle. Makes sense? > > Here starts my trouble. Three buttons pushed. Instead of looking at a 2D > plane, I guess you spread out in 3D. The diagonal line is more than that - > we have several planes where two of the three numbers are the same (and > which are not allowed). > > To help myself out, I've tried to write all combinations where one of the > push buttons is number 1. We select all combinations with the second button > being either 2-3-4 and so on, and how many combinations do we then have for > the third option? See table below: > > 1-2-x 8 > 1-3-x 7 > 1-4-x 6 > 1-5-x 5 > 1-6-x 4 > 1-7-x 3 > 1-8-x 2 > 1-9-0 1 > > 36 > > We can then do the same for the first button = number 2, and we get : 7 + > 6 + 5 + 4 + 3 + 2 + 1 = 28 combinations and so on. We get: > > 1-x-y 36 > 2-x-y 28 > 3-x-y 21 > 4-x-y 15 > 5-x-y 10 > 6-x-y 6 > 7-x-y 3 > 8-9-0 1 > > 120 > > OK, so that was with three buttons pushed. It's always good to know the > answer (if it's correct :-/ I hope it is), but it's a tedious process and I > was wondering if you could point me to an easy calculation instead? ... > Ideally something that expands to 4 and 5 buttons. > > I can 'invent' a calculation, which could be : =10*9*8/(3*2*1) = 120 ... > if this indeed shows the internal workings, I'd like to know why. Sorry my > combinatorics is so bad ... I haven't played in this field for a while. > Best regards, > > Claus > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cfuttrup at gmail.com Fri Apr 15 19:14:32 2022 From: cfuttrup at gmail.com (Claus Futtrup) Date: Fri, 15 Apr 2022 19:14:32 +0200 Subject: [Scilab-users] Combinatorics In-Reply-To: References: <6ce3fd8a-5ad0-721c-ebc5-7bf762d19476@gmail.com> Message-ID: Hi Mikhail and Scilabers Thank you Mikhail for the equation with factorials, the URL to Wikipedia, and confirming my findings are OK (I really wasn't sure). Although the specifics of my case (with codes on a lock) seems very constrained and 'special' - I suppose it is common after all. It is interesting to see the math is quite simple. It is also interesting to see the 'distribution' of combinations: Buttons pushed 0 1 2 3 4 5 6 7 8 9 10 Sum = Combinations 1 10 45 120 210 252 210 120 45 10 1 1024 It is not that 'safe' of a lock because someone can decode it within an hour or so. If you take e.g. 5 seconds for trying each combo, we're talking about 1,4 hours to try all of them and maybe you hit jackpot somewhere in the middle. It is not advisable to choose 0 or 1 buttons for the code. Coding 5 random numbers to be pushed on the lock will give the highest number of combinations, but 4-6 buttons gives a suitable range of codes, 7 could also be OK. Although more buttons pushed gives fewer combinations, it's unlikely that e.g. a thief will start with a high number of buttons pushed (pure psychology). From a decoding point of view, the most interesting part of the lock is that it isn't as simple as decoding a combination lock with 3 dials where you can easily keep track of how far you are. It becomes complicated and one kinda needs a look-up table to try all the combinations and it requires more concentration to go through all the combinations. Cheers, Claus On 15-04-2022 17:59, Mikhail Urusov wrote: > Dear Claus, > > Just in case you have not got an answer yet: > > > I can 'invent' a calculation, which could be : =10*9*8/(3*2*1) = 120 > ... if this indeed shows the internal workings, I'd like to know why. > Sorry my combinatorics is so bad ... I > > This is right. In general, the formula for the number?of > k-combinations of n elements is > n! / ( k! (n-k)! ). > Alternatively, you can write this as > n*(n-1)*....*(n-k+1) / (k!). > (This is the?way you have written it above for n = 10 and k = 3.) > The explanation in general is quite similar to this case: > > > Two buttons pushed. There's 10 * 9 / 2 = 45 combinations. Each > button can only be pushed once, so once you've selected the first > button, there's only 9 left, but also we divide by two because the > combination are doubled, I mean for example the combination 1-2 = 2-1 > ... the lock doesn't know the difference. If you spread out the > possibilities in a 2D plane, it's like ignoring the diagonal (like > pushing the same button twice) and also we either ignore the upper or > lower triangle. Makes sense? > > For example, for n=10 and k=4: > If you consider "arrangements", i.e., the combinations, where the > order matters (e.g., 1-2-5-7 and 2-7-5-1 are different), then you have > 10*9*8*7 such arrangements (for the first button you have 10 variants, > for the second one 9 variants, etc), but each "combination" (that is, > where the order does not matter) is counted 4! (=1*2*3*4) times > (number of permutations of 4 elements), so you need to divide: > (10*9*8*7)/(4!). > For more information, see https://en.wikipedia.org/wiki/Combination > > Best regards, > Mikhail > > > Am Do., 14. Apr. 2022 um 13:51?Uhr schrieb Claus Futtrup > : > > Dear Scilabers > > I hope you can help me out. My combinatorics is a bit rusty. > > So, the spouse has purchased a lock and I wondered how many > combinations are available? > > The lock has 10 push buttons, they are numbered 1-2-3-4-5-6-7-8-9-0. > > From a programming point of view, any of the numbers can be set on > or off, meaning there are 2^10 = 1024 combinations, as far as I > can see. > > I wonder how they are distributed, and how many of the numbers I > should activate in the lock to maximize the number of combinations? > > Let's see, we have: > > None (none of the buttons are activated), there's exactly 1 > combination for this situation. The lock is delivered from the > manufacturer in this state. > > All (all of the buttons are activated), there's exactly 1 > combination for this situation as well (no variability). > > One button pushed. There's obviously 10 possible combinations > (push any one of the 10 buttons). > > Two buttons pushed. There's 10 * 9 / 2 = 45 combinations. Each > button can only be pushed once, so once you've selected the first > button, there's only 9 left, but also we divide by two because the > combination are doubled, I mean for example the combination 1-2 = > 2-1 ... the lock doesn't know the difference. If you spread out > the possibilities in a 2D plane, it's like ignoring the diagonal > (like pushing the same button twice) and also we either ignore the > upper or lower triangle. Makes sense? > > Here starts my trouble. Three buttons pushed. Instead of looking > at a 2D plane, I guess you spread out in 3D. The diagonal line is > more than that - we have several planes where two of the three > numbers are the same (and which are not allowed). > > To help myself out, I've tried to write all combinations where one > of the push buttons is number 1. We select all combinations with > the second button being either 2-3-4 and so on, and how many > combinations do we then have for the third option? See table below: > > 1-2-x 8 > 1-3-x 7 > 1-4-x 6 > 1-5-x 5 > 1-6-x 4 > 1-7-x 3 > 1-8-x 2 > 1-9-0 1 > > 36 > > We can then do the same for the first button = number 2, and we > get : 7 + 6 + 5 + 4 + 3 + 2 + 1 = 28 combinations and so on. We get: > > 1-x-y 36 > 2-x-y 28 > 3-x-y 21 > 4-x-y 15 > 5-x-y 10 > 6-x-y 6 > 7-x-y 3 > 8-9-0 1 > > 120 > > OK, so that was with three buttons pushed. It's always good to > know the answer (if it's correct :-/ I hope it is), but it's a > tedious process and I was wondering if you could point me to an > easy calculation instead? ... Ideally something that expands to 4 > and 5 buttons. > > I can 'invent' a calculation, which could be : =10*9*8/(3*2*1) = > 120 ... if this indeed shows the internal workings, I'd like to > know why. Sorry my combinatorics is so bad ... I haven't played in > this field for a while. > > Best regards, > > Claus > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From cfuttrup at gmail.com Sun Apr 17 18:01:18 2022 From: cfuttrup at gmail.com (Claus Futtrup) Date: Sun, 17 Apr 2022 18:01:18 +0200 Subject: [Scilab-users] Next release? Message-ID: Dear Scilab team Last release was 9 months ago and I was wondering if a new release is planned? What is the target for improvements to be included in the next release? Best regards, Claus From fmiyara at fceia.unr.edu.ar Mon Apr 25 10:00:08 2022 From: fmiyara at fceia.unr.edu.ar (Federico Miyara) Date: Mon, 25 Apr 2022 05:00:08 -0300 Subject: [Scilab-users] Strange behavior of explicit vs implicit iteration Message-ID: <90a17a5d-1b04-6671-aaca-ea9dc4844384@fceia.unr.edu.ar> Dear All, Here I have the following script, where I compute the same thing using two iteration methods: alfa = rand(1,10); Rpr = rand(); R = rand(); Z = rand(10,200); G = zeros(1,200); for i=1:200 A = 0; B = 0; for k = 1:10 A = A + Rpr*alfa(k) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); B = B + Rpr*(1 - alfa(k)) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); end G(i) = (1 + A) / (1 + B); end A = 1; B = 1; for k = 1:10 A = A + Rpr*alfa(k) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); B = B + Rpr*(1 - alfa(k)) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); end G1 = A ./ B; [M, ind] = max(abs(G- G1)) However, the last line shows that there are differences between both methods. They are tiny (near %eps), but I can't find nor imagine which is the reason. NOTE: I kept the original formulas as in the script where the problem arised but changed the data. When I tried to use a simpler formula there was no difference. Any idea? Regards, Federico Miyara -- El software de antivirus Avast ha analizado este correo electr?nico en busca de virus. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Mon Apr 25 10:31:26 2022 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Mon, 25 Apr 2022 10:31:26 +0200 Subject: [Scilab-users] Strange behavior of explicit vs implicit iteration In-Reply-To: <90a17a5d-1b04-6671-aaca-ea9dc4844384@fceia.unr.edu.ar> References: <90a17a5d-1b04-6671-aaca-ea9dc4844384@fceia.unr.edu.ar> Message-ID: <071669a8-ee89-b57b-eb32-298336c8a698@utc.fr> Hi Frederico, Rouding stuff is not a simple issue, but it's clear that your are not doing the computations in the same order, which could explain the difference. Here is a simpler example showing that the result depends on the order in which computations are done: --> x=rand(10,1,"normal"); --> sum([1;x])-sum([x;1]) ?ans? = ? -2.220D-16 Floating point addition is NOT associative. See e.g. https://en.wikipedia.org/wiki/Round-off_error S. Le 25/04/2022 ? 10:00, Federico Miyara a ?crit?: > > Dear All, > > Here I have the following script, where I compute the same thing using > two iteration methods: > > alfa = rand(1,10); > Rpr = rand(); > R = rand(); > Z = rand(10,200); > > G = zeros(1,200); > for i=1:200 > A = 0; > B = 0; > for k = 1:10 > A = A + Rpr*alfa(k) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); > B = B + Rpr*(1 - alfa(k)) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); > end > G(i) = (1 + A) / (1 + B); > end > > A = 1; > B = 1; > for k = 1:10 > A = A + Rpr*alfa(k) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); > B = B + Rpr*(1 - alfa(k)) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); > end > G1 = A ./ B; > > [M, ind] = max(abs(G- G1)) > However, the last line shows that there are differences between both > methods. They are tiny (near %eps), but I can't find nor imagine which > is the reason. > > NOTE: I kept the original formulas as in the script where the problem > arised but changed the data. When I tried to use a simpler formula > there was no difference. > > Any idea? > > Regards, > > Federico Miyara > > > Libre de virus. www.avast.com > > > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.crete at thalesgroup.com Mon Apr 25 10:25:16 2022 From: denis.crete at thalesgroup.com (CRETE Denis) Date: Mon, 25 Apr 2022 08:25:16 +0000 Subject: [Scilab-users] Strange behavior of explicit vs implicit iteration In-Reply-To: <90a17a5d-1b04-6671-aaca-ea9dc4844384@fceia.unr.edu.ar> References: <90a17a5d-1b04-6671-aaca-ea9dc4844384@fceia.unr.edu.ar> Message-ID: <5ed0f2d61d3d4f1f9dc1e1d8801f63de@thalesgroup.com> Hello, A the error is of the order of %eps, isn?t it expected ? This is related to the addition of ?1? which is done after the loop for the first case, and before the loop in the second case. Initializing to A and B to 1 in the first case gives exactly the result of the second case: ? for i=1:200 A = 1; //0; B = 1; //0; for k = 1:10 A = A + Rpr*alfa(k) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); B = B + Rpr*(1 - alfa(k)) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); end G(i) = A ./ B; // (1 + A) / (1 + B); end A = 1; B = 1; for k = 1:10 A = A + Rpr*alfa(k) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); B = B + Rpr*(1 - alfa(k)) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); end G1 = A ./ B; --> [M, ind] = max(abs(G - G1)) M = 0. ind = 1. Best regards Denis De : users De la part de Federico Miyara Envoy? : lundi 25 avril 2022 10:00 ? : Users mailing list for Scilab Objet : [Scilab-users] Strange behavior of explicit vs implicit iteration Dear All, Here I have the following script, where I compute the same thing using two iteration methods: alfa = rand(1,10); Rpr = rand(); R = rand(); Z = rand(10,200); G = zeros(1,200); for i=1:200 A = 0; B = 0; for k = 1:10 A = A + Rpr*alfa(k) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); B = B + Rpr*(1 - alfa(k)) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); end G(i) = (1 + A) / (1 + B); end A = 1; B = 1; for k = 1:10 A = A + Rpr*alfa(k) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); B = B + Rpr*(1 - alfa(k)) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); end G1 = A ./ B; [M, ind] = max(abs(G - G1)) However, the last line shows that there are differences between both methods. They are tiny (near %eps), but I can't find nor imagine which is the reason. NOTE: I kept the original formulas as in the script where the problem arised but changed the data. When I tried to use a simpler formula there was no difference. Any idea? Regards, Federico Miyara [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif] Libre de virus. www.avast.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From serge.steer at laposte.net Mon Apr 25 10:35:09 2022 From: serge.steer at laposte.net (serge.steer at laposte.net) Date: Mon, 25 Apr 2022 10:35:09 +0200 (CEST) Subject: [Scilab-users] Strange behavior of explicit vs implicit iteration Message-ID: <1208710007.1183928.1650875709604@wlpnf0219> ?Do not forget you are doing numerical computations. This king of calculus implies rounding (the data are stored with a finite number of bits...) This explains the differences you got. ? De : "Federico Miyara" A : "Users mailing list for Scilab" Envoy?: lundi 25 Avril 2022 10:01 Objet : [Scilab-users] Strange behavior of explicit vs implicit iteration ? Dear All, Here I have the following script, where I compute the same thing using two iteration methods: ? alfa = rand(1,10); Rpr = rand(); R = rand(); Z = rand(10,200); G = zeros(1,200); for i=1:200 A = 0; B = 0; for k = 1:10 A = A + Rpr*alfa(k) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); B = B + Rpr*(1 - alfa(k)) / (Z(k,i) + alfa(k)*(1 - alfa(k))*R); end G(i) = (1 + A) / (1 + B); end A = 1; B = 1; for k = 1:10 A = A + Rpr*alfa(k) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); B = B + Rpr*(1 - alfa(k)) ./ (Z(k,:) + alfa(k)*(1 - alfa(k))*R); end G1 = A ./ B; [M, ind] = max(abs(G - G1)) However, the last line shows that there are differences between both methods. They are tiny (near %eps), but I can't find nor imagine which is the reason. NOTE: I kept the original formulas as in the script where the problem arised but changed the data. When I tried to use a simpler formula there was no difference. Any idea? Regards, Federico Miyara ? Libre de virus. www.avast.com _______________________________________________ users mailing list users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Wed Apr 27 17:32:46 2022 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Wed, 27 Apr 2022 17:32:46 +0200 Subject: [Scilab-users] Sundials module, Windows preview Message-ID: Hi all, The next version of scilab will include a new module "Sundials". This module provides new full featured? ODE solvers: arkode(), cvode() and DAE solver ida(), all handling complex numbers and dense/sparse/banded Jacobians. Each solver has specific features, e.g. ida() handles DAE, arkode() handles mixed implicit/explicit Runge-Kutta methods and cvode() can do forward sensitivity computation. The module also includes a general-purpose nonlinear system solver: kinsol(), who takes advantage of the module architecture (parsing, computation engine and SUNDIALS abstraction of various linear solvers). Current help pages can be found @ https://www.utc.fr/~mottelet/scilab/sundials/ and a *Windows* build of Scilab (in addition to the already available macOS build) including the new module is available at https://www.utc.fr/~mottelet/scilab_for_macOS.html The help pages propose a lot of examples and two demos (this section is to be enriched) are available. Comments are welcome ! -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From iwoj at il.pw.edu.pl Fri Apr 29 12:49:22 2022 From: iwoj at il.pw.edu.pl (=?UTF-8?Q?Izabela_W=C3=B3jcik-Grz=C4=85ba?=) Date: Fri, 29 Apr 2022 12:49:22 +0200 Subject: [Scilab-users] Changing properties of mark_mode polyline in param3d1 Message-ID: Hello, I have a simple example of param3d1 graph: param3d1([1 2 3],[3 4 2],[5 2 4]); h=gce(); h.line_mode="off"; h.mark_mode="on"; h.mark_sytle=9; h.mark_size=1; h.mark_foreground=13; h.mark_background=13; I would like to ask if it's possible to change properties of marks individually? My main goal is to change colors using colormap according to the values assigned to each mark (point on the graph). As an illustration of my problem I give a vector of values and colors for the 3 points: [1 2 3] [red green blue] I know how to do it for line_mode="on", but for mark_mode the structure of figure is different. Thanks in advance for any help. Regards, Iza -- Izabela W?jcik-Grz?ba Zesp?? Konstrukcji Metalowych ZKBiM IIB WIL Politechnika Warszawska -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephane.mottelet at utc.fr Fri Apr 29 13:01:37 2022 From: stephane.mottelet at utc.fr (=?UTF-8?Q?St=c3=a9phane_Mottelet?=) Date: Fri, 29 Apr 2022 13:01:37 +0200 Subject: [Scilab-users] Changing properties of mark_mode polyline in param3d1 In-Reply-To: References: Message-ID: <569266d4-7103-c302-bcad-dace1986141f@utc.fr> Hello, You should rather use scatter3d, which allows to give different colors to markers (and scale the color wrt a given color vector) S. Le 29/04/2022 ? 12:49, Izabela W?jcik-Grz?ba a ?crit?: > > Hello, > > I have a simple example of param3d1 graph: > > param3d1([1 2 3],[3 4 2],[5 2 4]); > > h=gce(); > > h.line_mode="off"; > > h.mark_mode="on"; > > h.mark_sytle=9; > > h.mark_size=1; > > h.mark_foreground=13; > > h.mark_background=13; > > I would like to ask if it's possible to change properties of marks > individually? My main goal is to change colors using colormap > according to the values assigned to each mark (point on the graph). As > an illustration of my problem I give a vector of values and colors for > the 3 points: > > [1 2 3] > > [red green blue] > > I know how to do it for line_mode="on", but for mark_mode the > structure of figure is different. > > Thanks in advance for any help. Regards, > > Iza > > -- > Izabela W?jcik-Grz?ba > Zesp?? Konstrukcji Metalowych > ZKBiM IIB WIL Politechnika Warszawska > > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet -------------- next part -------------- An HTML attachment was scrubbed... URL: From iwoj at il.pw.edu.pl Fri Apr 29 17:01:14 2022 From: iwoj at il.pw.edu.pl (=?UTF-8?Q?Izabela_W=C3=B3jcik-Grz=C4=85ba?=) Date: Fri, 29 Apr 2022 17:01:14 +0200 Subject: [Scilab-users] Changing properties of mark_mode polyline in param3d1 In-Reply-To: <569266d4-7103-c302-bcad-dace1986141f@utc.fr> References: <569266d4-7103-c302-bcad-dace1986141f@utc.fr> Message-ID: <935e1729c2124b5f3452ee28d5b93f71@il.pw.edu.pl> The problem is that my real plot is made with param3d1 and consists of different elements: polylines with line_mode, with mark_mode, xstrings. It is now impossible to change the type. Kind regards, Iza --- Izabela W?jcik-Grz?ba Zesp?? Konstrukcji Metalowych ZKBiM IIB WIL Politechnika Warszawska W dniu 29.04.2022 13:01, St?phane Mottelet napisa?(a): > Hello, > > You should rather use scatter3d, which allows to give different colors to markers (and scale the color wrt a given color vector) > > S. > > Le 29/04/2022 ? 12:49, Izabela W?jcik-Grz?ba a ?crit : > >> Hello, >> >> I have a simple example of param3d1 graph: >> >> param3d1([1 2 3],[3 4 2],[5 2 4]); >> >> h=gce(); >> >> h.line_mode="off"; >> >> h.mark_mode="on"; >> >> h.mark_sytle=9; >> >> h.mark_size=1; >> >> h.mark_foreground=13; >> >> h.mark_background=13; >> >> I would like to ask if it's possible to change properties of marks individually? My main goal is to change colors using colormap according to the values assigned to each mark (point on the graph). As an illustration of my problem I give a vector of values and colors for the 3 points: >> >> [1 2 3] >> >> [red green blue] >> >> I know how to do it for line_mode="on", but for mark_mode the structure of figure is different. >> >> Thanks in advance for any help. Regards, >> >> Iza >> >> -- >> Izabela W?jcik-Grz?ba >> Zesp?? Konstrukcji Metalowych >> ZKBiM IIB WIL Politechnika Warszawska >> >> _______________________________________________ >> users mailing list >> users at lists.scilab.org >> http://lists.scilab.org/mailman/listinfo/users > > -- > St?phane Mottelet > Ing?nieur de recherche > EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable > D?partement G?nie des Proc?d?s Industriels > Sorbonne Universit?s - Universit? de Technologie de Compi?gne > CS 60319, 60203 Compi?gne cedex > Tel : +33(0)344234688 > http://www.utc.fr/~mottelet > > _______________________________________________ > users mailing list > users at lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.crete at thalesgroup.com Fri Apr 29 18:09:32 2022 From: denis.crete at thalesgroup.com (CRETE Denis) Date: Fri, 29 Apr 2022 16:09:32 +0000 Subject: [Scilab-users] Changing properties of mark_mode polyline in param3d1 In-Reply-To: <935e1729c2124b5f3452ee28d5b93f71@il.pw.edu.pl> References: <569266d4-7103-c302-bcad-dace1986141f@utc.fr> <935e1729c2124b5f3452ee28d5b93f71@il.pw.edu.pl> Message-ID: <4aee636ba80141ddbac17ea1ea437443@thalesgroup.com> Hello, This seems to work, param3d1([1 2 3;1 2 3],[3 4 2;3 4 2], list([5 2 4;5 2 4], [-2 -3 -4])); and then it is possible to change the colour of each ?pair of data point?. This is a bit simpler, but I did not try it: param3d1([1 2 3;1 2 3],[3 4 2;3 4 2], [5 2 4;5 2 4]); HTH Denis De : users De la part de Izabela W?jcik-Grzaba Envoy? : vendredi 29 avril 2022 17:01 ? : users at lists.scilab.org Objet : Re: [Scilab-users] Changing properties of mark_mode polyline in param3d1 The problem is that my real plot is made with param3d1 and consists of different elements: polylines with line_mode, with mark_mode, xstrings. It is now impossible to change the type. Kind regards, Iza --- Izabela W?jcik-Grz?ba Zesp?? Konstrukcji Metalowych ZKBiM IIB WIL Politechnika Warszawska W dniu 29.04.2022 13:01, St?phane Mottelet napisa?(a): Hello, You should rather use scatter3d, which allows to give different colors to markers (and scale the color wrt a given color vector) S. Le 29/04/2022 ? 12:49, Izabela W?jcik-Grz?ba a ?crit : Hello, I have a simple example of param3d1 graph: param3d1([1 2 3],[3 4 2],[5 2 4]); h=gce(); h.line_mode="off"; h.mark_mode="on"; h.mark_sytle=9; h.mark_size=1; h.mark_foreground=13; h.mark_background=13; I would like to ask if it's possible to change properties of marks individually? My main goal is to change colors using colormap according to the values assigned to each mark (point on the graph). As an illustration of my problem I give a vector of values and colors for the 3 points: [1 2 3] [red green blue] I know how to do it for line_mode="on", but for mark_mode the structure of figure is different. Thanks in advance for any help. Regards, Iza -- Izabela W?jcik-Grz?ba Zesp?? Konstrukcji Metalowych ZKBiM IIB WIL Politechnika Warszawska _______________________________________________ users mailing list users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -- St?phane Mottelet Ing?nieur de recherche EA 4297 Transformations Int?gr?es de la Mati?re Renouvelable D?partement G?nie des Proc?d?s Industriels Sorbonne Universit?s - Universit? de Technologie de Compi?gne CS 60319, 60203 Compi?gne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet _______________________________________________ users mailing list users at lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -------------- next part -------------- An HTML attachment was scrubbed... URL: From arctica1963 at gmail.com Sat Apr 30 07:14:54 2022 From: arctica1963 at gmail.com (Lester Anderson) Date: Sat, 30 Apr 2022 06:14:54 +0100 Subject: [Scilab-users] Variable user equation input (2, 3 or more) Message-ID: Hello all, I have a simple code which computes applies the Chinese Remainder theorem (for a single variable) given three input congruence equations to solve for x; not very elegant but it works: My query, is it possible to make this more generalised and vary the number of input equations and give the user an option to specify the number of equations? For example, one may have 2, 4 or more equations. Any pointers would be helpful. Thanks Lester clear // Chinese Remainder Theorem (CRT) for 3 congruence equations// e.g. x ? 3 mod 5; x ? 1 mod 7; x ? 6 mod 8// result ? 78 mod 280 m=evstr(x_dialog(['Moduli values: '],'1'));r=evstr(x_dialog(['Remainder values: '],'1'));m1=m(1); m2=m(2); m3=m(3);r1=r(1); r2=r(2); r3=r(3);n=evstr(x_dialog(['Number of iterations: '],'1')); M=m1*m2*m3;M1=M/m1; M2=M/m2; M3=M/m3; for i=1:n if modulo(((M1*i)-1),m1) == 0 then M1_inv=i; end if modulo(((M2*i)-1),m2) == 0 then M2_inv=i; end if modulo(((M3*i)-1),m3) == 0 then M3_inv=i; endend x1=(r1*M1*M1_inv);x2=(r2*M2*M2_inv);x3=(r3*M3*M3_inv); x = modulo((x1 + x2 + x3), M); messagebox(['x ? '+string(r1)'+' mod '+string(m1)' ... 'x ? '+string(r2)'+' mod '+string(m2)' ... 'x ? '+string(r3)'+' mod '+string(m3)' ... 'The solution for (x): '+string(x)+' mod '+string(M)'], ... 'Solution of 3 congruence equations') -------------- next part -------------- An HTML attachment was scrubbed... URL: From arctica1963 at gmail.com Sat Apr 30 13:09:35 2022 From: arctica1963 at gmail.com (Lester Anderson) Date: Sat, 30 Apr 2022 12:09:35 +0100 Subject: [Scilab-users] Variable user equation input (2, 3 or more) In-Reply-To: References: Message-ID: Cleaned up the code using Loops clear // Chinese Remainder Theorem (CRT) for 3 congruence equations// e.g. x ? 3 mod 5; x ? 1 mod 7; x ? 6 mod 8// result ? 78 mod 280 m=evstr(x_dialog(['Moduli values: '],'1'));a=evstr(x_dialog(['Remainder values: '],'1'));m1=m(1); m2=m(2); m3=m(3);a1=a(1); a2=a(2); a3=a(3);n=evstr(x_dialog(['Number of iterations: '],'1')); M=prod(m); for i=1:length(m) M_ratio(i) = M/m(i)end for i=1:length(m) for j=1:n if modulo(((M_ratio(i)*j)-1),m(i)) == 0 M_inv(i)=j; xn(i)=(a(i)*M_ratio(i)*M_inv(i)); end endend x = modulo(sum(xn),M) // Console output://mprintf('\nThe solution for (x): %d mod %d',x, M) messagebox(['x ? '+string(a1)'+' mod '+string(m1)' ... 'x ? '+string(a2)'+' mod '+string(m2)' ... 'x ? '+string(a3)'+' mod '+string(m3)' ... 'The solution for (x): '+string(x)+' mod '+string(M)'], ... 'Solution of 3 congruence equations') On Sat, 30 Apr 2022 at 06:14, Lester Anderson wrote: > Hello all, > > I have a simple code which computes applies the Chinese Remainder theorem > (for a single variable) given three input congruence equations to solve for > x; not very elegant but it works: > > My query, is it possible to make this more generalised and vary the number > of input equations and give the user an option to specify the number of > equations? > For example, one may have 2, 4 or more equations. > > Any pointers would be helpful. > > Thanks > Lester > > clear > // Chinese Remainder Theorem (CRT) for 3 congruence equations// e.g. x ? 3 mod 5; x ? 1 mod 7; x ? 6 mod 8// result ? 78 mod 280 > m=evstr(x_dialog(['Moduli values: '],'1'));r=evstr(x_dialog(['Remainder values: '],'1'));m1=m(1); m2=m(2); m3=m(3);r1=r(1); r2=r(2); r3=r(3);n=evstr(x_dialog(['Number of iterations: '],'1')); > M=m1*m2*m3;M1=M/m1; M2=M/m2; M3=M/m3; > for i=1:n > if modulo(((M1*i)-1),m1) == 0 then > M1_inv=i; > end > > if modulo(((M2*i)-1),m2) == 0 then > M2_inv=i; > end > > if modulo(((M3*i)-1),m3) == 0 then > M3_inv=i; > endend > x1=(r1*M1*M1_inv);x2=(r2*M2*M2_inv);x3=(r3*M3*M3_inv); > x = modulo((x1 + x2 + x3), M); > messagebox(['x ? '+string(r1)'+' mod '+string(m1)' ... > 'x ? '+string(r2)'+' mod '+string(m2)' ... > 'x ? '+string(r3)'+' mod '+string(m3)' ... > 'The solution for (x): '+string(x)+' mod '+string(M)'], ... > 'Solution of 3 congruence equations') > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arctica1963 at gmail.com Sat Apr 30 18:14:27 2022 From: arctica1963 at gmail.com (Lester Anderson) Date: Sat, 30 Apr 2022 17:14:27 +0100 Subject: [Scilab-users] Variable user equation input (2, 3 or more) In-Reply-To: References: Message-ID: Sorted the code with multiple equations. Not too sure how to deal with the messagebox list of equations. Still have to do that manually - unless there is a way to automatically build this? Can this multiple text string be done via a for loop to build a list ? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: