Community RSS Feed
https://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Wolfram Language sorted by active[Notebook] Coronavirus logistic growth model: Italy and South Korea
https://community.wolfram.com/groups/-/m/t/1887823
*MODERATOR NOTE: coronavirus resources & updates:* https://wolfr.am/coronavirus
----------
&[Italy and South Korea][1]
[1]: https://www.wolframcloud.com/obj/wolfram-community/Published/CoronaVirus_Logistic_Model.nbRobert Rimmer2020-02-26T02:18:26ZModeling the spatial spread of infection diseases in the US - Part 1
https://community.wolfram.com/groups/-/m/t/1889072
&[Wolfram Notebook][1]
[1]: https://www.wolframcloud.com/obj/dzviovich/Published/Computational%20Essay%20Disease%20Modeling%20Part%201.nbDiego Zviovich2020-02-28T01:10:46ZAn SEIR like model that fits the coronavirus infection data
https://community.wolfram.com/groups/-/m/t/1888335
I am updating and correcting this post: a simple SEIR model with some modifications (like a delay factor for the onset of recovery) fits the available data of the coronavirus infection in China. The infection rate is 2.7, the removal rate is .1, the rate at which an exposed person becomes infective is .055, and the total susceptible population is 180 000. The model suggests that containment method effectively removed most of the population away from the infection path. This also suggests that the spread of this pathogen is likely not to be very extensive if quick action is taken in removing individuals from the infection path. I will try to post a notebook when I am done with this, time allowing me to make it as simple as clutter free as possible. The (updated) graph below has the data (based on the JHU data publicly available) in red (with an adjustment for the change in counting method introduced along the way) and the I curve in blue. The dots in green are also data (recovered), and in magenta, the R curve. The start date is Jan 1 and it runs for 150 days.Enrique Garcia Moreno E.2020-02-26T16:43:12ZHas anyone encountered problems retrieving financial data of ETF like "SPY"
https://community.wolfram.com/groups/-/m/t/1780562
I have been trying to retrieve pricing of ETFs and always the output is Missing["NotAvailable"] which is information that FinancialData used to have.Eduardo Pollak2019-08-31T18:39:34ZSolve nonlinear complex numerical differential equations
https://community.wolfram.com/groups/-/m/t/1887985
Dear Wolfram community,
I have a nonlinear complexe system with twovariables.
system={
D[a[t, x], t] == a[t, x] + I Conjugate[ d[t, x]] Conjugate[ c[t, x]],
D[b[t, x], t] == b[t, x] + a[t, x] + I c[t, x]*d[t, x],
D[c[t, x], t] == c[t, x] + I (a[t, x] - b[t, x])*Conjugate[d[t, x]],
D[d[t, x], x] == I c[t, x],
a[t, 0] == 1, b[t, 0] == 1, c[t, 0] == I, d[t, 0] == 0,
a[0, x] == 1, b[0, x] == 1, c[0, x] == I, d[0, x] == 0};
solution = NDSolve[system, {a, b, c, d}, {t, 0, 10}, {x, 0, 10}]
and get as an error massage:
NDSolve:Some of the functions have zero differential order, so the equations will be solved as a system of differential-algebraic equations.
NDSolve: For the method NDSolve`IDA, only machine real code is available. Unable to continue with complex values or beyond floating-point exceptions.
What can I do to solve this system correctly.
Thank for your help.C. H.2020-02-26T14:04:44ZFree online training offered with 8-session programming tutorials
https://community.wolfram.com/groups/-/m/t/1874396
Users of the Wolfram Language are fired up to improve their knowledge and skills, and we're bringing a series of [programming tutorials][1] to Wolfram U to help meet this need, starting on February 18. Sessions meet on Tuesdays and Thursdays, and a weekly quiz will be offered to assess your progress. Wolfram Technology Certified Level I will be awarded to participants who successfully complete additional assigned problems.This is an ambitious project with comprehensive content, and I'd love to hear what people think of it. [Registration][2] is open now.
[1]: https://www.wolfram.com/wolfram-u/special-event/programming-concepts-to-applications/
[2]: https://attendee.gotowebinar.com/register/1764197596751908620?source=communityJamie Peterson2020-02-07T18:29:05Z[Notebook] Coronavirus logistic growth model: China
https://community.wolfram.com/groups/-/m/t/1887435
*MODERATOR NOTE: coronavirus resources & updates:* https://wolfr.am/coronavirus
----------
&[Wolfram Notebook][1]
[1]: https://www.wolframcloud.com/obj/wolfram-community/Published/CoronaVirusLogisticGrowthModel.nbRobert Rimmer2020-02-25T16:51:00ZSimplify sums with Kronecker deltas?
https://community.wolfram.com/groups/-/m/t/1887811
Hi, I am defining a sum using the following code:
mySum = Sum[a[i] b[i], {i, 1, n}]
Then I do:
myValue = D[mySum, a[k]]
Which naturally gives: $\sum _{i=1}^n b(i) \delta _{i,k}$. Since no assumptions are made, Mathematica can do nothing more to simplify the expression. But then I do:
Simplify[myValue, k >= 1 && k <= n]
Which mathematically is $b(k)$ under the assumptions that $k\geq 1$ and $k\leq n$. But the simplification is not made. Is there a natural way in which Mathematica can deal with such simplifications?
I am trying the trial version of Mathematica, and I have to decide whether to buy it or not. I did not have to much time to try everything, but I did my best. I also looked on the web, and there does not seem to be a natural solution there. I would like Mathematica to do the simplification automatically given the right assumptions.
Thank you!Guillaume Laporte2020-02-26T01:19:55ZDelete lines in a Wordlist.txt that contain specified chars
https://community.wolfram.com/groups/-/m/t/1888076
Hello community,
I started to learn Wolfram Mathematica v12.0 some days ago and now I want to solve a little Problem.
There is a Wordlist.txt with German, Chinese and some other signs/symbols in it.
Now I want to remove every line/word in it, that contains something different then “abc..., ABC....,123...., and !?”.
I did many exercises and one of them was about strings, but I don’t understand how to put those things together yet.
Thanks for some help, with best regards :3
p.s. sorry about my English, missed practicing a very long time :0Christian Ebert2020-02-26T15:44:38ZConvert a piecewise integer function into usable form such as a List?
https://community.wolfram.com/groups/-/m/t/1888300
The function **InverseFourierSequenceTransform** returns a Piecewise function. The display of the values is nice but the values are buried in the representation. I got along by descending the expression tree for the values, but today the expression 10<n<17 showed up - enough duplication of effort. I hope there is a Ma function that converts any Piecewise function into usable form. For a work-around I use pl=DiscretePlot which happily displays the data. In the display object the data points and values are at pl[[1, 1, 1, 1, 2, 1, 1, 2, -1, 1]] from which a SparseArray and then a Normal list are created.
![enter image description here][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ifst.png&userId=283713Douglas Kubler2020-02-26T20:18:03ZFit a spiral on given image?
https://community.wolfram.com/groups/-/m/t/1888512
Dear Wolfram community!
As a part of a project work, I'm trying to fit a spiral to the image below, in the Mathematica software.
![Shell of a snail][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=kep.jpg&userId=1888496
I figured out that I can track points on the image, after this, I converted these points to polar coordinates and I tried to fit a polar function to said points, however it does not really fit the image.
As an attachment, I uploaded my Notebook
Any help or tip is appreciated.Máté Gigacz2020-02-26T20:51:11ZDefine a range for this plot?
https://community.wolfram.com/groups/-/m/t/1888914
There are no other instructions anywhere for how to define a range. I hate this software. What am I doing wrong?
![enter image description here][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot_2020-02-26%28unnamed%29-WolframMathematica.png&userId=1888582Nick Kudatzky2020-02-27T00:54:34ZTry to beat these MRB constant records!
https://community.wolfram.com/groups/-/m/t/366628
POSTED BY: Marvin Ray Burns.
Autobiographies and his style: [http://marvinrayburns.com/aboutme.html][1]
![enter image description here][2]
![CMRB][3]
**C**<sub>*MRB*</sub> is defined below. See http://mathworld.wolfram.com/MRBConstant.html.
![CMRB][4]
.
**C**<sub>*MRB*</sub>
=![enter image description here][5]
=B=![enter image description here][6]
was first discovered by Richard Crandall of Apple.
It is proven here by Gottfried Helms:
![enter image description here][7]
At
[https://math.stackexchange.com/questions/1673886/is-there-a-more-rigorous-way-to-show-these-two-sums-are-exactly-equal][8],
it has been noted that even though one has cause to be a little bit wary around formal rearrangements of conditionally convergent sums (see the [Riemann series theorem][9]), it's not very difficult to validate the formal manipulation of Helms. The idea is to cordon off a big chunk of the infinite double summation (all the terms from the second column on) that we know is absolutely convergent, which we are then free to rearrange with impunity. (Most relevantly for our purposes here, see pages 80-85 of this [document][10], culminating with the Fubini theorem which is essentially the manipulation Helms is using.)
![argrument 1][11]
![argrument 2][12]
To see integrals for **C**<sub>*MRB*</sub> we use the AbelPlana formula:
![AbelPlana][13]
![AbelPlana proof2][14]
This was first applied to **C**<sub>*MRB*</sub> at
[https://math.stackexchange.com/questions/2564705/what-are-some-working-models-that-are-a-fit-the-formula-for-the-mrb-constant/3505694#3505694][15], giving
**C**<sub>*MRB*</sub>
![MRB integrals][16]
Also, in terms of the EulerRiemann zeta function,
**C**<sub>*MRB*</sub> =![enter image description here][17]
Above, where **C**<sub>*MRB*</sub>= ![k^(1/k)-1][18]
= ![D[eta(k)]][19]
= ![eta'(k)][20]
= ![sum from 0][21],
Dark Malthorp says:
> ![enter image description here][22]
As with any scientific paper, this post contains only reproducible results with methods. These records represent the advancement of consumer-level computers and clever programming over the past 20 years. I see others breaking these records, even after I die!
Map:
----
- First, we have these record number of digits of **C**<sub>*MRB*</sub>
computations.
- Then we have some hints for anyone serious about breaking my record.
- Followed by speed records,
- a program Richard Crandall wrote to check his code for computing record number of digits
- and a conversation about whether Mathematica uses the same algorithm for computing **C**<sub>*MRB*</sub> by a couple of different methods.
- Then, for a few replies, we compute **C**<sub>*MRB*</sub> from Crandall's
eta derivative formulas and see records there.
- There are three replies about "NEW RECORD ATTEMPTS OF 4,000,000 DIGITS!" and the computation is now complete!!!!!.
- We see where I am on a 5,000,000 digit calculation. **(Just recently completed!!!!!!!!!!!!)**
- I describe the MRB supercomputer!!!!!! (faster than some computers with dual platinum Xeon processors) It was used for the 5,000,000 digit calculation.
- Then it comes time for the 6 million digit computation of**C**<sub>*MRB*</sub>.
**MKB constant calculations,**
![enter image description here][23] ,
**have been moved to their discussion at**
[Calculating the digits of the MKB constant][24].
Here are some record computations. If you know of any others let me know.
1. On or about Dec 31, 1998, I computed 1 digit of the (additive inverse of ) **C**<sub>*MRB*</sub> with my TI-92s, by adding 1-sqrt(2)+3^(1/3)-4^(1/4)+... as far as I could. That first digit, by the way, is just 0. Then by using the sum feature, in approximate mode, to compute $\sum _{n=1}^{1000 } (-1)^n \left(n^{1/n}\right),$
I computed the first correct decimal of $\text{CMRB}=\sum _{n=1}^{\infty } (-1)^n \left(n^{1/n}-1\right)$ i.e. (.1). It gave (.1_91323989714) which is close to what Mathematica gives for summing to only an upper limit of 1000.
2. On Jan 11, 1999, I computed 4 decimals(.1878) of **C**<sub>*MRB*</sub> with the Inverse Symbolic Calculator, with the command evalf( 0.1879019633921476926565342538468+sum((-1)^n* (n^(1/n)-1),n=140001..150000)); were 0.1879019633921476926565342538468 was the running total of t=sum((-1)^n* (n^(1/n)-1),n=1..10000), then t= t+the sum from (10001.. 20000), then t=t+the sum from (20001..30000) ... up to t=t+the sum from (130001..140000).
3. In Jan of 1999, I computed 5 correct decimals (rounded to .18786)of **C**<sub>*MRB*</sub> using Mathcad 3.1 on a 50 MHz 80486 IBM 486 personal computer operating on Windows 95.
4. Shortly afterward I tried to compute 9 digits of **C**<sub>*MRB*</sub> using Mathcad 7 professional on the Pentium II mentioned below, by summing (-1)^x x^(1/x) for x=1 to 10,000,000, 20,000,000, and a many more, then linearly approximating the sum to a what a few billion terms would have given.
5. On Jan 23, 1999, I computed 500 digits of **C**<sub>*MRB*</sub> with an online tool called Sigma. Remarkably the sum in 4. was correct to 6 of the 9 decimal places! See
[http://marvinrayburns.com/Original_MRB_Post.html][25]
if you can read the printed and scanned copy there.
6. In September of 1999, I computed the first 5,000 digits of **C**<sub>*MRB*</sub> on a 350 MHz Pentium II with 64 Mb of RAM using the simple PARI commands \p 5000;sumalt(n=1,((-1)^n*(n^(1/n)-1))), after allocating enough memory.
7. On June 10-11, 2003 over a period, of 10 hours, on a 450 MHz P3 with an available 512 MB RAM, I computed 6,995 accurate digits of **C**<sub>*MRB*</sub>.
8. Using a Sony Vaio P4 2.66 GHz laptop computer with 960 MB of available RAM, at 2:04 PM 3/25/2004, I finished computing 8000 digits of **C**<sub>*MRB*</sub>.
9. On March 01, 2006, with a 3 GHz PD with 2 GB RAM available, I computed the first 11,000 digits of **C**<sub>*MRB*</sub>.
10. On Nov 24, 2006, I computed 40, 000 digits of **C**<sub>*MRB*</sub> in 33 hours and 26 min via my program written in Mathematica 5.2. The computation was run on a 32-bit Windows 3 GHz PD desktop computer using 3.25 GB of Ram.
The program was something like this:
Block[{a, b = -1, c = -1 - d, d = (3 + Sqrt[8])^n,
n = 131 Ceiling[40000/100], s = 0}, a[0] = 1;
d = (d + 1/d)/2; For[m = 1, m < n, a[m] = (1 + m)^(1/(1 + m)); m++];
For[k = 0, k < n, c = b - c;
b = b (k + n) (k - n)/((k + 1/2) (k + 1)); s = s + c*a[k]; k++];
N[1/2 - s/d, 40000]]
11. Finishing on July 29, 2007, at 11:57 PM EST, I computed 60,000 digits of **C**<sub>*MRB*</sub>. Computed in 50.51 hours on a 2.6 GHz AMD Athlon with 64 bit Windows XP. Max memory used was 4.0 GB of RAM.
12. Finishing on Aug 3, 2007, at 12:40 AM EST, I computed 65,000 digits of **C**<sub>*MRB*</sub>. Computed in only 50.50 hours on a 2.66 GHz Core 2 Duo using 64 bit Windows XP. Max memory used was 5.0 GB of RAM.
13. Finishing on Aug 12, 2007, at 8:00 PM EST, I computed 100,000 digits of **C**<sub>*MRB*</sub>. They were computed in 170 hours on a 2.66 GHz Core 2 Duo using 64 bit Windows XP. Max memory used was 11.3 GB of RAM. typical daily record of memory used was 8.5 GB of RAM.
14. Finishing on Sep 23, 2007, at 11:00 AM EST, I computed 150,000 digits of **C**<sub>*MRB*</sub>. They were computed in 330 hours on a 2.66 GHz Core 2 Duo using 64 bit Windows XP. Max memory used was 22 GB of RAM. typical daily record of memory used was 17 GB of RAM.
15. Finishing on March 16, 2008, at 3:00 PM EST, I computed 200,000 digits of **C**<sub>*MRB*</sub> using Mathematica 5.2. They were computed in 845 hours on a 2.66 GHz Core 2 Duo using 64 bit Windows XP. Max memory used was 47 GB of RAM. typical daily record of memory used was 28 GB of RAM.
16. Washed away by Hurricane Ike -- on September 13, 2008 sometime between 2:00 PM - 8:00 PM EST an almost complete computation of 300,000 digits of **C**<sub>*MRB*</sub> was destroyed. Computed for a long 4015. Hours (23.899 weeks or 1.4454*10^7 seconds) on a 2.66 GHz Core 2 Duo using 64 bit Windows XP. Max memory used was 91 GB of RAM. The Mathematica 6.0 code used follows:
Block[{$MaxExtraPrecision = 300000 + 8, a, b = -1, c = -1 - d,
d = (3 + Sqrt[8])^n, n = 131 Ceiling[300000/100], s = 0}, a[0] = 1;
d = (d + 1/d)/2; For[m = 1, m < n, a[m] = (1 + m)^(1/(1 + m)); m++];
For[k = 0, k < n, c = b - c;
b = b (k + n) (k - n)/((k + 1/2) (k + 1)); s = s + c*a[k]; k++];
N[1/2 - s/d, 300000]]
17. On September 18, 2008, computation of 225,000 digits of **C**<sub>*MRB*</sub> was started with a 2.66 GHz Core 2 Duo using 64 bit Windows XP. It was completed in 1072 hours. Memory usage is recorded in the attachment pt 225000.xls, near the bottom of this post.
18. 250,000 digits were attempted but failed to be completed to a serious internal error that restarted the machine. The error occurred sometime on December 24, 2008, between 9:00 AM and 9:00 PM. The computation began on November 16, 2008, at 10:03 PM EST. Like the 300,000 digit computation, this one was almost complete when it failed. The Max memory used was 60.5 GB.
19. On Jan 29, 2009, 1:26:19 pm (UTC-0500) EST, I finished computing 250,000 digits of **C**<sub>*MRB*</sub>. with a multiple-step Mathematica command running on a dedicated 64 bit XP using 4 GB DDR2 RAM onboard and 36 GB virtual. The computation took only 333.102 hours. The digits are at http://marvinrayburns.com/250KMRB.txt. The computation is completely documented in the attached 250000.PD at bottom of this post.
20. On Sun 28 Mar 2010 21:44:50 (UTC-0500) EST, I started a computation of 300000 digits of **C**<sub>*MRB*</sub> using an i7 with 8.0 GB of DDR3 RAM onboard, but it failed due to hardware problems.
21. I computed 299,998 Digits of **C**<sub>*MRB*</sub>. The computation began Fri 13 Aug 2010 10:16:20 pm EDT and ended 2.23199*10^6 seconds later |
Wednesday, September 8, 2010. I used Mathematica 6.0 for Microsoft
Windows (64-bit) (June 19, 2007) That is an average of 7.44 seconds per digit. I used my Dell Studio XPS 8100 i7 860 @ 2.80 GHz with 8GB physical DDR3 RAM. Windows 7 reserved an additional 48.929
GB virtual Ram.
22. I computed exactly 300,000 digits to the right of the decimal point
of **C**<sub>*MRB*</sub> from Sat 8 Oct 2011 23:50:40 to Sat 5 Nov 2011
19:53:42 (2.405*10^6 seconds later). This run was 0.5766 seconds per digit slower than the
299,998 digit computation even though it used 16 GB physical DDR3 RAM on the same machine. The working precision and accuracy goal
combination were maximized for exactly 300,000 digits, and the result was automatically saved as a file instead of just being displayed on the front end. Windows reserved a total of 63 GB of working memory of which 52 GB were recorded being used. The 300,000 digits came from the Mathematica 7.0 command
Quit; DateString[]
digits = 300000; str = OpenWrite[]; SetOptions[str,
PageWidth -> 1000]; time = SessionTime[]; Write[str,
NSum[(-1)^n*(n^(1/n) - 1), {n, \[Infinity]},
WorkingPrecision -> digits + 3, AccuracyGoal -> digits,
Method -> "AlternatingSigns"]]; timeused =
SessionTime[] - time; here = Close[str]
DateString[]
23. 314159 digits of the constant took 3 tries due to hardware failure. Finishing on September 18, 2012, I computed 314159 digits, taking 59 GB of RAM. The digits came from the Mathematica 8.0.4 code
DateString[]
NSum[(-1)^n*(n^(1/n) - 1), {n, \[Infinity]},
WorkingPrecision -> 314169, Method -> "AlternatingSigns"] // Timing
DateString[]
24. Sam Noble of Apple computed 1,000,000 digits of **C**<sub>*MRB*</sub> in 18 days 9 hours 11 minutes 34.253417 seconds.
25. Finishing on Dec 11, 2012, Richard Crandall, an Apple scientist, computed 1,048,576 digits
in a lightning-fast 76.4 hours computation time (from the timing command). That's on a 2.93 GHz 8-core Nehalem. In Aug of 2018, I computed 1,004,993 digits of **C**<sub>*MRB*</sub> in 53.5 hours with 10 DDR4 RAM (of up to 3000 MHz) supported processor cores overclocked up to 4.7 GHz! Search this post for "53.5" for documentation. Sept 21, 2018: I computed 1,004,993 digits of **C**<sub>*MRB*</sub> in 50.37 hours of absolute time (35.4 hours computation time) with 18 (DDR3 and DDR4) processor cores! Search this post for "50.37 hours" for documentation.** Finally, now, May 11, 2019, I computed over 1,004,993 digits, using 28 kernels on 18 DDR4 RAM (of up to 3200 MHz) supported cores overclocked up to 5.1 GHz in 45,5 hours of absolute time and only 32.5 hours of computation time! Search 'Documented in the attached ":3 fastest computers together 3.nb." ' for the post that has the attached documenting notebook.
26. I computed a little over 1,200,000 digits of **C**<sub>*MRB*</sub> in 11
days, 21 hours, 17 minutes, and 41 seconds (finishing on March 31, 2013). I used a six-core Intel(R) Core(TM) i7-3930K CPU @ 3.20 GHz 3.20 GHz.
27. On May 17, 2013, I finished a 2,000,000 or more digit computation of **C**<sub>*MRB*</sub>, using only around 10GB of RAM. It took 37 days 5 hours 6 minutes 47.1870579 seconds. I used my six-core Intel(R) Core(TM) i7-3930K CPU @ 3.20 GHz 3.20 GHz.
28. A previous world record computation of **C**<sub>*MRB*</sub> was finished on Sun 21 Sep 2014 at 18:35:06. It took 1 month 27 days 2 hours 45 minutes 15 seconds. The processor time from the 3,000,000+ digit computation was 22 days. I computed the 3,014,991 digits of **C**<sub>*MRB*</sub> with Mathematica 10.0. I Used my new version of Richard Crandall's code in the attached 3M.nb, optimized for my platform and large computations. I also used a six-core Intel(R) Core(TM) i7-3930K CPU @ 3.20 GHz with 64 GB of RAM of which only 16 GB was used. Can you beat it (in more number of digits, less memory used, or less time taken)? This confirms that my previous "2,000,000 or more digit computation" was accurate to 2,009,993 digits. they were used to check the first several digits of this computation. See attached 3M.nb for the full code and digits.
29. Finished on Wed 16 Jan 2019 19:55:20, I computed over 4 million digits of **C**<sub>*MRB*</sub>.
It took 4 years of continuous tries. This successful run took 65.13 days computation time, with a processor time of 25.17 days, on a 3.7 GHz overclocked up to 4.7 GHz on all cores Intel 6 core computer with 3000 MHz RAM. According to this computation, the previous record, 3,000,000+ digit computation, was accurate to 3,014,871 decimals, as this computation used my algorithm for computing n^(1/n) as found at chapter 3 in the paper at
https://www.sciencedirect.com/science/article/pii/0898122189900242
and the 3 million+ computation used Crandall's algorithm. Both algorithms outperform Newton's method per calculation and iteration.
See attached [notebook][26].
M R Burns' algorithm:
x = SetPrecision[x, pr];
y = x^n; z = (n - y)/y;
t = 2 n - 1; t2 = t^2;
x =
x*(1 + SetPrecision[4.5, pr] (n - 1)/t2 + (n + 1) z/(2 n t) -
SetPrecision[13.5, pr] n (n - 1) 1/(3 n t2 + t^3 z));
(*N[Exp[Log[n]/n],pr]*)
Example:
ClearSystemCache[]; n = 123456789;
(*n is the n in n^(1/n)*)
x = N[n^(1/n),100];
(*x starts out as a relatively small precision approximation to n^(1/n)*)
pc = Precision[x]; pr = 10000000;
(*pr is the desired precision of your n^(1/n)*)
Print[t0 = Timing[While[pc < pr, pc = Min[4 pc, pr];
x = SetPrecision[x, pc];
y = x^n; z = (n - y)/y;
t = 2 n - 1; t2 = t^2;
x = x*(1 + SetPrecision[4.5, pc] (n - 1)/t2 + (n + 1) z/(2 n t)
- SetPrecision[13.5, pc] n (n - 1)/(3 n t2 + t^3 z))];
(*You get a much faster version of N[n^(1/n),pr]*)
N[n - x^n, 10]](*The error*)];
ClearSystemCache[]; n = 123456789; Print[t1 = Timing[N[n - N[n^(1/n), pr]^n, 10]]]
Gives
{25.5469,0.*10^-9999984}
{101.359,0.*10^-9999984}
R Crandall's algorithm:
While[pc < pr, pc = Min[3 pc, pr];
x = SetPrecision[x, pc];
y = x^n - n;
x = x (1 - 2 y/((n + 1) y + 2 n n));];
(*N[Exp[Log[n]/ n],pr]*)
Example:
ClearSystemCache[]; n = 123456789;
(*n is the n in n^(1/n)*)
x = N[n^(1/n)];
(*x starts out as a machine precision approximation to n^(1/n)*)
pc = Precision[x]; pr = 10000000;
(*pr is the desired precision of your n^(1/n)*)
Print[t0 = Timing[While[pc < pr, pc = Min[3 pc, pr];
x = SetPrecision[x, pc];
y = x^n - n;
x = x (1 - 2 y/((n + 1) y + 2 n n));];
(*N[Exp[Log[n]/n],pr]*)
N[n - x^n, 10]](* The error*)]; Print[
t1 = Timing[N[n - N[n^(1/n), pr]^n, 10]]]
Gives
{32.1406,0.*10^-9999984}
{104.516,0.*10^-9999984}
More information available upon request.
30. Finished on Fri 19 Jul 2019 18:49:02, I computed over 5 million digits of **C**<sub>*MRB*</sub>.
Methods described in the reply below that starts with
"
Attempts at a 5,000,000 digit calculation
."
Here is my mini-cluster of the fastest 3 computers mentioned below:
The one to the left is my custom-built extreme edition 6 core and later with an 8 core Xeon processor.
The one in the center is my fast little 4 core Asus with 2400 MHz RAM.
Then the one on the right is my fastest -- a Digital Storm 6 core overclocked to 4.7 GHz on all cores and with 3000 MHz RAM.
![enter image description here][27]
[1]: http://marvinrayburns.com/aboutme.html
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=5106Capture.JPG&userId=366611
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1ac.JPG&userId=366611
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=295111f.JPG&userId=366611
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=11kc.JPG&userId=366611
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=11kc2.JPG&userId=366611
[7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=10297Capture.JPG&userId=366611
[8]: https://math.stackexchange.com/questions/1673886/is-there-a-more-rigorous-way-to-show-these-two-sums-are-exactly-equal
[9]: https://en.wikipedia.org/wiki/Riemann_series_theorem
[10]: https://www.math.ucdavis.edu/~hunter/intro_analysis_pdf/ch4.pdf
[11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=7211Capture.JPG&userId=366611
[12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=10837Capture.JPG&userId=366611
[13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=proof1.JPG&userId=366611
[14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=proof2.JPG&userId=366611
[15]: https://math.stackexchange.com/questions/2564705/what-are-some-working-models-that-are-a-fit-the-formula-for-the-mrb-constant/3505694#3505694
[16]: https://community.wolfram.com//c/portal/getImageAttachment?filename=798811g.JPG&userId=366611
[17]: https://community.wolfram.com//c/portal/getImageAttachment?filename=11i.JPG&userId=366611
[18]: https://community.wolfram.com//c/portal/getImageAttachment?filename=11ka.JPG&userId=366611
[19]: https://community.wolfram.com//c/portal/getImageAttachment?filename=11kc.JPG&userId=366611
[20]: https://community.wolfram.com//c/portal/getImageAttachment?filename=11j.JPG&userId=366611
[21]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1869Capture.JPG&userId=366611
[22]: https://community.wolfram.com//c/portal/getImageAttachment?filename=11k.JPG&userId=366611
[23]: http://community.wolfram.com//c/portal/getImageAttachment?filename=5860Capturemkb.JPG&userId=366611
[24]: http://community.wolfram.com/groups/-/m/t/1323951?p_p_auth=W3TxvEwH
[25]: http://marvinrayburns.com/Original_MRB_Post.html
[26]: https://community.wolfram.com/groups?p_auth=zWk1Qjoj&p_p_auth=r1gPncLu&p_p_id=19&p_p_lifecycle=1&p_p_state=exclusive&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=6&_19_struts_action=/message_boards/get_message_attachment&_19_messageId=1593151&_19_attachment=4%20million%2011%202018.nb
[27]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ezgif.com-video-to-gif.gif&userId=366611Marvin Ray Burns2014-10-09T18:08:49ZHow is a finite value boundary condition expressed?
https://community.wolfram.com/groups/-/m/t/1886232
I am trying to implement a calculation based on the demonstration "Transient Cooling of a Sphere." The Mathematica function NDSolveValue is used to solve a partial differential equation subject to one initial condition and two boundary conditions. One of the boundary conditions is that the solution must be finite at r=0. Symbolically, it is expressed as u{0,t]<Infinity. But if I use this form of the boundary condition in the NDSolveValue function, I get an error message that an equation or list of equations is expected. So what is the correct syntax for imposing this boundary condition within the NDSolveValue function?Jean Piquette2020-02-23T22:31:28ZArcSin seems to give an incorrect answer
https://community.wolfram.com/groups/-/m/t/1888601
Hi;
When I key the following code into a notebook:
Solve[8/Sin[36 Degree] == 5/[Beta],[Beta], Reals] // N
ArcSin[0.3674 Degree]
I get 0.00641238 for the answer to the 2nd line - see attached, which according to my TI-89 is incorrect. My TI-89 give the answer of 21.5554.
After reviewing the documentation, I still cannot understand what I am doing incorrectly. Additionally, I have used this command in the past, and it worked great.
Thanks,
MitchMitchell Sandlin2020-02-26T19:53:15ZObtain a Candlestickchart for BTC
https://community.wolfram.com/groups/-/m/t/1880037
Hello there,
I am new to this platform. I am facing the following problem.
How to create a candlestick chart or trading chart for bitcoin? I think it does not assume BTC as a part of financial data.
The usual code does not work :-
data = FinancialData["BTC", {{2015, 5, 1}, {2020, 2, 15}}];
CandlestickChart[data]
It returns the following statement -
CandlestickChart::ldata: Missing[NotAvailable] is not a valid dataset or list of datasets.
CandlestickChart::dtvals: Unable to automatically determine horizontal coordinates for the given data and DataRange.
Also can any data (not registered as financial data), be represented as candlestick chart data?
If anyone knows how to go about this problem, please do reply.
Thanks.Sheeba Pandey2020-02-16T22:00:53ZFind number of years for each animal from this system of equations
https://community.wolfram.com/groups/-/m/t/1887898
Dear all
I have the notebook calculation and i want to find how many years each animal lives: deer,bear,fox
Solve[nrAniVeverita == nrAniIepure - 3 &&
nrAniVulpea == 2*nrAnIepure &&
nrAniCerbul == 10 + nrAniVulpea &&
nrAniUrsul == nrAniCerbul + nrAniVulpea &&
nrAniCerbul + nrAniUrsul + nrAniVeverita + nrAniVulpea >= 110 &&
nrAniCerbul + nrAniUrsul + nrAniVeverita + nrAniVulpea <= 120,
{nrAniCerbul, nrAniUrsul, nrAniVeverita, nrAniVulpea}
]
The solver returns {}
Can you please help ?bogd timo2020-02-26T15:37:31ZCalculate basic reproduction number using next generation matrix
https://community.wolfram.com/groups/-/m/t/1887862
equationss := {s - d *T - \[Beta]*y*T, \[Beta]*y*T - \[Delta]*x, (1 - \[Rho]) (1 - \[Epsilon]) p*x - c*y, \[Rho] (1 - \[Epsilon]) p*x - c*z }
equilimpoints = Solve[equationss == {0, 0, 0, 0}, {T, x, y, z}] // Simplify
(* Jacobian Matrix*)
m:= D[{equationss}, {{T, x, y, z}}]// MatrixForm
CharacteristicPolynomial[m /. equilimpoints[[2]], \[Lambda]]
Eigenvalues[m /. equilimpoints[[2]]]
On the above problem, the CharastersticsPolynomial and Eigenvalues functions are not giving me any result, In addition to that, I wanted to calculate the Basic reproduction number of the system of ordinary differential equations using next-generation matrix method. However, I could not find any inbuilt function for this method. Can somebody point me in the right direction?
In a nut shell, here are my questions
1. Characteristic polynomial and Eigenvalues functions are not giving any result why?
2. is there any inbuilt function to calculate the basic reproduction number using the next-generation matrix?
Thank you before hand.Abiy Zeleke2020-02-26T05:49:12Z[CALL] Computer-Based Math(s) Module - Self-Study - Beta Testing
https://community.wolfram.com/groups/-/m/t/1840936
[![enter image description here][2]][3]
Dear community,
At computerbasedmaths.org (CBM) we are continually striving to broaden the audience of students that can experience learning through problem solving in a computer-based environment. With ongoing updates to the Wolfram Cloud, we are now in a position to adapt our desktop-teacher-centred delivery into self-study-browser delivery. To this end we have taken the CBM module Are girls better at maths? and removed the teacher functionalities and put in optional video inserts to assist the learner as required.
We would like to gather data on whether students of age 11-18 of any ability can follow the content (with or without parental support) and whether the structure of video introduction and follow-up review to each modality is something that works for them. If there are no students available, feedback from adults is also useful even if the content is already understood. It would be helpful to know how applicable the approach would be to adults and the types of adaptations we would need to make for this audience.
Please send feedback using the form at the end of the module.
**To access the module, please visit:** https://wolfr.am/CBM-SelfStudy
Expected duration to complete the module if learning this for the first time would be between 1 and 3 hours.
Please pass this on to students you know to have a go during the school break, give them the opportunity to learn real-world skills that are often missed in mainstream education.
Any questions or general suggestions, please ask in comments below.
Many thanks,
Alec Titterton, CBM Development Manager
----------
**Issues we are aware of and working on:**
- Moving to a new slide is not automatically scrolled up to the top.
- Answers are not retained between sessions.
- Chapter review page backgrounds are white, they should be coloured.
- Sidebars- Circled letters are slightly misaligned and dont have their explanatory tooltips (D = Define the question; A = Abstract to computable form; C = Compute; I = Interpret)
- 4-step bars have cell dingbat formatting issues.
- Navigation menu has slight text formatting issues in the styled chapter headings
**Functionality we are considering:**
- Adding a human tutor remotely (but asynchronously) to review text answers and assess projects.
- Accreditation for completion and certification.
----------
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=6807AGBAM.png&userId=778999
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2019-12-13at11.40.59AM.png&userId=20103
[3]: https://www.wolframcloud.com/env/CBM/SelfStudy/Content/English/AreGirlsBetterAtMaths.Student.nb#sidebar=none
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2019-12-13at11.51.56AM.png&userId=20103Alec Titterton2019-12-13T10:52:54ZManage large data quantity?
https://community.wolfram.com/groups/-/m/t/1887373
I have a very large quantity of information in a CVS file. I imported the data correctly but now I need to use FromDigits... and everytime that that I try the function, the Mathematica collapses and closes... any suggestions?Eddy Rey2020-02-25T20:24:55ZStep-by-step Solution to utilize Wolfram Engine in Amazon SageMaker
https://community.wolfram.com/groups/-/m/t/1887758
I am a data scientist from Amazon, specifically AWS AI, ML Solutions Lab. Wolfram Language / Mathematica is my "mother" language in programming world. Although none of the people I've met in Silicon Valley uses Wolfram Language, but I still hope to make it popular.
Amazon SageMaker is a fully managed service that provides every developer and data scientist with the ability to build, train, and deploy machine learning (ML) models quickly. SageMaker removes the heavy lifting from each step of the machine learning process to make it easier to develop high quality models.
Just like AWS's EC2 instances, SageMaker also allows you to pick an instance that best works with your computational demand. You can configure memory, storage & type, GPU, CPU, internet speed, etc.
In order to play Wolfram Language in the SageMaker, we need to install Wolfram Engine and activate Wolfram Script and use a font-end supporting package.
Step 1: Get Wolfram Engine.
```
sudo yum install wget
sudo wget http://dl.wolframcdn.com/0036F4/WolframEngine/12.0.1.0/WolframEngine_12.0.1_LINUX.sh
```
Step 2: Install Wolfram Engine:
sudo bash WolframEngine_12.0.1_LINUX.sh
---------------------------------------------------------------------------------------------------------------------------------------------------
Wolfram Engine 12.0 Installer
---------------------------------------------------------------------------------------------------------------------------------------------------
Copyright (c) 1988-2019 Wolfram Research, Inc. All rights reserved.
WARNING: Wolfram Engine is protected by copyright law and international treaties. Unauthorized reproduction or distribution may result in
severe civil and criminal penalties and will be prosecuted to the maximum extent possible under law.
Enter the installation directory, or press ENTER to select /usr/local/Wolfram/WolframEngine/12.0:
>
Now installing...
[************************************************************************************************************************************************]
Type the directory path in which the Wolfram Engine script(s) will be created, or press ENTER to select /usr/local/bin:
>
NOTE: Unable to determine the package manager used by the system--skipping the install of WolframScript system integration. Installer
packages in the RPM and DEB formats have been left in "/usr/local/Wolfram/WolframEngine/12.0/SystemFiles/Installation". Consult your system
documentation on how such packages might be installed.
WARNING: No Avahi Daemon was detected so some Kernel Discovery features will not be available. You can install Avahi Daemon using your
distribution's package management system.
Go to http://avahi.org for more information.
Installation complete.
Step 3: install Wolfram Script:
3.1: Check your machine type:
```
sh-4.2$ cat /etc/os-release
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
```
The .*deb* files are meant for distributions of *Linux* that derive from *Debian* (Ubuntu, *Linux* Mint, etc.). The .*rpm* files are used primarily by distributions that derive from *Redhat* based distros (*Fedora*, CentOS, RHEL) as well as by the openSuSE distro.
Based on different machine, you will need to install wolfram script in different ways:
```
cd /usr/local/Wolfram/WolframEngine/12.0/SystemFiles/Installation
```
```
sh-4.2$ sudo yum localinstall wolframscript-1.3-2019101401.x86_64.rpm
Loaded plugins: dkms-build-requires, priorities, update-motd, upgrade-helper, versionlock
Examining wolframscript-1.3-2019101401.x86_64.rpm: wolframscript-1.3-2019101401.x86_64
Marking wolframscript-1.3-2019101401.x86_64.rpm to be installed
Resolving Dependencies
amzn-main/latest | 2.1 kB 00:00:00
amzn-updates/latest | 2.5 kB 00:00:00
--> Running transaction check
---> Package wolframscript.x86_64 0:1.3-2019101401 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================
Installing:
wolframscript x86_64 1.3-2019101401 /wolframscript-1.3-2019101401.x86_64 5.2 M
Transaction Summary
=======================================================================================================================
Install 1 Package
Total size: 5.2 M
Installed size: 5.2 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wolframscript-1.3-2019101401.x86_64 1/1
/var/tmp/rpm-tmp.wVqwLo: line 5: xdg-icon-resource: command not found
/var/tmp/rpm-tmp.wVqwLo: line 5: xdg-icon-resource: command not found
/var/tmp/rpm-tmp.wVqwLo: line 5: xdg-icon-resource: command not found
/var/tmp/rpm-tmp.wVqwLo: line 11: xdg-mime: command not found
warning: %post(wolframscript-1.3-2019101401.x86_64) scriptlet failed, exit status 127
Non-fatal POSTIN scriptlet failure in rpm package wolframscript-1.3-2019101401.x86_64
Verifying : wolframscript-1.3-2019101401.x86_64 1/1
Installed:
wolframscript.x86_64 0:1.3-2019101401
```
Step 4: The last step is to activiate your engine with your developer account, and it's free!
```
wolframscript -activate
```
A simple test:
```
wolframscript wolframscript -code 2+2
```
Step 5: You also will need to get the Jupyter frontend support:
cd to a directory as you desires:
```shell
sh-4.2$ git clone https://github.com/WolframResearch/WolframLanguageForJupyter.git
Cloning into 'WolframLanguageForJupyter'...
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 511 (delta 0), reused 0 (delta 0), pack-reused 509
Receiving objects: 100% (511/511), 275.56 KiB | 4.30 MiB/s, done.
Resolving deltas: 100% (318/318), done.
sh-4.2$ cd WolframLanguageForJupyter/
sh-4.2$ ls
configure-jupyter.wls CONTRIBUTING.md extras images LICENSE README.md WolframLanguageForJupyter
sh-4.2$ ./configure-jupyter.wls add
```
And you will see your Wolfram Kernel in your launch page! Have fun folks!
![enter image description here][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2020-02-2514.57.28.png&userId=524853Wenzhen Zhu2020-02-25T23:04:30ZHow to make Manipulate / Dynamic work in JupyterLab
https://community.wolfram.com/groups/-/m/t/1887748
Hello, I am a data scientist in Amazon, due to some security and customer privacy reasons, we are not allowed to playing data on local machine, all the data must be stored in S3 bucket for security, and the only interface we can use to access the data is Amazon SageMaker notebooks.
I have always been a huge fan of Dynamic and Manipulate functionality for almost 10 years, and would like to keep using Wolfram Language in industry data science, where Python is the only language people use now. And I was happy to see that WolframEngine is finally free for developers, which made it possible to convince my co-workers to try.
However, I found the JupyterLab does not support Manipulate and Dynamic functionality, is there any Jupyter front end extension can solve my problem? Right now it's just impossible to display anything normally.
![enter image description here][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2020-02-2514.44.54.png&userId=524853Wenzhen Zhu2020-02-25T22:45:46ZImprove (enhance) an image
https://community.wolfram.com/groups/-/m/t/1887653
Hello community.
I'm trying to work on an image and would like to know if any image specialists here know how to improve the visualization of this photo??
**Note:** my goal is just to study how to improve the visualization of an image through *Wolfram Language*.
(This photo was taken with the cell phone. It was sent to me in .jpg format)
Below is the original photo (attached to the post):
![im1][1]
Something caught my eye in this image (like a statue, a person or maybe it´s nothing). Below is my attempt to be able to see more clearly (as I am not an expert in image treatment yet, I would like to ask here in the community for ideas):
EvaluationData[
data1 = Flatten@
Table[Show[ColorBalance[data, RGBColor[{0 + x, 0 + y, 0 + z}]],
ImageSize -> Large], {x, 0.3, 1, 0.1}, {y, 0.3, 1, 0.1}, {z, 0.3,
1, 0.1}]; oi = ImageAdjust[data1[[130]], {0.5, 0, 0.4}];
data2 = ImageExposureCombine@
Flatten@Table[
Show[ImageAdjust[
ImagePartition[data1[[i]], UpTo[Scaled[7/24]]][[3, 4]], {0.5,
0, 0.4}], ImageSize -> Large], {i, 1, Length@data1}];
data3 = ImageExposureCombine@
Table[Binarize[data2,
Method -> i], {i, {{"BlackFraction", 0.33}, "Mean", "Median"}}];
Do[Print[
k], {k, {oi, {Show[data2, ImageSize -> 250],
Show[data3, ImageSize -> 250]}}}]]
![im2][2]
Any idea of how to improve the code or the quality of the visualization is welcome.
Thanks.
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1387im1.png&userId=1316061
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=6869im2.png&userId=1316061Claudio Chaib2020-02-25T22:41:28ZSolve system of diff-algebraic equations with periodic boundary-conditions?
https://community.wolfram.com/groups/-/m/t/1887211
Hi,
I have a system of differential-algebraic equations DAEs. I have periodic boundary conditions. When using NDSolve, I got a message that in DAE only initial conditions are expected. Is there any way in Mathematica to solve the system of DAEs with periodic boundary conditions like x1[t_0]==x1[t_f]?Maha Youssef2020-02-25T13:38:17ZRunning Wolfram Mathematica inside Jupiter Notebook in Google Cloud + GPUs
https://community.wolfram.com/groups/-/m/t/1884517
I am a Data Scientist working in a startup in Brazil. Recently I was working with Social Networks in Python using networkx library to analyse posts from a given hashtag for our client. However, I was completely aware of the additional functionalities of Wolfram Mathematica. Take the following picture as an example, done with networkx, 100,000 people:
![Social Network Emotions Connections][1]
It's an interesting perspective, but adds little value to generate strategic insights for our clients, given that we need to zoom it to analyze details of this network. In my previous experience of Wolfram Mathematica, I was able to use some reasoning coming from cellular automata interactions to map, track people of interest (blue circle), and watch the evolution of mood (color), number of connections (size of circle) in a social network:
![Evolution of Mood][2]
Besides, one can use Mathematica's features of finding communities, coloring them and even highlight people of interest when passing the mouse over the social network and also speaking their names:
![Communities][3]
More than that, you can highlight communities and check the number of connections of each individual:
![Communities Two][4]
So, it's clear that Wolfram Mathematica is way ahead of networkx. However, I was dealing with a drawback: if you choose to plot more than 10,000 connections in Mathematica, that can take some time. And time is what you don't have in a startup. So, I started wondering how I could use GPUs with Wolfram Mathematica. One way it's to use webMathematica, installing Java and Apache Tomcat in a cloud instance. However, I was told one can also use Wolfram Client Python library and run Mathematica in a Python notebook.
So, I will present how I was able to run Mathematica inside a Jupyter notebook located in a Google Cloud instance with 8 V100 GPUs. My co-worker, Gustavo Gouvea, also put efforts in this solution.
First of all, go to Google Cloud Platform (GCP) Compute Engine and select Create Instance in a given region. Choose your CPUs, Memory, GPUs and regarding the boot disk, I used Debian GNU/Linux with Anaconda, PyTorch and CUDA already installed, as we also work with Deep Learning and NLP.
After that, you need to configure Jupyter in order to be able to open it in the local browser, by doing the following:
ipython
from IPython.lib import passwd
passwd()
Now that you created the password, you are going to save "sha1:49b8799c22..."
Then you will edit Jupyter configuration file (use sudo or chmod -R 777 /home/anaconda3):
sudo vi ~/.jupyter/jupyter_notebook_config.py
Add (type "i") these line of code:
c=get_config()
c.NotebookApp.password = paste your sha1 here
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.ip = "*" or 0.0.0.0
c.NotebookApp.open_browser = False
Go to GCP VPC and create a static IP for your instance, SSH into it.
So, to start Jupyter notebook you will need to run:
jupyter notebook
![Jupyter][5]
Now you will access Jupyter in the following address:
http://http://55.100.30.200:8888/
![Jupyter 2][6]
That will allow you to run Python notebooks in Jupyter. Now Mathematica. Get the mathematica .sh file:
sudo wget link_to_mathematica.sh
To install Mathematica run in another SSH session (terminal window):
sudo bash link_to_mathematica.sh
Ok, you installed Mathematica. Now run:
math
This command will ask for your Activation key and Password. After providing them, Mathematica notebook starts in the command line
![Mathematica running][7]
**Important:** You must run Mathematica ("math") **before** you open Jupyter Notebook.
Now that you've opened Mathematica in the command line with one SSH and after that Jupyter Notebook in other SSH, access the web address, port 8888, create a new Python 3 notebook and install wolframclient library:
![pip install][8]
Now you can run your Mathematica scripts with backup of how many GPUs you need:
![NVIDIA-SMI][9]
from wolframclient.language import wl as w1
from wolframclient.language import wlexpr
from wolframclient.evaluation import WolframLanguageSession
session = WolframLanguageSession('/usr/local/Wolfram/Mathematica/12.0/Executables/MathKernel')
import numpy as np
import imageio
import matplotlib.pyplot as plt
from PIL import Image
![Output][10]
In bird's eye:
![Overview][11]
![enter image description here][12]
The only point is that you won't have access to all Mathematica functionalities, as Manipulate, Mouse Over and the display of some images when output is truncated. My guess is that init.m config file must be adjusted to increase output size before truncation (in the command line) :
![GraphPlot][13]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Easter0.PNG&userId=992056
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=0.jpeg&userId=992056
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=01.png&userId=992056
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=02.png&userId=992056
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2918jupy.png&userId=992056
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=jupyter.png&userId=992056
[7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pp.png&userId=992056
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pip.png&userId=992056
[9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=nvidia.png&userId=992056
[10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=py.png&userId=992056
[11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=bird.png&userId=992056
[12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=sss.png&userId=992056
[13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=issues.png&userId=992056Rubens Zimbres2020-02-21T00:39:03Z[Notebook] A walk-through of the SARS-CoV-2 nucleotide Wolfram resource
https://community.wolfram.com/groups/-/m/t/1887456
*MODERATOR NOTE: coronavirus resources & updates:* https://wolfr.am/coronavirus
----------
&[Wolfram Notebook][1]
[1]: https://www.wolframcloud.com/obj/wolfram-community/Published/CoronavirusNucleotidesWDRPresentation.nbJohn Cassel2020-02-25T17:33:03ZPlot from irrational end points?
https://community.wolfram.com/groups/-/m/t/1886823
I have a function that Wolfram Alpha provides numerical solutions. See image...
![enter image description here][1]
These are clearly not integers and probably not rational numbers. How do I plot this function? Each time I do I get the response "end points are not on curve." See image.
![enter image description here][2]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=numericalsolutions.jpg&userId=1886309
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=endpointsnotoncurve.jpg&userId=1886309
I have tried even using the values Wolfram alpha provided, but I still get the same response. Any ideas how I could plot this? Seems Wolfram Alpha should be able to do it, as it provided me a small handful of great numerical examples. But I would like to plot more.Jeffrey N Cook2020-02-24T19:50:20ZRepeated solving of PDE with changing (boundary) conditions by NDSolve
https://community.wolfram.com/groups/-/m/t/1887169
Dear all,
I am new to this forum and it would be glad to get some help of your guys. I am trying to solve a system of PDEs but for a better understanding and clarity I created a simplified test case, see attached file. So please do not care about the physical meaning, it is just a test case.
What is the problem:
I have got several systems of PDEs and I using NDSolve to get the solutions. The system of PDE changes depending on the solution. Hence, I am using the output of the first system of PDEs as an input for the second system of PDEs. The output of the second system of PDEs is the input of the first system of PDEs and so on. I would like to do this several times. Of course, I can do copy paste but this is not efficient. The first initial condition is a good guess.
I need the solution of each loop of each system of PDEs. I tried to understand the following functions “Nest”, “Module”, “Do”, “For” etc. but I did not get a working solution.
&[Wolfram Notebook][1]
Thanks in advance for your help!
[1]: https://www.wolframcloud.com/obj/416574c5-70d2-46f7-aa72-99b94f8edb4eFerdinand C2020-02-25T12:24:06Z[UPDATES] Resources For Novel Coronavirus COVID-19
https://community.wolfram.com/groups/-/m/t/1872608
![enter image description here][1]
*TO SHARE THIS POST:* https://wolfr.am/coronavirus
*INTERACTIVE DASHBOARD:* https://wolfr.am/COVID19Dashboard
----------
This post is intended to be the hub for Wolfram resources related to novel coronavirus COVID-19 ( a.k.a. 2019-nCoV ) from Wuhan, China. The larger aim is to provide a forum for disseminating ways in which Wolfram technologies and coding can be utilized to shed light on the virus and epidemic. Possibilities include using the Wolfram Language for data-mining, modeling, analysis, visualizations, and so forth. Among other things, we encourage comments and feedback on these resources. Please note that this is intended for technical analysis and discussion supported by computation. Aspects outside this scope and better suited for different forums should be avoided. Thank you for your contribution!
## Data Sources
We have published and are continuously updating the following Wolfram Data Repository entries:
> **Genetic Sequences for the SARS-CoV-2 Coronavirus**
> https://datarepository.wolframcloud.com/resources/Genetic-Sequences-for-the-SARS-CoV-2-Coronavirus
> **Epidemic Data for Novel Coronavirus COVID-19**
> https://www.wolframcloud.com/obj/resourcesystem/published/DataRepository/resources/Epidemic-Data-for-Novel-Coronavirus-COVID-19
> **Patient Medical Data for Novel Coronavirus COVID-19**
> https://datarepository.wolframcloud.com/resources/Patient-Medical-Data-for-Novel-Coronavirus-COVID-19
## Computational Articles:
We encourage you to share your computational explorations relevant to coronavirus on Wolfram Community as stand-alone articles and then comment with their URL links on this discussion thread. We will summarize these articles in the following list:
> **Genome analysis and the SARS-nCoV-2** by Daniel Lichtblau
> https://community.wolfram.com/groups/-/m/t/1874816
> **A walk-through of the SARS-CoV-2 nucleotide Wolfram resource** by John Cassel
> https://community.wolfram.com/groups/-/m/t/1887456
> **Geometrical analysis of genome for COVID-19 vs SARS-like viruses** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1878824
> **Chaos Game For Clustering of Novel Coronavirus COVID-19** by Mads Bahrami
> https://community.wolfram.com/groups/-/m/t/1875994
> **Coronavirus logistic growth model: China** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1887435
> **Coronavirus logistic growth model: Italy and South Korea** by Robert Rimmer
> https://community.wolfram.com/groups/-/m/t/1887823
> **Mapping Novel Coronavirus COVID-19 Outbreak** by Jofre Espigule-Pons
> https://community.wolfram.com/groups/-/m/t/1868945
> **Visualizing Sequence Alignments from the COVID-19** by Jessica Shi
> https://community.wolfram.com/groups/-/m/t/1875352
## Video Recordings
- John Cassel - [Behind the Genetic Sequences for Novel Coronavirus SARS-CoV-2][2]
- Keiko Hirayama - [Patient Data Exploration for the Novel Coronavirus COVID-19][3]
- Keiko Hirayama - [Epidemic Data Exploration for the Novel Coronavirus COVID-19][4]
- Arnoud Buzing - [Data Science for Coronavirus][5]
- Rory Foulger - [Coronavirus Data Exploration - Wolfram Livecoding with Students][6]
## Other useful resources:
- Arnoud Buzing [GitHub][7] repository and [Notebook Gallery][8] for coronavirus
- [Modeling a Pandemic like Ebola with the Wolfram Language](https://blog.wolfram.com/2014/11/04/modeling-a-pandemic-like-ebola-with-the-wolfram-language)
- [Epidemics at Wolfram Demonstrations](https://demonstrations.wolfram.com/search.html?query=epidemic)
- [IGSIRProcess - IGraph Epidemic models][9]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=900_675_28__20200123194001.jpg&userId=20103
[2]: https://youtu.be/HCJgv3N_kDo
[3]: https://youtu.be/MlI_8o4A3BA
[4]: https://youtu.be/P86ZY-znE64
[5]: https://www.twitch.tv/videos/547321229
[6]: https://youtu.be/4xCfPIiredM
[7]: https://github.com/arnoudbuzing/wolfram-coronavirus
[8]: https://wolfr.am/JZNRriEE
[9]: http://szhorvat.net/mathematica/IGDocumentation/#epidemic-modelsVitaliy Kaurov2020-02-04T15:18:14ZFindFormula Of Function With Two Inputs (e.g. f(x,z))
https://community.wolfram.com/groups/-/m/t/1886647
I am attempting to use the Wolfram Language to derive a function f(x,z), where x is the desired accuracy in base-2 digits and z is floor(log2(input)), to model the convergence rate of a continued fraction used to approximate $e^x$. I have generated a CSV file containing millions of sample entries, where each row represents <code>x,z,f(x,z)</code>. I uploaded the csv file to my website if you want a peek at it: [https://jackgiffin.com/main/misc_help_pages/cont-fraction-convergence-e-samples.txt][1].
However, I have ran into three problems, one of which I can find no solution to.
1. FindFormula does not seem to be able to generate a function with multiple inputs
2. FindFormula return piecewise equations, which are bad for projecting much higher approximations. My partial solution is just to generate a lot of formulas and select the first one that is not piecewise.
3. FindFormula does not seem to have an overestimate option. Ideally, there would be an option to make FindFormula find a formula which is never less than the true value. My partial solution id just a to add 1 or 2 to the resulting equations.
Here is the code I am currently using to generate one-input function:
&[Wolfram Notebook][2]
[1]: https://jackgiffin.com/main/misc_help_pages/cont-fraction-convergence-e-samples.txt
[2]: https://www.wolframcloud.com/obj/c83766a1-0f4b-4ec8-b4d9-94bcf10b3ab2Jack Giffin2020-02-24T22:51:20ZSolve nonlinear numerical differential equations with several variables?
https://community.wolfram.com/groups/-/m/t/1886272
Dear Wolfram community,
I have a nonlinear system with two variables. For Example:
Clear["Global`*"]
system = {
D[a[t, x], t] == a[t, x] + b[t, x],
D[b[t, x], x] == a[t, x] b[t, x],
a[t, 0] == 0.5, b[0, x] == 1};
solution = NDSolve[system, {a, b}, {t, 0, 10}, {x, 0, 10}]
and get as an error massgae:
`NDSolve::femnonlinear: Nonlinear coefficients are not supported in this version of NDSolve..`
What is my problem and my miss understanding?
Thank for your help.C. H.2020-02-24T11:10:13ZRandom Cities with a Non-Missing Property
https://community.wolfram.com/groups/-/m/t/1885694
I would like to fetch four random city entities from the curated database that have a value in a specified property (not Missing[]). The end result would look something like this if I used the property "Area":
{{"Los Angeles", Quantity[468.6701619038, ("Miles")^2]},{"Miami", Quantity[35.871043820, ("Miles")^2]},{"Twin Falls", Quantity[18.103053374, ("Miles")^2]},{"Canton", Quantity[25.462368239, ("Miles")^2]}}
So far everything I've tried has been too slow to be useful, on the order of 20 minutes per query. I admit though that I don't understand EntityClass, EntityFunction, etc. very well. The problem seems to be in the large size of the database that contains the "city" entities and the relatively few entities that have values for most of the properties. Usable times for my purpose would be less than 15 seconds or so.
Any help would be appreciated.
MarkMark Greenberg2020-02-23T22:45:01ZNumerically solve the following set of PDEs (Structural singularity)?
https://community.wolfram.com/groups/-/m/t/1856267
Hello,
When I try to numerically solve the following set of PDEs, I get the following error:
NDSolve::indexss: The DAE solver failed at t = 0.`. The solver is intended for index 1 DAE systems and structural analysis indicates that the DAE is structurally singular.
After careful examination of the equations by me and my colleagues, we don't understand why these equations are not numerically solvable. Please let me know if you see any hints of why.
The code is attached and included below as an image (the actual code didn't look good when pasted from Mathematica).
Thank you,
Abed
![enter image description here][2]
[1]: https://www.wolframcloud.com/obj/abed.alnaif/Published/pdeSolve_debug_v10.nb
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=mathematic_pdesolve_snapshote.PNG&userId=1662782Abed Alnaif2020-01-09T19:43:07ZObtain incomplete moments of bivariate normal as func of CDF?
https://community.wolfram.com/groups/-/m/t/1885898
Hi
I am a Mathematica/Wolfram novice so apologies for the elementary nature of this question.
I am looking to use Mathematica to see if a few integrals related to bivariate distributions have
closed forms.
In particular I am interested in the incomplete moments:
Integrate[
x^m y^n Exp[ -(x^2 + y^2 -
2 \[Rho] x y)/(2 (1 - \[Rho]^2))]/(2 \[Pi] Sqrt[
1 - \[Rho]^2]), {x, a, Infinity}, {y, b, Infinity}]
I suspect they can be written in terms of the standard CDF- L(a,b,rho) in the Abramowitz /Stegun formalism (eqn 26.3.3).
However, as a test case, trying to get Mathematica to evaluate the above with m=n=0 leads it into a loop from which it never seems to emerge.
How could I define the default m=m=0 case and see if it can express the m>0 n>0 case in terms of it?
Many thanks.
TomTom Weston2020-02-23T15:36:24ZPlot points using the elements of a random generated matrix as coordinates?
https://community.wolfram.com/groups/-/m/t/1885575
Hey, So recently we got task at school. The task was to create function, which will make random matrix depends on what you entry. That was the easy part. But then we have to generate point graph. Since the matrix should have 2 and more lines, we have to take first line out of the random generated matrix and make its points as x-axis. Same goes for the second line - take its points as points of y-axis.Then connect the points and label the axes. I have bloody no idea, how am I suppost to make the points from the first two lines as point graph? This code below is what I've got so far. It works pretty well as a rangom generator for matrix.
Matrix[a_, b_] := Module[{x, y, result},
x = a;
y = b;
result =
RandomInteger[{-100, 100}, {RandomInteger[{2, x}],
RandomInteger[{2, y}]}];
Print [MatrixForm[result]]
]Tomáš Jahoda2020-02-23T00:58:19ZUsing Pseudo-Hilbert Curves to Assist People Perceive Images via Sound
https://community.wolfram.com/groups/-/m/t/1862464
###Introduction###
Recently, I was learning about infinite space filling curves and their applications in real life. I became fascinated with [Hilbert Curves][1], one of many [plane-filling functions][2]. I wanted to see how these shapes could be used in image to video conversion. To begin with, I explored how pseudo Hilbert Curves could be used to convert a square image to audio so that each pixel color was associated with a specific sound.
Theoretically, a person would be able to learn this association and would be able to reconstruct a mental image by listening to audio. This could help with people who are visually impaired, letting blind people "hear" pictures. The reverse is also true. People who are deaf will be able to "see" sound.
I thought I could implement this using Mathematica, which I learned last summer at the Wolfram High School Camp.
###Why Hilbert Curves###
![Pseudo-Hilbert Curves from Order 1 to 10][3]
As you can see above, as you increase the order, the limit of these curves start to fill an infinite amount of space. A true Hilbert Curve is actually $\lim_{n\to\infty} PseudoHilbertCurve_n$. Each one of these curves can be used on an image of dimensions 2 by 2, 4 by 4, 8 by 8, etc. The curve needed is accordingly:
HilbertCurve[Log[2, ImageDimensions[image]]]
Each line in the curve will go over one pixel in the image, starting at the bottom left and ending at the bottom right.
![Example of Order 3 Pseudo Hilbert Curve][4]
But why would you need to use this specific pattern, as supposed to something more simple? Here: https://youtu.be/3s7h2MHQtxc?t=355. In short, if you were to increase the resolution of your image, you would now have to retrain your brain to re-associate the pixel value and the associated frequency at that point on the image. But this is now the case on a Hilbert Curve. As you increase the resolution of your image, and thus the order pseudo-Hilbert Curve, a point will just move closer and closer to its limit in the same space, which solves our problem.
###Converting Color to Sound###
This was the main hurdle when writing the program. I needed to convert each pixel value to a unique sound frequency. My initial thought was to just create an association between each wavelength in the visible electromagnetic spectrum and a frequency, but I was quick to learn that doesn't work in the digital world. RGB colors could be a combination of different wavelengths. And I couldn't just add these wavelengths separately because there could be overlap. There was also brightness and darkness which isn't part of the light spectrum. So instead of the RGB format, I decided to use the HSB format (hue, saturation, and brightness). This is also more compatible for human learning, as the human eye uses these three characteristics to determine color, as supposed to the RGB values on a computer image.
![Graphics3D Visualizer of HSB][5]
As you can see from the image, Hue could be used to determine the color. Now, instead of RGB with three values to one color, Hue gave me one number to a specific color.
![Graphics Hue Color Chart][6]
But I still needed to show saturation and brightness in my sound waves. Color in a computer is expressed in three dimensions while sound has two: amplitude and frequency. I would be leaving one color property out. I could think of multiple ways to express all three as sound waves, but none of them made sure that similar colors sounded the same. For example, if I had a hue playing a certain frequency, I could define a range around this point that could express either saturation or brightness using a plus/minus system.
To solve this, I decided to use [AudioChannel][7] functions. This way, one channel could express the hue through a specific frequency, while the other channel could express the saturation and brightness combined through volume and frequency respectively. This way, colors that were similar would sound similar too.
###Creating the Function###
Obviously, I needed to get real images. I used *image1*, where the pixels were easily noticeable, and my baby picture for the school yearbook as *image2*, as a test image. The first one, being resized to a 8 by 8 image, would utilize an order 3 pseudo-Hilbert Curve ($\log _{2}8=3$), and the second one, being resized to a 32 by 32 image, would utilize an order 5 pseudo-Hilbert Curve ($\log _{2}32=5$).
![The images I used to test the program.][8]
To get the HSB values, I used Wolfram's in-built [Hilbert Curve][9] and [Pixel Value][10] functions. I used Pixel Value to read the image's pixel values as bytes, which was converted to RGB and then to HSB. To get the points on the Hilbert Curve that was associated with their respective position on the image, I added {1,1} to each point so that it matched the pixel space (the origin on a Cartesian Plane is designated as (1,1) on an image).
getHSB[image_] :=
ColorConvert[
RGBColor /@
Divide[PixelValue[
image, ({1, 1} + #) & /@
HilbertCurve[Log[2, ImageDimensions[image][[1]]]][[1]], "Byte"],
255.], "HSB"]
In the Wolfram Language, HSB values range from 0 to 1 instead of the normal 0 to 360 which I guess gives the user more control of the specific color they want to implement. I had to scale these values to the frequency range I wanted for the hue and brightness. Through trial and error, I decided that 100-3900 Hz was a good range so that people of all ages could hear the lowest and highest frequencies. For the amplitude dictated by the saturation, I could just use the direct value as [SoundVolume][11]. I made it so that the sound for each pixel had a duration of 0.1 seconds for demonstrative purposes. In the real world, I would think that this should be a lot smaller so that images don't take too long to hear.
getHSB[image_] :=
ColorConvert[
RGBColor /@
Divide[PixelValue[
image, ({1, 1} + #) & /@
HilbertCurve[Log[2, ImageDimensions[image][[1]]]][[1]], "Byte"],
255.], "HSB"]
hueToFrequencyMatch[HSB_] := Rescale[HSB[[1]], {0, 1}, {100, 3900}]
saturationToAmplitudeMatch[HSB_] := HSB[[2]]
brightnessToFrequencyMatch[HSB_] :=
Rescale[HSB[[3]], {0, 1}, {100, 3900}]
soundFrequency[frequency_] :=
Sound[Play[Sin[frequency*2 Pi t], {t, 0, 0.1}]]
soundFrequencyVolume[frequency_, ampSaturation_] :=
Sound[soundFrequency[frequency], SoundVolume -> ampSaturation]
After this, I just had to apply these functions over the HSB values of each pixel in the order dictated by the appropriate pseudo-Hilbert Curve, and then merge the hue sound and saturation+brightness sound as separate audio channels.
convertHToSound[image_] :=
soundFrequency /@ hueToFrequencyMatch /@ getHSB[image] // AudioJoin
convertBSToSound[picture_] :=
(soundList = {}; n = 1;
While[n <= Length@getHSB[picture],
AppendTo[soundList,
soundFrequencyVolume[
getHSB[picture][[n]] // brightnessToFrequencyMatch,
getHSB[picture][[n]] // saturationToAmplitudeMatch]];
n++])
convertHSBToSound[audio1_, audio2_] :=
AudioChannelCombine[{audio1, audio2}]
Because hue is the most important color characteristic, I wanted to emphasize this AudioChannel more. Thus,
editChannel2[audio_, factor_] := AudioPan[audio, -factor]
To put everything together, I made a separate function to organize the results.
seperateTable[picture_] :=
(convertBSToSound[picture];
Module[{a = convertHToSound[picture], b = soundList // AudioJoin},
c = editChannel2[convertHSBToSound[a, b], 0.05];
table =
Grid[{{Image[picture, ImageSize -> 100], a, b, c}, {Blank[],
AudioPlot@a, AudioPlot@b, AudioPlot@c}}];
ReplacePart[table,
1 -> Prepend[
First[table], {"Image", "Hue", "Saturation+Brightness",
"HSB"}]]])
These were my results. I will attach the *hsb1* and *hsb2* sound files to this post, along with my notebook.
![Final image to sound representation.][12]
Because they use two channels, you should use earbuds or headphones so that you can clearly differentiate the sounds coming through your left and right ears.
![Spectrogram of *hsb1* and *hsb2*][13]
###Visualizing the Process###
animate[image_, audio_] :=
Module[{list = ({1, 1} + #) & /@
HilbertCurve[Log[2, ImageDimensions[image][[1]]]][[1]]},
(AudioPlay@audio;
Animate[
ReplacePixelValue[Image[image, ImageSize -> 100],
list[[1 ;; index]] -> Orange],
{index, 1, list // Length, 1},
DefaultDuration ->
QuantityMagnitude[
UnitConvert[Quantity[audio // Duration, "Seconds"]]],
AnimationRepetitions -> 1])]
I used this to create the following two animations. If you ran these programs, the HSB sound would play alongside the animation, showing exactly which pixel correlates to each sound. Unfortunately, I couldn't play the audio here on the post, but it is in the attached notebook if you would like to see. Here is what it looks like:
![*hsb1* Conversion][14]
![*hsb2* Conversion][15]
###Future Work###
In the future, I hope to create a machine learning algorithm that can learn this association between audio and image in reverse (recreate the image from audio). If anyone has any ideas or pointers for me, please share in the comments below - I would really appreciate it!
[1]: http://mathworld.wolfram.com/HilbertCurve.html
[2]: http://mathworld.wolfram.com/Plane-FillingFunction.html
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-01-19at12.07.19PM.png&userId=1725131
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=example.gif&userId=1725131
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=HSB.png&userId=1725131
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Hue.png&userId=1725131
[7]: https://reference.wolfram.com/language/ref/AudioChannels.html
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-01-19at1.39.00PM.png&userId=1725131
[9]: https://reference.wolfram.com/language/ref/HilbertCurve.html
[10]: https://reference.wolfram.com/language/ref/PixelValue.html
[11]: https://reference.wolfram.com/language/ref/SoundVolume.html
[12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-01-19at2.23.47PM.png&userId=1725131
[13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-01-19at2.32.49PM.png&userId=1725131
[14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=animation1.gif&userId=1725131
[15]: https://community.wolfram.com//c/portal/getImageAttachment?filename=animation2.gif&userId=1725131
[16]: https://drive.google.com/file/d/1lvjOWkzEzidCDLwYmOmqI4Krz7M_935X/view?usp=sharing
[17]: https://www.wolframcloud.com/obj/srinath.rangan/Published/Hilbert%20Curve%20Project%202.wl?Srinath Rangan2020-01-19T19:42:34Z[WSS18] A New Kind of Chess
https://community.wolfram.com/groups/-/m/t/1380041
![enter image description here][1]
# Summary & Objectives
The rules of chess have been perfected for more than a millennia to ensure an exciting game every time. These relatively simple rules are capable of producing very interesting and complex dynamics that deserve to be studied in their own rights, not just merely for competition purposes. This project aims at laying down the formalism to capture the game of chess as well as many other board and card games. In accordance with this formalism, a Mathematica chess package has been developed which creates, displays, and evolves a ChessState object using ChessState, ChessPlot, and ChessEvolve functions.
ChessPlot enables the user to provide options such as setting board color set, displaying coordinates, rotating point of view, or extracting MatrixForm of a ChessState.
![enter image description here][2]
In addition, a list of rule functions is provided which take in a ChessState and output all the possible moves in accordance with the rule they represent.
With this setup, the user is able to setup any ChessEvaluate function and explore the chess space. This open-ended chess design also enables the user to modify the rules with ease so they can explore chess variations such as antichess, atomic chess, and others (see LiChess.org for more examples).
## ChessState
Many board/card games may be represented using an association where coordinates in the game are associated with states.
Specifically for chess, we can write:
![enter image description here][3]
Which can be encapsulated in a wrapper for aesthetic reasons as well as additional functionalities that help the user to extract the state of a coordinate using different notations (e.g. "e1", {rank, file} = {1, 5}).
![enter image description here][4]
In order to avoid referring to previous states of the game, auxiliary (as in not part of the board) has been added. For instance, if a pawn may be captured via En passant, it's coordinate will be mentioned. As another example, if the rooks or the king move, the opportunity of castling will be revoked. White and black cemeteries are there to keep track of captured pieces. Turn switches between White and Black after each move. The game ends when the Result is set to "1/2-1/2", "1-0", or "0-1".
## A Move $=$ A Set of Actions
A move is a list of actions. For instance, the move of a white pawn at a7 capturing a rook at b8 and becoming a queen may be represented as {a7 &rarr; &#9812; , &#9820;
&rarr; BlackCemetery, b8 &rarr; &#9813;
}.
## Mathematical Formulation of Chess Rules
If we want to develop a chess algorithm, we should list all the rules pseudo-mathematically as such:
![enter image description here][5]
(Forgive me for mistakes and for using an image instead of typing it. I will try to write this up more clearly at a later time)
## Game Rules $=$ Exhaustive Move Generators
I have used the rules expressed above to create functions that intake a ChessState and output all the possible moves in accordance with the rules. For instance, an exhaustive move generator for knights in Mathematica would look like this:
![enter image description here][6]
Be aware that not all rules might have been implemented as of the time you are reading this post.
## Code on GitHub
You can find my code on GitHub. You can either import chess.m as a package or use Notebook01.nb for code, documentation, and demonstrations. The following is the link to GitHub but be aware that I am planning to move this to a new GitHub location (before Jan 2019). If that happens, I'll update this link.
[https://github.com/Miladiouss/Summer2018Starter/tree/master/ChessPackage][7]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=6152chess.gif&userId=1188265
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=chess01.png&userId=1188265
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=state01.png&userId=1188265
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=chessStateImage.png&userId=1188265
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=cheesRules.png&userId=1188265
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=KnightMoves.png&userId=1188265
[7]: https://github.com/Miladiouss/Summer2018Starter/tree/master/ChessPackageMilad Pourrahmani2018-07-11T21:30:48Z