Wolfram Blog http://blog.wolfram.com News, views, and ideas from the front lines at Wolfram Research. Wed, 26 Oct 2016 15:44:46 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 Announcing Wolfram SystemModeler 4.3 http://blog.wolfram.com/2016/10/25/announcing-wolfram-systemmodeler-4-3/ http://blog.wolfram.com/2016/10/25/announcing-wolfram-systemmodeler-4-3/#comments Tue, 25 Oct 2016 16:49:16 +0000 Patrik Ekenberg http://blog.internal.wolfram.com/?p=33517 Today I am excited to announce SystemModeler 4.3. This release focuses on three key areas: model analytics, collaboration and performance, which I will illustrate in this blog. You can see more on the What’s New page, or download a trial to try it yourself.

I’ll start by talking about our improvements in collaboration. I develop lots of models in SystemModeler, and when I do, I seldom develop them in a vacuum. Either I send a model to my colleagues for them to use, I receive one from them or models get sent back and forth while we work on them together. This is, of course, also true for novice users. A great way to learn how to use SystemModeler—or any product, for that matter—is to look at things other people have done, whether it be a coworker or other users online, and build upon that.

Whether you send your models to other people, receive models or send models between your own platforms, we want to make sure that you have everything you need to start using the model, straight out of the box.

As an example, I have built a model of an inverted pendulum using the PlanarMechanics library. It has a linear-quadratic regulator built using the Modelica Standard Library, and it also includes components from the ModelPlug library that connect to real-life hardware, such as actuators and sensors on an Arduino board (or any other board following the Firmata protocol).

Model of an inverted pendulum

In the model, you can apply a force to different parts of the pendulum using input from an Arduino board. When simulated, the model produces an automatically generated animation.

Automatically generated animation

As a developer of this model, I usually know of quite a few things that will be interesting to plot. In this particular case, for example, you can create interesting results by studying the different forces acting on the pendulum and the different states of the controller. In SystemModeler 4.3, you can predefine plots in a model. After choosing a set of variables to plot, simply right-click “Add Plot to Model” and give it a name, e.g. ControllerInputs.

Add plot to model

Now the stored plot can easily be accessed each time the model is simulated.

Simulating the model

Even if model parameters or the model structure are changed, the plots will remain and be available next time you need to use the model. Storing plots is not only a useful feature when you revisit models that you yourself have built, but it is also useful when you share or receive models from others.

Now, let me save this model and send it to a colleague. Previously I would have needed to make sure that they had all the resources to run the model, including all the libraries I have used. In SystemModeler 4.3, I can now easily save all this in one convenient file with the improved Save Total Model feature. Everything needed, including libraries, stored plots and animation objects, will be available for the person who receives the file.

Everything included

So a coworker receives my model—how would he or she begin analyzing it? In SystemModeler 4.3, we have introduced new model analytics features that help answer that question. Starting out, we can get a quick look at the model using the new summary property for WSMModelData.

WSMModelData["InvertedPendulum", "Summary"]

InvertedPendulum summary

The pie chart shows how large of a percentage of components are from a particular domain. A majority of the components comes from the dark blue slice, the PlanarMechanics library. In Mathematica, you can mouse over the slices to see the domain name.

Another good place for my coworker to start would be by looking at the plots I defined in the model before sending it. Support for the stored plots have, of course, also been included in the Wolfram Language. If a plot has been chosen as the preferred plot, a very neat one-liner in the Wolfram Language makes it easy to start exploring the model.


Plot of InvertedPendulum

In Simulation Center, you will find a list of all stored plots in the experiment browser. You can list all the available plots with the Wolfram Language via the "PlotNames" property.

WSMModelData["InvertedPendulum", "PlotNames"]

{"ControllerInputs", "XY-Position", "PositionVelocityAcceleration", \ "AppliedForces"}

Parametric plots can be stored and plotted.

WSMPlot["InvertedPendulum", "XY-Position"]

XY plot of InvertedPendulum

Use the stored plot functionality to easily measure the response to changes in parameters.

WSMPlot[WSMSimulate["InvertedPendulum",    WSMParameterValues -> {"body.m" -> {0.25, 0.5,        0.75}}], "AppliedForce"]

InvertedPendulum applied force plot

A stored plot can consist of multiple plots.

WSMPlot["InvertedPendulum", "AngleAndPosition"]

Plot of InvertedPendulum with angle and position

One area where we have made heavy use of this new functionality is with our SystemModeler examples. On our webpage, we have for a long time provided a large selection of SystemModeler models collected from different industries and education areas. Whether it be the internal states of a digital adder or the heat flows in a freezer, these examples usually contain a lot of different things that you can study. We have now added the most important plots to analyze and understand each example model using stored plots.

Furthermore, the models that we have created over the years have now also been included directly in the product. Whether you want to get started using SystemModeler using models from your domain or study new concepts, the new included curated models will be useful.

Now let’s return to the model my colleague just received. Suppose that he or she would like to perform some further analysis on it. A new set of templates has been included in order to facilitate this. The following command, for example, creates a template in Mathematica that allows you to change an input in real time and plot the response.

WSMCreateTemplateCell["InvertedPendulumControl", "ChangeRealTimeInput"]

Just fill in the blanks, and the simulation models will come alive with real-time interaction in Mathematica.

Real-time simulation

Templates for many other tasks are available, such as FFT analyses, model calibrations, parameters, initial value sweeps and much more.

These are just some of the new, exciting model analytics and collaboration features in SystemModeler 4.3. For a more complete view, check out our What’s New page. If you try out the new SystemModeler, you will experience one of the things that I haven’t mentioned, namely that it is snappier and faster than before. Actually, performance has been improved across the board, including faster model compilation times and faster simulations from the Wolfram Language.

http://blog.wolfram.com/2016/10/25/announcing-wolfram-systemmodeler-4-3/feed/ 0
Wolfram Data Summit 2016 http://blog.wolfram.com/2016/10/18/wolfram-data-summit-2016/ http://blog.wolfram.com/2016/10/18/wolfram-data-summit-2016/#comments Tue, 18 Oct 2016 14:21:54 +0000 John Moore http://blog.internal.wolfram.com/?p=33423 This past September, we hosted our annual Wolfram Data Summit in Fairfax, Virginia. Over the past seven years, the Data Summit has come to occupy a central place at the nexus of data, computation and business. This high-level gathering of data innovators brings together people from many backgrounds and provides them the opportunity to share their challenges and breakthroughs in analyzing, managing and disseminating data.

With its emphasis on cross-pollination, the Wolfram Data Summit has emerged as an exciting place to share insight into the subtle differences and unique challenges presented by data in different domains. New and unexpected points of commonality emerge from these conversations, allowing participants to trade solutions to emergent data problems.

Washington, DC, skyline

This question of what to do with data was taken up by Lei Wu (Ancestry.com) and Cinzia Perlingieri (Center for Digital Archaeology), both of whom curate large data collections that preserve cultural memory. At Ancestry.com, Wu and his team of data scientists are reimagining digital genealogy as social networking. We use Facebook for friends and LinkedIn for professional relationships. What if we had a network—what he calls a “big tree”—for our shared genealogical history as well? This big tree engages users in the process of turning data into knowledge.

Like Wu, Perlingieri emphasized the importance of combining human insight with machine learning when it comes to doing things with data. Perlingieri and her team are searching for scalable methodologies that preserve cultural heritage. “We need a redefinition of data as a concept inclusive of alternative narratives and community-driven contributions to heritage,” she said.

Though Ancestry.com and the Center for Digital Archaeology serve very different clienteles, they share a user-focused approach to data curation and interpretation. Users create knowledge by interacting with archives, generating new connections between data elements in the process. These types of connections were explored by each of the Summit’s presenters, including Anthony Scriffignano, chief data scientist at Data Summit co-sponsor Dun & Bradstreet, whose talk delved into some of the “Things We Forget to Think About.”

Because we recognize the promise of computational knowledge for every industry, we will continue to expand the Wolfram Data Summit. The Wolfram Data Summit develops understanding of data at the level of software, hardware and technical processes. But at its core, the Wolfram Data Summit is about how we create and structure data, what kinds of insights can be derived from it and how we apply computational thinking. What kind of computational thinking do professionals use in different domains? How might computational thinking be applied across those industry boundaries? As the Wolfram Data Summit turns eight, we continue to search for answers to these questions and more.

Watch more videos from the 2016 Wolfram Data Summit, including Stephen Wolfram’s keynote address, here.

This post has been updated to include video of Anthony Scriffignano’s talk.

http://blog.wolfram.com/2016/10/18/wolfram-data-summit-2016/feed/ 0
New in the Wolfram Language: Ask http://blog.wolfram.com/2016/10/14/new-in-the-wolfram-language-ask/ http://blog.wolfram.com/2016/10/14/new-in-the-wolfram-language-ask/#comments Fri, 14 Oct 2016 13:52:57 +0000 Carlo Barbieri http://blog.internal.wolfram.com/?p=33418 Making web forms should be dead simple. That has been one of our goals at Wolfram Research since the release of the Wolfram Cloud. We’ve made smart input fields, powered by Wolfram|Alpha technology, that understand almost anything users type. We’ve designed FormFunction and APIFunction so that you can build forms and APIs with the same readable syntax. And now with the newest version of the Wolfram Language, you can build interactive web forms with dynamic branching and control flow using the Ask family of functions.

Would you like to learn how to build web forms with Ask?

What Ask Does

In a nutshell, AskFunction allows you to ask the user a series of questions—as in surveys, web orders, tax forms, quizzes, etc. To demonstrate, I have built a simple web form for my friends and family to RSVP to my upcoming party.

CloudDeploy[ AskFunction[ AskDisplay["RSVP for my party"]; Ask[{"name", "Enter name"} -> "String"]; Ask[{"attending", "Will you be attending?"} -> {"Yes" -> True, "No" -> False}]; Ask["name"] If[Ask["attending"], " is", " is not"] " attending." ] ]

RSVP for my party


Will you be attending?

Carlo is attending

The first time I call Ask["name"], the web form prompts the user for input. When I call Ask["name"] the second time, the AskFunction remembers the user’s previous answer and uses that instead of asking again. See the example for yourself here.

This example isn’t really that different from what you can already do with FormFunction; Ask is not intended to replace FormFunction. Where Ask begins to really shine over its older brother is when you want to skip or tailor questions based on previous responses.

In the event a friend or family member says they are not attending my party, I would like to give them the opportunity to reconsider their tragic mistake. This is where AskConfirm comes in: AskConfirm asks users if they are OK with their answer; if they say no, AskConfirm effectively rewinds the computation and gives them a second chance to answer differently. And we can make it so only those who said they aren’t attending are prompted for confirmation. Try it out.

CloudDeploy[  AskFunction[   AskDisplay["RSVP for my party"];   Ask[{"name", "Enter name"} -> "String"];   If[    ! Ask[{"attending", "Will you be attending?"} -> {"Yes" -> True,         "No" -> False}],    AskConfirm["attending",      "You said you aren't attending. Would you like to change your \ answer?"]    ];   Ask["name"]  <> If[Ask["attending"], " is", " is not"]  <>     " attending."   ]  ]

You said you aren't attending. Would you like to change your answer?

And we can then ask more questions to those who are attending, such as whether they’ll be bringing a guest. There’s no need to ask those who aren’t attending if they are going to bring a guest—so we won’t! Try it out.

CloudDeploy[  AskFunction[   AskDisplay["RSVP for my party"];   AskAppend[{"name", "Enter name"} -> "String"];   If[    ! Ask[{"attending", "Will you be attending?"} -> {"Yes" -> True,         "No" -> False}],    AskConfirm["attending",      "You said you aren't attending. Would you like to change your \ answer?"];    Ask["name"][[1]] <> " is  not attending",    If[     Ask[{"plusone",         "Will you be bringing a plus one?"} -> {"Yes" -> True,         "No" -> False}],     AskAppend["name"]     ];    If[     Ask["plusone"],     StringJoin[      Riffle[Ask["name"], " and "] ,      " are attending"      ],     Ask["name"] <> " is attending"     ]    ]   ]  ]

Notice that when I ask for the user’s name and the name of the guest, I now use AskAppend instead of Ask. AskAppend["name"] does exactly what it sounds like it does—it appends the new answer for "name" to the previous answer. Unlike Ask, AskAppend can ask the same question multiple times and build up a list of each answer. So if I first answer AskAppend["name"] with “Carlo” and then later answer with “Ada,” when I call Ask["name"] again, the answer will be: {“Carlo”, “Ada”}.

I will also ask the user what sort of food they want—and once again, those who aren’t attending get to skip this question since it doesn’t apply. As an added bonus, I can utilize the built-in Wolfram Cloud storage and save the survey results to a Databin or CloudExpression. In less than ten minutes, I have built a functional web form with branching, using straightforward and declarative code. Here is the complete code, which you can try out in the cloud right now:

CreateCloudExpression[<|"attendance" -> {}, "foodCount" -> <||>|>,    "mysurveys/partyrsvp"]; CloudDeploy[  AskFunction[   AskDisplay["RSVP for my party"];   AskAppend[{"name", "Enter name"} -> "String"];   If[    ! Ask[{"attending", "Will you be attending?"} -> {"Yes" -> True,         "No" -> False}],    AskConfirm["attending",      "You said you aren't attending. Would you like to change your \ answer?"],    Ask[{"plusone",        "Will you be bringing a plus-one?"} -> {"Yes" -> True,        "No" -> False}];    If[     Ask["plusone"],     AskAppend["name"]];    Ask[{"food", "What food would you like?"} -> {"Pizza", "Sushi",        "Burgers", "Pasta"}]];   Module[{ce = CloudExpression["mysurveys/partyrsvp"]},    AppendTo[ce["attendance"], Ask["name"] -> Ask["attending"]];    AskTemplateDisplay[     If[       ! #attending,       "Sorry to hear you can't make it,  " <> #name,       ce["foodCount", #food]++;       Column[{         StringJoin[          "Thanks for responding! We look forward to seeing you, " ,           StringRiffle[#name, " and "] ,           "!"          ],         BarChart[          KeyValueMap[Labeled[#2, #1] &, ce["foodCount"]],           PlotLabel -> "Current Food Votes"          ]         }]       ] &     ]    ]   ],  Permissions -> "Public"  ]

Thanks for responding! We look forward to seeing you, Carlo and Ada!

A few other new functions I didn’t mention include AskedQ and AskedValue. AskedQ lets you check if a question has been asked already. AskedValue works like Ask, except it will not prompt the user if they have not been asked yet; the function will instead return Missing for unanswered questions.

What You Can Build with Ask

RSVP forms are far from the only thing you can build with Ask. We’ve been asked by many different users for this sort of control flow to be added to web forms. And we’re proud of how flexible this generic framework is. What I really love about the Wolfram Language is that behind a design that makes it simple to build 90% of applications, there is also deep customizability. With the basic tools of Ask, AskConfirm, AskAppend and AskDisplay, any problem with an “If this, do that” structure, or any flow chart, can be written as an AskFunction form. Here are just a few of the many applications you can now build.

Troubleshooting Guides

Have you ever needed to help friends or family members troubleshoot their computers? Build a troubleshooting guide web app and give your friends, family or clients an effective guide to fix their own problems.

Troubleshooting My Computer

Computer is really slow

Do you have an anti-virus program installed?

Tax/Legal Forms

A lot of factors go into finances—are you married, do you have children, how much do you make or spend? If you don’t have dependents, you should be able to skip over any question about dependents. Try out our example web form for computing your marginal tax rate.

Married filing jointly

What was your income in 2015?

Do you have any dependents?

You owe 16542.5 in taxes. Your marginal tax rate is 16.5%


FormFunction works fine for quizzes, but maybe you want to only display advanced questions once a student has demonstrated mastery of the beginner questions. Or use AskConfirm and AskAppend to loop on a particular question until the student has the correct answer.

What is 2+2?

What is x in 2x+1=3

What is sin(0)

You scored 33.33%. Would you like me to generate more practice problems?

What We’re Working on

Ask is still new, and the potential for what it can do is rapidly growing. Even now, we’re continuing to build on the Ask functionality and expand the functions in new directions. Coming down the pipeline are new projects that will bring the Ask syntax to different applications like chatbots and more. I’m genuinely proud of what we’ve accomplished so far and where we’re headed in the future. So if you’re interested in learning more about how to use these functions, please feel free to leave a comment!

http://blog.wolfram.com/2016/10/14/new-in-the-wolfram-language-ask/feed/ 0
Barcelona Wolfram Technology Conference 2016 http://blog.wolfram.com/2016/10/11/barcelona-wolfram-technology-conference-2016/ http://blog.wolfram.com/2016/10/11/barcelona-wolfram-technology-conference-2016/#comments Tue, 11 Oct 2016 14:04:12 +0000 Christopher Jordan http://blog.internal.wolfram.com/?p=33403 We’re bringing a Wolfram Technology Conference to Barcelona!

Join us on October 27 for a series of talks, case studies and workshops that will equip you with the knowledge to make the most of Wolfram technologies.

Barcelona Wolfram Technology Conference banner

Our experts will introduce our latest release, Wolfram Enterprise Private Cloud, which aims to shape the way organizations see and deliver computation, enabling users to derive vastly increased value from their big data for analytics, business intelligence and smart application development.

Special guest Jan Brugard of Wolfram MathCore will demonstrate how Mathematica and SystemModeler can be used together to model and analyze a wide range of systems, and will give industry examples such as:

  • Optimizing bio-ethanol production
  • Landing drones autonomously on ships
  • Eliminating the need for biopsy when diagnosing problems with the liver

The conference will be a great opportunity to check out our latest technology, talk to our developers and get the chance to meet fellow technical specialists.

For more information and to reserve your space, click here.

See you there!

http://blog.wolfram.com/2016/10/11/barcelona-wolfram-technology-conference-2016/feed/ 0
Draw Anything and Win Hackathons with the Wolfram Language http://blog.wolfram.com/2016/10/05/draw-anything-and-win-hackathons-with-the-wolfram-language/ http://blog.wolfram.com/2016/10/05/draw-anything-and-win-hackathons-with-the-wolfram-language/#comments Wed, 05 Oct 2016 14:04:29 +0000 Zach Littrell http://blog.internal.wolfram.com/?p=33368 After 36 hours, two math graduate students created Draw Anything, the grand prize–winning, Wolfram Cloud–powered app, at the MHacks V hackathon. We’ve written about Olivia Walch and Matt Jacobs’s winning iOS app before. Now, the pair of prize-winning Wolfram hackers have taken the time to talk with us about how they used the Wolfram Language and fast Fourier transforms to create step-by-step drawing guides for any input image—whether it’s a picture of Homer Simpson, a dog, yourself or your future dream car.

Draw Anything car demonstration

Matt shared how he was pretty new to coding before MHacks V. That was before Olivia, a web cartoonist who also studies mathematics, introduced him to hackathons and the Wolfram Language. They read our blog post about creating popular curves with Fourier series, and realized they could use the same idea to create drawing guides on the fly. The Wolfram Language, with built-in cloud technology and over 5,000 functions, proved perfect not only for bringing their hackathon idea to life but also, as Matt says, “for making it so easy to get in there and not be scared of programming.” Watch the video below as Olivia and Matt describe their journey to victory at MHacks V.

Since DrawAnything and MHacks V, Matt has continued to expand his programming abilities, while both Olivia and Matt have grabbed more hackathon prizes, including a trip to compete in Taiwan for HackNTU. And they have no doubts about keeping Wolfram technology at the top of their coding toolbox for future competitions.

Are you interested in doing a hackathon with Wolfram technology, need an idea or want to see some of the other winning hacks? Then visit this page to learn more about using Wolfram tech at hackathons.

Be sure to check out other Wolfram Language stories like Olivia and Matt’s on our Customer Stories pages.

http://blog.wolfram.com/2016/10/05/draw-anything-and-win-hackathons-with-the-wolfram-language/feed/ 1
Mersenne Primes and the Lucas–Lehmer Test http://blog.wolfram.com/2016/09/30/mersenne-primes-and-the-lucas-lehmer-test/ http://blog.wolfram.com/2016/09/30/mersenne-primes-and-the-lucas-lehmer-test/#comments Fri, 30 Sep 2016 16:51:06 +0000 John McGee http://blog.internal.wolfram.com/?p=32298


A Mersenne prime is a prime number of the form Mp = 2p – 1, where the exponent p must also be prime. These primes take their name from the French mathematician and religious scholar Marin Mersenne, who produced a list of primes of this form in the first half of the seventeenth century. It has been known since antiquity that the first four of these, M2 = 3, M3 = 7,
M5 = 31 and M7 = 127, are prime.

Marin Mersenne

Mersenne claimed that 2p – 1 was prime for primes p ≤ 257 only for
p ∈ {2,3,5,7,13,17,19,31,67,127,257}. It is easy to verify where he was correct and where he was not, using the Wolfram Language function PrimeQ. PrimeQ uses modern prime testing methods that do not require finding a factor to prove a number to be composite.

It is possible that his claim that M67 is prime was a typographical error of M61. However, it is not hard to understand why primality testing was difficult in Mersenne’s time, since trial division was one of the few tools available. For example, for M257, the smallest factor is a 15-digit number and, even with modern factoring methods, it is not easy to find. The Wolfram Language function FactorInteger uses advanced methods that enable it to factor large integers.

Euler and the Mersenne Factor Theorem

Some of the first advances in primality testing were accomplished by the great mathematician Leonhard Euler, who verified that M31 is prime sometime before 1772. He did this by showing that any prime divisor of M31 must be congruent to 1 or 62 (mod 248).

Such a relatively short list could be checked by trial division (by hand) in a reasonable amount of time in Euler’s day. His was an application of the Mersenne factor theorem, which states that if q is a divisor of Mp, then q ≡ 1 or –1 (mod 8), q ≡ 1 (mod p) and q = 2kp + 1 for some positive integer k. These facts greatly limit the possible divisors of Mp. The functions below use this theorem to provide a list of possible factors of Mp that are less than .

We use these functions to quickly find a factor of 241 – 1. Note that q is a factor of 2p – 1 if and only if 2p ≡ 1 (mod q). This enables the use of PowerMod, which provides very efficient modular exponentiation.

The following is a Mersenne number with 161,649 digits

Lucas and Lehmer

The next major advance was the discovery by Édouard Lucas of a clever method to test the primality of numbers of this form. He used his method in 1876 to verify that M127, the largest Mersenne prime discovered before the age of computers, is prime. In the early twentieth century, after the understanding of binary arithmetic and algebra became widely known, Derek Henry Lehmer refined Lucas’ method. The resulting Lucas–Lehmer primality test provides an efficient method of testing if a number of this form is prime. It does this by using the modular equivalence

This means that k is congruent to the number represented by its lowest-order p bits plus the number represented by the remaining bits. This relation can be applied recursively until k < 2p – 1.

Consider the example that follows. Here we show that for
k = 1234567891. Note that kmod-bitand-k-2-23-1 , the lowest-order 23 bits, and , the remaining bits shifted to the lowest position.

The function below encodes this method to compute k (mod 2p – 1) using bit operations only (no division). Notice that 2n – 1 has the binary form 111 … 1112, all 1s and no 0s, so it also serves as a mask for the lower-order p bits of k.

The following function encodes the Lucas–Lehmer primality test (LLT). We define the sequence s0 = 4, s2i – 1 – 2; i > 0. Then Mp = 2p – 1 is prime iff sp – 1 ≡ 0(modMp).

Note: Experiments have shown that the runtime of these functions is dominated by the large integer arithmetic.

To efficiently test if 2p – 1 is prime, it is better to first check for small prime divisors and to perform other basic primality testing. We first use the Mersenne prime divisor theorem encoded in checkMPDivisors and then the Wolfram Language function PrimeQ. If neither of these complete in a short time, then we apply the Lucas–Lehmer test.

Here we present an extended version of PrimeQ that applies the Lucas–Lehmer test for large integers of the form 2p – 1.

M13 to M20

The first Mersenne prime discovered by a computer running the Lucas–Lehmer test was M521, found by Raphael M. Robinson on January 30, 1952, using the early vacuum tube-based computer SWAC (Standards Western Automatic Computer). The Williams tube memory unit of this computer, holding 256 words of 37 bits each, is shown below.

Williams tube

The 20th Mersenne prime was discovered by Alexander Hurwitz in November of 1961 by running the Lucas–Lehmer test for about 50 minutes on an IBM 7090. We reproduce these early results below, using about 151 seconds of single-core computing time on a modern laptop.

One feature of the Wolfram Language that makes it suitable for this kind of work is its fast, large-integer arithmetic. This was a real challenge in the early days of computerized Mersenne prime searching. Researchers quickly adopted fast Fourier transform methods to convert the problem of multiplying two large integers, essentially a convolution of two lists of digits, into a simple element-by-element product of transformed digits. Fast integer multiplication is needed for the squaring step in the Lucas–Lehmer test. The Wolfram Language uses the latest platform-optimized algorithms to work with exact integer numbers with up to billions of digits. By way of example, we verify that the last of these, M4423, is indeed a Mersenne prime and show all of its digits.

Perfect Numbers

There is an interesting connection between Mersenne primes and perfect numbers. A perfect number is a number that is equal to the sum of all of its divisors (other than the number itself). Euclid suspected, and Euler finally proved, that all even, perfect numbers have the form P = 2p – 1(2p – 1) = 2p – 1Mp. The Wolfram Language function PerfectNumberQ checks if a number is perfect. We demonstrate this property directly for M31.

The 21st, 22nd and 23rd Mersenne Primes

We proceed to rediscover #21 = M9689, #22 = M9941 and #23 = M11213. These were all discovered by Donald B. Gillies running the LLT on an ILLIAC II during the spring 1963 (the article can be found here). We use nearly 6 minutes of elapsed time to test all of the numbers of the form 2p – 1 for primes 7,927 ≤ p ≤ 17,389.

The 24th, 25th and 26th Mersenne Primes

We next extend the search to find #24 = M19937,
#25 = M21701 and #26 = M23209. The last of these was discovered in February of 1979 by Landon Curt Noll and Laura Nickel. They searched the range M21001 to M24499 using 6,000 CPU hours on a CDC Cyber 174 (that article can be found here). Our computations are becoming sufficiently intense to warrant the use of parallel processing. Since the tests of the candidate prime factors are independent, we can use ParallelMap to speed up the work. We check the range
17,393 ≤ p ≤ 27,449 in about three and a half minutes using 4 cores.

Notice how the specialized Lucas–Lehmer test is significantly faster than the more general function PrimeQ for these Mersenne primes.

The 27th and 28th Mersenne Primes

We next test the range 27457 ≤ p ≤ 48611 to locate
#27 = M44497. This was discovered in April 1979 on a Cray-1 by Harry Nelson and his team. Our search of this range runs in about 15 minutes.

The next Mersenne prime is #28 = M86243. It was discovered in September of 1982 by David Slowinski, also on a Cray-1. The Cray-1 supercomputer weighed about 5 tons, consumed about 115 kilowatts of power and delivered 160 MFLOPS of computing performance. It was supplied with 1 million 64-bit words of memory (8 megabytes), and cost about $16 million in today’s dollars. A detail of its significant cooling system is shown below. By comparison, a Raspberry Pi weighs a few ounces, runs on 4 watts, delivers about 410 MFLOPS and is provided with 1 gigabyte of RAM, all for about $40, and it comes with Mathematica.

Cray-1 supercomuter

The number M86243 has 25,962 digits. In 1 hour and 14 minutes we were able to find this value (on my laptop, not on a Raspberry Pi) by testing over the range 48,619 ≤ p ≤ 87,533.

The 29th Mersenne Prime

Since we are now using serious computer time, we also produce a timestamp for each run. We now check the range 87,557 ≤ p ≤ 110,597. In 1 hour and 44 minutes, this reveals #29 = M110503, first discovered on January 29, 1988, by Walker Colquitt and Luke Welsh running the LLT on an NEC DX-2 supercomputer (the article can be found here).

The 30th and 31st Mersenne Primes

The next two Mersenne primes, M132049, the 30th, and M216091, the 31st, were actually discovered before #29, by the same team that discovered #28. They used a Cray X-MP to find #30 in September of 1983 and #31 in September 1985. We verify #30 by searching the range 110,603 ≤ p ≤ 139,901. It took nearly 4 hours and 8 minutes to check each Mp in this range.

The Great Internet Mersenne Prime Search

The discovery of the 34th Mersenne prime, M1257787, in September 1996 ended the reign of the supercomputer in the search for Mersenne primes. The next 15 were found by volunteers of the Great Internet Mersenne Prime Search (GIMPS), which runs a variant of the Lucas–Lehmer test as a background process on personal computers. This large-scale distributed computing project currently achieves a performance equivalent to approximately 300 TFLOPS per second, harnessing the otherwise idle time of more than 1.3 million computers.


We verify the 34th Mersenne prime by directly using the Lucas–Lehmer test. We are reaching the limits of personal computer capability. Testing thousands of Mersenne numbers in this range would take many days. It is interesting to note that the Lucas–Lehmer test is often used as a stress test for the reliability of computer hardware and software, as even one arithmetic error among the billions of computations needed for testing one large prime will produce an incorrect conclusion, miss a true Mersenne prime or falsely report that a composite is prime. The fact that we have tested every Mp for primes between 2 and 139,901 is strong evidence for the reliability of large integer arithmetic and binary operations in Mathematica.

Factoring Mersenne Numbers

As we have seen, the possible factors of numbers of the form
2p – 1 are limited by the Mersenne factor theorem. This has enabled an efficient computerized search for the factors of large integers of this form. The integer q divides 2p – 1 only if 2p ≡ 1 (mod q), which can be quickly checked with PowerMod. At the time of this writing, all Mersenne numbers up to 21201 – 1 have been fully factored. A Wolfram Demonstration that illustrates these can be found here. The GIMPS project has also led to the discovery of large factors of many Mersenne numbers as a byproduct of its primality testing. A recent paper that presents a modern approach to this problem, along with 17 new factorizations, can be found here. The largest number factorized was 21199 – 1; its smallest newly found factor has 76 decimal digits. Its smallest factor is actually 23. The total computer time for this effort was nearly 7,500 core years.

We can quickly find the first few factors of 21201 – 1 using the Wolfram Language function FactorInteger.

The Wolfram Language has cataloged of all of the Mersenne primes discovered to date, with ordering up to #44. Access to this information is provided by the functions MersennePrimeExponent and MersennePrimeExponentQ.

If you find this subject interesting, you can find more details at the following websites.

Download this post as a Computable Document Format (CDF) file. New to CDF? Get your copy for free with this one-time download.

http://blog.wolfram.com/2016/09/30/mersenne-primes-and-the-lucas-lehmer-test/feed/ 2
2016 Wolfram Europe French Tour http://blog.wolfram.com/2016/09/26/2016-wolfram-europe-french-tour/ http://blog.wolfram.com/2016/09/26/2016-wolfram-europe-french-tour/#comments Mon, 26 Sep 2016 07:00:42 +0000 Lizzie Griffiths http://blog.internal.wolfram.com/?p=32522 Bonjour la France! This October, we’re coming to you to introduce Mathematica 11. We will be running three conferences across France, starting October 4.

Seminaire Mathematica

The conferences will have seminars on topics such as these:

  • Machine learning and neural networks
  • Data science
  • Predictive analytics
  • Cloud development
  • Image processing
  • Graph theory
  • Applied mathematics

Each seminar will introduce Mathematica 11 and its new features, alongside a more in-depth talk with one of our specialists.

The tour will be a great opportunity to check out our latest technology, talk to our developers and get the chance to meet fellow technical specialists and Mathematica experts.

Each date will include several talks. For more information and to reserve your space, please visit the following webpages:

October 4, 2–5pm: Lyon

October 5, 9am–12pm and 2–4:30pm: Grenoble

October 6, 1:30–5:30pm: Paris

Guest speakers on the tour include Sander Huisman, an active contributor on Wolfram Community, who will discuss Mathematica by examples; Bruno Autin, who will share insights on Geometrica; and Alain Carmasol from Universite de Lorraine, who will give a talk on Mathematica for engineers. Wolfram Research’s technical consultant Robert Cook will be available all three days, giving an overview on what’s new in Mathematica 11 and a talk on insight and prediction.

See you there!

http://blog.wolfram.com/2016/09/26/2016-wolfram-europe-french-tour/feed/ 0
New in the Wolfram Language: Audio http://blog.wolfram.com/2016/09/23/new-in-the-wolfram-language-audio/ http://blog.wolfram.com/2016/09/23/new-in-the-wolfram-language-audio/#comments Fri, 23 Sep 2016 19:02:06 +0000 Carlo Giacometti http://blog.internal.wolfram.com/?p=32528 I have always liked listening to music. In high school, I started wondering how it is that music seems to be so universally pleasing, and how it differs from other kinds of sounds and noises. I started learning to play guitar, and later at the University of Trieste, I learned about acoustics and signal processing. I picked up the guitar in high school, but once I began learning to program, the idea of being able to create and process any sound using a computer was liberating. I didn’t need to buy expensive and esoteric gear; I just needed to write some (or a lot!) of code. There are many programming languages that focus on music and sound, but complex operations (such as sampling a number from a special distribution, or the simulation of random processes) often require a lot of effort. That’s why the audio capabilities in the Wolfram Language are special: the ability to deal with audio objects is combined with all the knowledge and computational power of the Wolfram Language!

First, we needed a brand-new atomic object in the language: the Audio object.


Play Audio

The Audio object is represented by a playable user interface and stores the signal as a collection of sample values, along with some properties such as sample rate.

In addition to importing and storing every sample value in memory, an Audio object can reference an external object, which means that all the processing is done by streaming the samples from a local or remote file. This allows us to deal with big recordings or large collections of audio files without the need for any special attention.

The file size of the two-minute Bach piece above is almost 50MB, uncompressed.



The out-of-core representation of the same file is only a few hundred bytes.

afile = Audio["http://exampledata.wolfram.com/bach.mp3"]

Play Audio
audio out 3



Audio objects can be created using an explicit list of values.

f[t_] := Mod[<br />
   t*BitAnd[BitOr[BitShiftRight[t, 12], BitShiftRight[t, 8]],<br />
     BitAnd[63, BitShiftRight[t, 4]]], 256, -128];<br />
data = Table[f[t], {t, 0, 100000}];<br />
data // Short

Audio[data, "SignedInteger8", SampleRate 8000]

Play Audio

Various commonly generated audio signals can be easily and efficiently created using the new AudioGenerator function, ranging from basic waveform and noise models to more complex signals.

Table[Labeled[<br />
  AudioPlot[AudioGenerator[wave, .01], PlotTheme "Minimal"],<br />
  wave], {wave, {"Sin", "Sawtooth", "White"}}]

Play Audio

The AudioGenerator function also supports pure functions, random processes and TimeSeries as input.

Play Audio

Now that we know what Audio objects are and how to create them, what can we do with them?

The Wolfram Language has a lot of native features for audio processing. As an example, we have complex filters at our disposal with very little effort.

Use LowpassFilter to make a recording less harsh.

Play Audio

Play Audio

WienerFilter can be useful in removing background noise.

Play Audio

Play Audio

A lot of audio-specific functionality has been developed for editing and processing Audio objects—for example, editing (AudioTrim, AudioPad, AudioNormalize, AudioResample), to visualization (AudioPlot, Spectrogram, Periodogram), special effects (AudioPitchShift, AudioTimeStretch, AudioReverb) and analysis (AudioLocalMeasurements, AudioMeasurements, AudioIntervals).

It is easy to manipulate sample values or perform basic edits, such as trimming.

A fun special effect consists of increasing the pitch of a recording without changing the speed.

Play Audio

Play Audio

And maybe adding an echo to the result.

Play Audio

With a little effort, it is also possible to apply more refined processing. Let’s try to replicate what often happens at the end of commercials: speed up a normal recording without losing words.

We can start by deleting silent intervals.

Delete the silences from the recording.

Play Audio

Finally, speed up the result using AudioTimeStretch.

Play Audio

To make the result sound less dry, we can apply some reverberation using AudioReverb.

Play Audio

Much of the processing can be done by using the Wolfram Language’s arithmetic functions; all of them work seamlessly on Audio objects. This is all the code we need for amplitude modulation.

Play Audio

Play Audio

Play Audio

Or you can do a weighted average of a list of recordings.

Play Audio

Play Audio

Play Audio

Play Audio

Play Audio

A lot of the analysis tasks can be made easier by AudioLocalMeasurements. This function can automatically compute a collection of features from a recording. Say you want to synthesize a sound with the same pitch and amplitude as a recording.

Play Audio

AudioLocalMeasurements makes the extraction of the fundamental frequency and the amplitude profile a one-liner.

Using these two measurements, one can reconstruct pitch and amplitude of the original signal using AudioGenerator.

Play Audio

We get a huge bonus by using the results of AudioLocalMeasurements as an input to any of the advanced capabilities the Wolfram Language has in many different fields.

Potential applications include machine learning tasks like classifying a collection of recordings.

And then there’s 3D printing! Produce a 3D-printed version of the waveform of a recording.

You can get an idea of the variety of applications at Wolfram’s Computational Audio page, or by looking at the audio documentation pages and tutorials.

Sounds are a big part of everyone’s life, and the Audio framework in the Wolfram Language can be a powerful tool to create and understand them.

http://blog.wolfram.com/2016/09/23/new-in-the-wolfram-language-audio/feed/ 3
Announcing Wolfram Enterprise Private Cloud http://blog.wolfram.com/2016/09/19/announcing-wolfram-enterprise-private-cloud/ http://blog.wolfram.com/2016/09/19/announcing-wolfram-enterprise-private-cloud/#comments Mon, 19 Sep 2016 17:38:16 +0000 Conrad Wolfram http://blog.internal.wolfram.com/?p=32331 Today I’m pleased to announce Wolfram Enterprise Private Cloud (EPC), which takes the unique benefits of the Wolfram technology stack—ultimate computation, integrated language and deployment—and makes them available in a centralized, private, secure enterprise solution.

In essence, EPC enables you to put computation at the heart of your infrastructure and in turn deliver a complete enterprise computation solution for your organization.

EPC diagram

There are two strands to this blog post: what we’re delivering and why you’d want an enterprise computation solution and strategy.

Here’s how we got to today. For a few years, one of our key directions at Wolfram has been to build computation as a cloud service, so high-level computation (and computation-rich development) can be deliverable to everyone with the convenience of a cloud deployment. A couple of years ago we delivered our public cloud, a manifestation of core Wolfram technology delivered as a consumer service for professionals and individuals, but hosted by us.

EPC is the enterprise “privatization” with enhanced capabilities—taking this public Wolfram Cloud and packaging it up for hosting on any organization’s infrastructure or a designate like Amazon’s EC2. Instead of us offering the computation cloud service, you can, all within your enterprise. That means all the computation of Mathematica 11 and rapid application development of the Wolfram Language can now be server-side and cloud-based in your organization. High-level computation (for example, applied to your private data) can be an instant, ready-to-go, secure internal service for anyone you choose, with a wide range of interface modalities you can use directly for deploying from CEOs to developers, and instant APIs to go through other applications too.

Let me also point out the key principle that I believe marks out our technology as uniquely suitable for this centralized computation service model: we’re a unified, all-in-one system, not a collection of different systems for different tasks. We’ve put together all computational fields and functionality into one high-level, coherent Wolfram Language. We’re enabling complete interconnectedness. In a cloud-based service, lots of different systems means lots of separate “computational servers” to do different things—stats, reporting, modeling—causing huge switching losses, and that’s once you’ve got them and kept them playing together at all for a given task or workflow. Disparate systems are a real killer for broad, computation-based productivity.

That’s why our technology is in general so suitable for a private cloud manifestation.

We’re also adding many technologies we’ve implemented specially for EPC—from pre-warmed APIs to intra-node parallelization.

In the end, EPC has one objective: to enable computation everywhere in your organization, whether through ease of advanced access by traditionally computational groups or newfound access outside those groups.

First quote

So at one level, Wolfram Enterprise Private Cloud is an (exciting) new product. But at another, I believe it’s something much more significant: the start of a fundamental shift in how organizations see and deliver computation for the enterprise.

What do I mean by this? Until recently, the use of high-level computation has only been accessible to a small number of specialists in most organizations. If you’re not one of them, you really had three options: use basic computation (like Excel) yourself; rely on preordained, heavily collimated uses of computation; or seek out a specialist to build something custom or give you a one-off answer.

But computation is now very central to a huge number of organizational functions and the organization itself. It isn’t just for the specialist, many layers removed from the CEO; it’s too core for that. So likewise, it’s important to have an architecture for computation that matches this new reality. That means quality, security, command-and-control, coherence and consistent technology ability for computation need to be enterprise functions, not each decided ad hoc for each use or by each user. I’m describing the need for every organization to look at their enterprise computation strategy (which you can see explained more in our short video piece).

Here’s a typical example I come across. I’m visiting a bank and they ask, “Can the Wolfram Language make DLLs [dynamic link libraries] for Excel?” Digging into this request further, I find out that R&D is using the Wolfram Language for building prototypes that traders want to use through their familiar Excel interface. They’d like to package the DLLs up to hand to each trader instead of recoding. I ask, “But what happens if that R&D code has got a bug and the trader goes on running it? Or leaves and has taken a copy with them? How quickly can you even deploy this in practice? How is this wired directly to management reporting?”

The bank’s question betrays an “individual computation” way to think about the problem. The “enterprise computation” way would instead be for R&D to host an API on the private cloud to connect to an Excel interface. R&D can update the cloud deployment anytime—there’s no DLL to be updated and redistributed, there’s no choice needed between computational ability and interface, there’s no translation or installation; the quality, tracking, auditing and security models are much easier to govern.

EPC DLL comparison small


One key driver for enterprise computation is big data—you could even say big data is a killer first reason for enterprise computation. So many organizations now state that failing to get the best answers from their data is a core business-strategic issue. They have amassed huge amounts of data but not effective, imaginative and broad-based analytics and visualization. Data and analytics mustn’t be siloed but need to be diced between groups; a data analytics hub is needed. (Watch my live and interactive 2015 Thinking Digital talk about decisions and data and computation.)

When data analytics was a specialist function in organizations, using desktop software—ours particularly!—matched up fine. But now data analytics is a shared enterprise problem; you need to match it with a shared enterprise computation solution—starting with EPC. Only an enterprise model, not an individual desktop one, can sort out data analytics failings.

This change to an enterprise model is new to general computation but not to previous technological progress. Often there’s a question of whether the powerhouse should be distributed or centralized.

Think electrical power. In the very early days (mid-19th century), each user pretty much generated their own. Then centralized power stations were found more effective and efficient at delivering the widely varying requirements of each user. But to reach most people, they depended on a network, technological and engineering progress (e.g. transformers) and standardization so everything interoperated (e.g. the power grid). It may be now with photovoltaic cells and other small-scale power generation opportunities that we’re entering a hybridized power generation future with an optimized mixture of local and centralized generation combined.

With computing, we’ve flip-flopped from mainframe to PC and now to the hybridization of local and cloud computing—the web providing necessary networking standardization to make this a practical reality.

Yet since the mainframe, the high-end computation part of computing hadn’t adopted an enterprise or hybridized architecture. That’s the change we’re starting today with EPC: enterprise as well as local computation—elevating computation to a core service. Much more will follow from us, including a complete hybridized enterprise computation ecosystem.

One consequence I’m very happy about: how EPC empowers our many Wolfram technology enthusiasts to get colleagues’ and management’s attention for their great, innovative work. Almost any Wolfram Language results that have stayed local can now be deployed (all within organizational security policies) as ready-to-use computational power and knowledge-based programs to anyone with a web browser. EPC gives our existing users (and me!) a terrific answer to questions like “How do I use my Wolfram Language code in a production environment?”

Second EPC quote

EPC can deliver many things we’ve been asked for, but it can go further by resetting thinking about computation.

In particular, I’m finding real excitement in early briefings to CTOs, CIOs and others concerned with technology strategy about this architectural shift and EPC. Not all couched their current infrastructural challenges in these terms, but most agree they do need a much more coherent enterprise computation strategy moving forward.

That’s what Wolfram Enterprise Private Cloud and Wolfram can get you started with today.

Wolfram offers both technology and consulting to help organizations apply computation everywhere. Discuss your needs with our specialists.
http://blog.wolfram.com/2016/09/19/announcing-wolfram-enterprise-private-cloud/feed/ 0
Wolfram Summer Camp 2016 Wrap-Up http://blog.wolfram.com/2016/09/16/wolfram-summer-camp-2016-wrap-up/ http://blog.wolfram.com/2016/09/16/wolfram-summer-camp-2016-wrap-up/#comments Fri, 16 Sep 2016 16:59:52 +0000 Greg Hurst http://blog.internal.wolfram.com/?p=32347 Thirty-nine students from seven different countries attended our camp at Bentley University this summer. Students arrived at camp with some programming experience, but most had little or no familiarity with the Wolfram Language. Despite this, in nine short days they were all able to complete amazing projects.

Group Image of Wolfram Summer Camp Participants

Throughout the two weeks, students learned the Wolfram Language from faculty and a variety of guest speakers. They had the opportunity to see Stephen Wolfram give a “live experiment” and speak about the company, entrepreneurialism and the future of technology. Students also heard from guest speakers such as Etienne Bernard and Christopher Wolfram, who showed off other aspects of the Wolfram Language.

Although students spent a vast amount of time hard at work on their projects, they also had many laughs throughout the program. They participated in group activities such as the human knot, the Spikey photo scavenger hunt and the toothpick-and-gumball building contest, as well as weekend field trips to the Boston Museum of Science and the New England Aquarium.

Students having fun at Wolfram Summer Camp

The students completed phenomenal projects on a wide range of topics, ranging from geospatial analysis, textual analysis, machine learning and neural nets, physical simulations, pure math and much more. Here are just a few projects:

“Where Is Downtown?” by Kaitlyn Wang. This project uses cluster analysis and data from Yelp and Wikipedia obtained with ServiceConnect to estimate the polygon of a city’s downtown.

Estimating the polygon of a city's downtown

“Where Will Your Balloon Go?” by Cyril Gliner. This project uses WindVectorData to simulate where a balloon would travel when let go at a given time and location on Earth.

Simulating balloon travel distance

“Tiling Polyominoes Game,” by Jared Wasserman. This drag-and-drop game asks the user to place the polyominoes on the right to cover all the gray areas on the left without overlapping the tiles.

Screenshot of Polyonminoes game

“Automatic Emoji Annotator!” by Marco Franco. This project imported over 50,000 tweets to create a neural network that gives the emojis that best represent a sentence.

Automatic Emoji Annotator

“Automated Face Anonymizer,” by Max Lee. This is perhaps the project I found to be the most fun, only because it involved me. It anonymizes an image by replacing faces with my head.

Automated Face Anonymizer

This word cloud represents the most common Wolfram Language symbols the students collectively used in their projects:

Word cloud of student projects

Here are frequencies of the 30 most commonly used symbols by the students. The first few symbols were used so frequently, a log scale is used:

30 most commonly used symbols

How do these frequencies compare with normal, everyday usage of the Wolfram Language? We can answer this with the WolframLanguageData property "Frequencies". It turns out the usage frequencies from camp versus normal usage have a correlation coefficient of about 0.8. Here’s how the first few symbols compare:

Symbol frequency in student projects compared to everyday use
Table legend

Lastly, we can use the WolframLanguageData property "RelatedSymbols" and CommunityGraphPlot to group the symbols used by the students into clusters based on topic. It shows how eclectic this group of 39 students’ projects were:

Graphplot of student projects based on symbols

http://blog.wolfram.com/2016/09/16/wolfram-summer-camp-2016-wrap-up/feed/ 0