Community RSS Feed
http://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions from all groups sorted by activePalette user interface
http://community.wolfram.com/groups/-/m/t/1238569
Hi all,
I am using Wolfram Mathematica about 10 years, but the user interface did not improve substantially. I really upset that such innovative company as Wolfram Research did not provide any useful alternative of palettes and docked cells for packages developers.
From my own point of view the palettes have several shortcomings.
1. they overlay each other and notebooks. Users have to waste more time for allocate the palettes than use them. Typically users open several notebooks and the next one notebook opens on its own place of screen without any correlation with the palettes. Finally users decide to close the palettes.
2. the functional of the palettes is scarce. Some package developers prefer to create a small notebook with buttons rather than the palette.
3. the palettes look archaic in comparison with other programs.
----------
For example, a ribbon interface has proved effective. Take a look at MS Word, Matlab, Foxit Reader and so on. Or maybe one can use a tabbed document interface for notebooks.Mikhail Cherkasskii2017-12-04T06:31:52ZHow do I set NIntegrate Method correctly?
http://community.wolfram.com/groups/-/m/t/1244595
Hello, I'm trying do define a function this way:
f[a_?NumericQ, b_?NumericQ]:=NIntegrate[g[k,a,b],{k,0,Infinity},Exclusions->{0},MaxRecursion->70,Method->{"GaussKronrodRule","Points"->20},WorkingPrecision->6]
Where g is a function which has a singularity in k=0 and is oscillating.
If I then compute lets say f[5,0] it returns me an error saying:
NIntegrate::levtime: Time spent solving linear system in LevinRule exceeded 10.` seconds. Try increasing the value of the "TimeConstraint" option or decreasing the value of the "Points" option.
NIntegrate::mtdfb: Numerical integration with LevinRule failed. The integration continues with Method -> GaussKronrodRule.
... and that the result is computed correctly
This makes me think that there's something wrong in how I wrote the method option. If I don't include the WorkingPrecision->6 options (and I choose an "a" so that this donesn't give problems) appearently it computes succesfully. I need to use an "a" ranging from 10^-6 to 10^15 so I need to increase the WorkingPrecision as for a->0 NIntegrate returns me an error saying that it needs a bigger working precision.
I hope you can give me some advise, thank you for your help and patienceAurelio Amerio2017-12-13T10:46:03ZWhat Game of Thrones character do you resemble?
http://community.wolfram.com/groups/-/m/t/1242672
Hi all,
First time community poster here! I'll start off by saying, I am by no means an expert in machine learning. I dabble with the basic tutorials and training options offered by Wolfram, but when it comes to the guts of this stuff, I'm brand new. I say this as I think my project here is a good proof of concept on how easy it is to pick up machine learning with the Wolfram language. (Feel free to skip to the bottom of the post for a link to my notebook.)
**Initial testing**
To start out, I simply looked into the basic machine learning examples provided around our Mathematica 11 release, linked [here][1]. The [Create a Legendary Creature Recognizer][2] in particular is what I based my initial testing off of.
To start, I narrowed it down to two relatively different but very popular characters, Daenerys Targaryen and Jon Snow. Similar to the format in the creature recognizer, I simply imported images, associated them to the character name, and plugged this into my [Classify][3] function. To test it's capabilities, I used the "Top Probabilities" call to see with what confidence it was assigning characters.
Like I said, I'm new to machine learning, so this was a learning process for me. To my surprise, this solution was rather messy and just not at the level of accuracy I was looking for. It struggled with actors/actresses out of costume, was polluted by the background, and just didn't have enough images to be accurate.
This is what lead me to ultimately focus on 3 things when training my classifier function and eventually my neural networks. 1) Images of characters should include the actors or actresses both in and out of costume. 2) The [FindFaces][4] functions needed to be used to remove any background or outfit pollution. 3) The amount of images for each character needed to be as large as possible.
**Collecting images for my dataset**
Once I was able to mast extracting images using FindFaces, it was time to do some heavy internet image searching to get the relevant images. I decided to limit my identifier to just 7 characters: Dany, Jon, Tyrion, Cersei, Jaime, Arya, and Sansa (apologies to all of the Davos fans!) As mentioned before, I did specific searches for characters throughout the seasons as well as actors/actresses outside of costume (as well as additional searches for different hairstyles, facial hair, glasses, age, etc.)
To speed up this process, I first created a quick image tester to be sure that each of the images I pulled from my searches was being pulled correctly without having to test the entire dataset all at once. For example, I would test all of the season 1 images I found of Dany at one time. You can see what this looks like below.
![enter image description here][5]
testImgs = {}
i = 1;
testFaces = {};
While[i < Length[testImgs] + 1,
testFace = ImageTrim[testImgs[[i]], #] & /@ FindFaces[testImgs[[i]]];
AppendTo[testFaces, ImageResize[testFace[[1]], Tiny]];
i++;
]
testFaces
For proof of concept, the image includes a couple common errors that I found. In some cases, The image would not be able to find any faces per low-quality or just odd lighting/angles, in which would result in the error. In other cases, images would pick up background noise that resembled a face (not provided in this example). You can see in the last picture, another character's face was found first. These images would need to be removed from the set before being added to the full dataset. As I went along, it became easier to weed out images that would likely be unusable. You can see an example of what these image sets would look like below. Jaime's in particular was my smallest.
![enter image description here][6]
The final step in this process was to make the appropriate associations for the images and provide a list that could be used by the Classify function. You can see the code for this below. To summarize, I made separate lists of images for each character, then iterated through those list to associate them with the appropriate character name then add that associated object to my master list.
faceRec = {};
i = 1;
While[i < Length[dt] + 1,
dtface = ImageTrim[dt[[i]], #] & /@ FindFaces[dt[[i]]];
AppendTo[faceRec, ImageResize[dtface[[1]], {100, 100}] -> "Dany"];
i++;
]
i = 1;
While[i < Length[js] + 1,
jsface = ImageTrim[js[[i]], #] & /@ FindFaces[js[[i]]];
AppendTo[faceRec, ImageResize[jsface[[1]], {100, 100}] -> "Jon"];
i++;
]
i = 1;
While[i < Length[tl] + 1,
tlface = ImageTrim[tl[[i]], #] & /@ FindFaces[tl[[i]]];
AppendTo[faceRec, ImageResize[tlface[[1]], {100, 100}] -> "Tyrion"];
i++;
]
i = 1;
While[i < Length[cl] + 1,
clface = ImageTrim[cl[[i]], #] & /@ FindFaces[cl[[i]]];
AppendTo[faceRec, ImageResize[clface[[1]], {100, 100}] -> "Cersei"];
i++;
]
i = 1;
While[i < Length[jl] + 1,
jlface = ImageTrim[jl[[i]], #] & /@ FindFaces[jl[[i]]];
AppendTo[faceRec, ImageResize[jlface[[1]], {100, 100}] -> "Jaime"];
i++;
]
i = 1;
While[i < Length[as] + 1,
asface = ImageTrim[as[[i]], #] & /@ FindFaces[as[[i]]];
AppendTo[faceRec, ImageResize[asface[[1]], {100, 100}] -> "Arya"];
i++;
]
i = 1;
While[i < Length[ss] + 1,
ssface = ImageTrim[ss[[i]], #] & /@ FindFaces[ss[[i]]];
AppendTo[faceRec, ImageResize[ssface[[1]], {100, 100}] -> "Sansa"];
i++;
]
faceRec = RandomSample[faceRec, Length[faceRec]];
Per a note from one of our developers, I also chose to randomize the list of associations, as our neural network framework down assume a random order when processing. This didn't provide any noticeable difference in my dataset, but I thought it was an important thing to at least note.
**Using the Classify function**
With my images associated, I was ready to jump into creating my ClassifierFunction. With a single line of code, I was able to do so, as seen below.
gotFaces = Classify[faceRec]
To test my model, I pulled in some new images and used the same logic as before to create a testing set. I did try to find images in costume as well as in real life, with different hairstyles, and at different ages to provide some more variety in my testing.
![enter image description here][9]
test = {}
i = 1;
testFaces = {};
While[i < Length[test] + 1,
testFace = ImageTrim[test[[i]], #] & /@ FindFaces[test[[i]]];
AppendTo[testFaces, ImageResize[testFace[[1]], {100, 100}]];
i++;
]
testFaces
I will note, that doing this same process to this point with just Jon and Dany worked REALLY well. To my surprise, though, it just wasn't quite as promising with a larger cast of characters. Some characters were correct with relatively high confidence, some were right but with a split between a few characters, and some were wrong but at least had the correct character in close proximity to the top character.
Manipulate[gotFaces[character, "TopProbabilities"], {character, testFaces}]
![enter image description here][10]
![enter image description here][11]
![enter image description here][12]
This had me troubleshooting like crazy. I will say that simply duplicating the associations already in the list several times actually improved the accuracy quite a bit, which was expected. With this in mind, I decided to try my hand at our neural network functionality.
**Using the NetChain and NetTrain functions**
I'll say it once, and I'll say it again. I am by no means an expert in neural networks. It's a big topic in tech now, so I've developed a basic conversational understanding of the concept. However, this was my first time actually creating my own neural network in any language.
The process was relatively simple, much to my surprise, thanks to Wolfram's vast amount of documentation. Per some research, I learned about "convolutional" neural nets and found a similar image example of this in our documentation pages for [NetTrain][13]. Using this example, I made some minor adjustments to the NetChain to fit this to my own data and was well on my way to training my first neural net! You can see what this ended up looking like below. The variable "classes" simply being all of the potential characters.
lenet = NetChain[
{ConvolutionLayer[20, 5], Ramp, PoolingLayer[2, 2],
ConvolutionLayer[50, 5], Ramp, PoolingLayer[2, 2], FlattenLayer[],
500, Ramp, 7, SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", classes}],
"Input" -> NetEncoder[{"Image", {100, 100}}]
]
From here, the NetTrain function is super simple. You can see an image of what this looks like in motion below with real-time training progress as the program runs. For larger sets of data, there is also the option to add a time goal. For mine, I simply allowed it to run for the full 10-15 minutes. It's certainly interesting to be able to actually see the loss function change as the data set runs.
trained = NetTrain[lenet, faceRec]
![enter image description here][15]
This method did still have its errors but the accuracy as well as the confidence in the selections did seem to be significantly higher. I saw much more examples of split "TopProbabilities" for the wrongly classified images, as with the Dany and Arya pictures below, but also a much larger level of correctly classified images with 90%+ as their "TopProbabilities" return, as with the Jon and Sansa pictures below.
Manipulate[trained[character, "TopProbabilities"], {character, testFaces}]
![enter image description here][16]
![enter image description here][17]
![enter image description here][18]
![enter image description here][19]
As with the Classify function, adding more images (even duplicates) to the dataset did provide even more accurate results and confidence to the neural net model. Ideally, if using this for an actual application, I would have a more elegant way of importing the images in for the NetTrain. A suggestion from a meeting I sat in recently was to explore [NetEncoder][20]. I also got the vibe that there are some other options in the pipeline to support this, specifically with large numerical datasets.
**Real-time character matching**
Moving on to the fun part that you've all been waiting for! I started out by using the same logic as with my character image import to pull in images from LinkedIn of my coworkers to see how the ClassifierFunction and NetChain handled these outside inputs.
![enter image description here][21]
wolfram = {}
i = 1;
wolframFaces = {};
While[i < Length[wolfram] + 1,
wolframFace = ImageTrim[wolfram[[i]], #] & /@ FindFaces[wolfram[[i]]];
AppendTo[wolframFaces, ImageResize[wolframFace[[1]], {100, 100}]];
i++;
]
wolframFaces
I understand that this is not exactly what deep learning is intended for, but it's a fun little application to try to trick the trained sets to force us into a character. The models definitely vary on what character they give to each coworker, so it is noticeable that their methods are likely quite different. However, it did give a highly odd confidence for some of my coworkers in both cases.
Manipulate[
gotFaces[employee, "TopProbabilities"], {employee, wolframFaces}]
![enter image description here][22]
And finally, the quiz you've all been waiting for. THE LIVE IDENTIFIER! You can see a quick image of what this looks like below. It uses the camera on your computer to allow you to grab a live image of yourself and run this through the ClassifierFunction and NetChain.
Panel[
Column[{
Row[{ImageCapture[ImagingDevice -> $ImagingDevice]}],
Row[{
Button[TextCell["Grab Image", FontSize -> 24],
img = CurrentImage[ImageSize -> 900], ImageSize -> {337, 50},
Alignment -> Center]
}],
Row[{TextCell["Captured Faces", Bold, FontSize -> 24]},
Alignment -> {Top, Center}],
Row[{Dynamic[currentFace = ImageTrim[img, #] & /@ FindFaces[img]]}],
Row[{TextCell["Classify function ID", Bold, FontSize -> 24]}],
Row[{Dynamic[
Style[gotFaces[currentFace, "TopProbabilities"],
FontSize -> 16]]}],
Row[{TextCell["Neural net ID", Bold, FontSize -> 24]}],
Row[{Dynamic[
Style[trained[currentFace, "TopProbabilities"],
FontSize -> 16]]}]
}
], ImageSize -> 355]
![enter image description here][23]
It's interesting to use this "live" model to start exploring how the input images are affecting the final trained sets. I noticed that although I tended to lean towards a small group of characters (especially in the Neural net ID), some particular factors could vary the outputs. Image quality (per camera or amount of cropping from not being close enough), head tilt, hair in face, facial expressions, etc. did provide some level of variation in my quick analysis.
**Closing thoughts**
Although not a perfect model, it's been really reassuring to know the level of accuracy obtained on such a small dataset and with very little knowledge of the appropriate neural networks to be used with this type of analysis. Being able to jump right in per the support of the Wolfram documentation as well as the ease of built-in functions made it SUPER easy to build such a model from scratch.
If I were looking to develop further, I would like to explore more about neural networks geared towards facial recognition as well as better way to collect as well as import a vast dataset of even more characters. It would be my hope that this would 1) better identify certain defining features and 2) eliminate the variations that we see more obviously in the live camera model.
It's not perfect, but what a fun proof of concept and a great learning experience! You can download all of the files [here][24]. Specifically, the GOTFacesApplication is a more simplistic model that imports the .wlnet model vs. having you have to sit and wait for the full project notebook to evaluate. Since some of the Import/Export on the [WLNet][25] functionality is still "experimental", I hit some snags on creating a CDF to be used with our free CDF player (my apologies to those who haven't made the jump to Mathematica yet!)
Hope you all enjoy!
[1]: https://www.wolfram.com/language/11/improved-machine-learning/?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[2]: https://www.wolfram.com/language/11/improved-machine-learning/create-a-legendary-creature-recognizer.html?product=language&lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[3]: http://reference.wolfram.com/language/ref/Classify.html?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[4]: http://reference.wolfram.com/language/ref/FindFaces.html?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAA6zAAAAJDEwNTRhMDhjLTU4MTQtNGUxYy05NGZmLWE2MGQwMTNhOWYwZg.jpg&userId=1161398
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAA5kAAAAJGQwNjFmMzRiLTIyNzQtNGE0Ni1iOGVhLWJmMmVkZjdjMTFiNg.jpg&userId=1161398
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAulAAAAJDc2OTEwODEzLTA2ZWMtNDFkOS1hNjRlLWQzYTE1MjIzMGRiMw.jpg&userId=1161398
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAAyLAAAAJDgyMGIxZWEyLWM4NDEtNDdhNi1hZmE2LThlOTY5ODFjZjA1NQ.jpg&userId=1161398
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAAtPAAAAJGQ0Y2M3NGFjLTM3ZDEtNDU2Yy04NDRiLWNlMzQ3ZDUwZWE5OA.jpg&userId=1161398
[10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAA18AAAAJDYxZWZmYTEzLTViYWEtNDVmZC05NThiLTZiYzQ2MGY0NTQ3OA.jpg&userId=1161398
[11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAA8XAAAAJDkzMzcyNTQyLTU2YmEtNDkxYi04Zjk1LWY3NjQ3MWJlY2VhMA.jpg&userId=1161398
[12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIAAQDGAAgAAQAAAAAAAAxKAAAAJDExODhmNzczLTQyNjMtNGY4MC04ZTA2LTgzMTY2MTczYzMxMg.jpg&userId=1161398
[13]: http://reference.wolfram.com/language/ref/NetTrain?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAA8NAAAAJDU3Y2QzNDI1LTgxYjItNDU5Yi1hZWZiLTg2YzQ0NzIyZDFmMg.jpg&userId=1161398
[15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAuBAAAAJDhiMmNhMjU2LTJhOWYtNGE3OC04NWFlLTczNWViMDYzNzU1Yg.jpg&userId=1161398
[16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAvlAAAAJDI3NGYyMDAxLWQyNWQtNGM5NC1iZjNjLTU5NDdhYzdmZmY0YQ.jpg&userId=1161398
[17]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAA7eAAAAJGRkMTBkYWY1LTNiMGUtNDA5NS05YTk2LTg5MGIwYzVlNzE3Zg.jpg&userId=1161398
[18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAA8KAAAAJGViNzc1MDU4LTUzZGUtNGY1ZC1hMWY3LTlkYzExNzVjMGRiZA.jpg&userId=1161398
[19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAApWAAAAJDdhMGQ4YjI3LTg5OGEtNGE3Yi1hODY2LTIzMzE2Njc5NjIyOA.jpg&userId=1161398
[20]: http://reference.wolfram.com/language/ref/NetEncoder.html?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[21]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAA1QAAAAJDFiNDRlNWYyLWI5ZDAtNDA0Zi1hYTdmLTBlMGQ4MzBmNjFmNw.jpg&userId=1161398
[22]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAnJAAAAJDdmMmExMzI5LWQwM2MtNDE3My1iNDBlLTJkODc2YmIxMTVkMw.jpg&userId=1161398
[23]: http://community.wolfram.com//c/portal/getImageAttachment?filename=AAIABADGAAgAAQAAAAAAAAtuAAAAJDMxNzIyOTljLWFkYTUtNDBkMC1iNWIyLTZjODNhYmZiMzE0Yg.jpg&userId=1161398
[24]: https://amoeba.wolfram.com/index.php/apps/files/?dir=/LinkedIn%20Notebooks/GoT&lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==
[25]: http://reference.wolfram.com/language/ref/format/WLNet.html?lipi=urn:li:page:d_flagship3_pulse_read;Dgg9GItqQQ%2bBZdXo2Z7y8A==Sam Tone2017-12-11T23:40:19Z[✓] Get plot with just axes crossing at the origin?
http://community.wolfram.com/groups/-/m/t/1242000
Hi, when I plot (3D) a 2 variable scalar function in wolfram Mathemática I always get the function in a box formed by the axis. How could I get rid of that box and just see the surface I´m plotting and the three ortogonal axis crossing at the origin??Victor Gutierrez2017-12-09T11:01:10Zwhy the result of command Plot is empty?
http://community.wolfram.com/groups/-/m/t/1244489
I have run a command of Plot for a solution of an equation. However, the graph is always empty. I don't know what's wrong with my code. Could anyone help me to figure it out?
My code is following:
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=code.jpg&userId=1232269Tim Zhang2017-12-12T23:57:12ZI’m okay with making name tags with Mathematica
http://community.wolfram.com/groups/-/m/t/1244333
*This post was originally published at [Ultimaker][1].*
----------
Pioneer Chris Hanusa led a Mathematica and 3D printing workshop where he shared resources to help attendees get up and running with the program and 3D printing. At the end of the information-rich workshop, attendees learned how to to use Mathematica to create several 3D printable objects, including name tags.
In October, at my invitation, Assistant Professor Chris Hanusa of the Math Department at Queens College led an Introduction to 3D printing with Mathematica workshop for educators at [NYU’s ITP][2] in New York City. Chris is a mathematician and a designer who creates beautiful objects inspired by math (you can see his work on his website [hanusadesign][3]). Chris creates his objects and shares the math behind them on his site. He has also written several tutorials on his [blog mathzorro.com][4] about how to use Mathematica to create 3D objects. There is a great deal to learn about Mathematica before one can start designing printable 3D objects, and during the workshop Chris worked to provide the attendees with enough information to be just a little bit dangerous. Without a question, Mathematica is the kind of application that one needs to see in action, and then spend quite a bit of time with processing the information and doing further exploration on one’s own.
Chris’s teaching style encourages independence. He shows his college students how to rely on Mathematica’s extensive documentation, and he provides well-scaffolded tutorials to follow so that his students develop their understanding and confidence.
[Mathematica][5] is not a CAD package, nor was it created with 3D printing in mind. However, one can use Mathematica’s programing language to create printable 3D objects, basically watertight, mesh files and export them as STLs or OBJs. Like other programming languages (Processing, Openscad, OpenGL) that can create 3D objects with code, you don’t have the ability to drag and drop shapes. Basically, you create statements that generate nodes or vertices in 3D space. By specifying coordinates, you can then apply rotate, scale and translate transformations. You can use parametric curves, vector functions, and trigonometry to create your geometric objects. Remember when you asked in Trig class "When will ever use this?" Well, you’ll use your trig in Mathematica to create 3D printable objects. Math class would have been very different for me if I had access to both Mathematica and 3D printing back when I was in high school.
What I like about Mathematica (and Processing and OpenSCAD) is the algorithmic approach to generating objects. While Processing uses a sketch metaphor and OpenSCAD employs an editing window, Mathematica uses notebooks. For each of these options, programmers start with a general idea of a task for their computers to perform. Programmers then flesh out their general ideas into complete, unambiguous, step-by-step procedures to carry out their tasks. Such procedures are called algorithms. An algorithm is not the same thing as a program. A program is written in some particular programming language, like C, Java, Python, or the Wolfram Language. An algorithm is more like the idea behind the program. An algorithm can be expressed in any language, including English.
When you know what you want your program to do, many programmers find it helpful to write a description of the task or tasks. That description can then be used as an outline for their algorithm. As a programmer refines and elaborates on their description, gradually adding more details, they eventually end up with a complete algorithm that can be translated directly into a programming language. This method is called stepwise refinement, and it is a type of top-down design. As you proceed through the stages of stepwise refinement, you write out descriptions of your algorithm in pseudo-code, the informal instructions that imitate the structure of your program without complete details or the perfect syntax of actual code. Pseudo-code is where you figure out what kinds of data your program needs and what kind of data it returns. This is also the step where you think about the best way to solve the problems that you're going to run into during the project, and to you get to figure out solutions to try before even starting to write code.
Think of programming as a process of logical problem-solving. Your two big challenges are a) learning the syntax, and b) applying your logical problem-solving skills to an unfamiliar domain. When I taught programming at [Saint Ann’s School][6] in Brooklyn, NY, I told my students who were learning a new language to break things down into four areas:
- Code-reading—be able to look at code and figure out what it’s doing. Code-reading means two things:
- Being able to understand what a particular line of code is doing -
understanding the syntax of the program.
- It also means understanding something called the control flow of the program: when the program executes a line of code, what will it execute next?
- Pseudo-code—This is where you do a lot of thinking and not a lot of
writing code. Because most projects start with a vague idea, or an
English description, this step helps turn your project into something
that is approachable as a program. It forces you to define and
explain what you're trying to do very precisely.
- Code-writing—It can be intimidating to try and figure out how to
express what you're trying to do with an unfamiliar syntax of a
programming language. However, if you've done a good job with the
pseudo-code, writing your code should be in some ways the simplest
step. You’re performing a translation from the precise and clear
concepts you've figured out to the syntax of the programming language
in question. As you write the code, you'll figure out some issues
that your original design or pseudo-code didn't address. You'll
improvise, double back, and sometimes change your entire design. But
the more you separate the simple writing of code from the hard work
of figuring out what you want the code to do, the happier you will be
in the long run.
- Debugging—This is the process of testing and fixing the problems in a
program that you've already written. Unfortunately, this is the step
that will generally take most of your time. While occasionally you
will be able to write a program that's bug-free, generally your
program will either not work immediately or it will do something
completely unexpected. Learning techniques for figuring out what's
wrong (and even more important, solving the problem) is important.
The more code you write and the longer your programs become, the
harder problems become to track down and deal with.
Start small, modify, test and build incrementally. When you work in Mathematica, instead of modifying code that works, make a copy and modify the copy. This way you’ll have a record of what you started with that you can always return to at a later date.
Mathematica is also capable of nested commands. But ease into this. Until you know how each command works (what information a command takes and what it returns) you may want to consider separating the commands out. As you become more experienced, nest away with confidence.
During the workshop, Chris pointed out a few things that were helpful to keep in mind:
- Mathematica is case sensitive.
- All built-in Mathematica functions are spelled, capitalized, and
follow CamelCase rules.
- It is important to distinguish between parentheses (), brackets [],
and braces {}: Parentheses (): Used to group mathematical
expressions, such as (3+4)/(5+7). Brackets []: Used when calling
functions, such as N[Pi]. Braces {}: Used when making lists, such as
{i,1,20}.
- To calculate an expression, use Shift-Return.
- To find the options of a given function, highlight it in the notebook
and then press Command+Shift+F.
- A semicolon can be used to suppress output.
- Mathematica has four types of equals: =, ==, :=, and ===.
- Assignment: To define a variable to store it in memory, use =. For example, to define z to be 3, write z=3.
- Test for equality: Use == to check for equality. For example, 1-1==0 will evaluate to True and 1==0 will evaluate to False.
- Set Delay: Use := when you want to evaluate the function when it is called rather than when it is assigned . (This is advanced.)
- SameQ: Use === to test whether two expressions are identically the same.
- Adding comments to your notebook will help you remember what your intentions were when you look back on your notebook months later. Comments are also invaluable for other people who are navigating through your notebook. To write a sentence, create a new text cell by clicking below a cell. When the cursor turns horizontal type Option-7, or right click and navigate to Insert New Cell > Text.
- Use the documentation. If you are having trouble with a certain
function, use the ? command to ask for help. For example enter ?
Table and the output will be a yellow box with a quick synopsis of
the command. For more detailed information, click the blue >> at the
bottom right of this yellow box. This will open the Documentation
Center which gives examples of using the command in action, available
options for this command, and anything else you might want to know
about the command.
The following three statements represent a sphere, a cuboid and a cone:
Sphere[{0, 0, 0}, .28]
Cuboid[{-.05, -.05, .26}, {.05, .05, .35}]
Cone[{{0, 0, 0}, {0, 0, -1}}, .3]
You can also combine them using a list
Graphics3D[{
Sphere[{0, 0, 0}, .28],
Cuboid[{-.05, -.05, .26}, {.05, .05, .35}],
Cone[{{0, 0, 0}, {0, 0, -1}}, .3]
}]
They are combined, but if you press Shift Return, I suspect you may not get what you expect.
In order to see all the objects combined you have to pass these objects from Graphics3D[] to Show[]:
sphere = Graphics3D[Sphere[{0, 0, 0}, .28]]
cuboid = Graphics3D[Cuboid[{-.05, -.05, .26}, {.05, .05, .35}]]
cone = Graphics3D[Cone[{{0, 0, 0}, {0, 0, -1}}, .3]]
Show[sphere, cuboid, cone]
Like other programming languages, there's often more than one way to do do the same thing:
shapes = {
Sphere[{0, 0, 0}, .28],
Cuboid[{-.05, -.05, .26}, {.05, .05, .35}],
Cone[{{0, 0, 0}, {0, 0, -1}}, .3]}
Map[Graphics3D, shapes]
Show[Map[Graphics3D, shapes]]
Graphics3D[Table[Sphere[{i, 0, 0}, .2], {i, 0, 10}]]
To get the workshop attendees started, Chris created a [Mathematica Basics Crash Course][7] and a [3D Graphics in Mathematica][8] notebook.
If you're new to Mathematica, open Chris’s notebooks and execute each command by placing your cursor at the end of the line and pressing Shift+RETURN. Not everything will make sense right away, and that’s okay. Mathematica is packed with information and functionality. At the beginning just try to appreciate what it is doing, and then marvel at what might be possible when you have more experience.
Mathematica has a large number (195) of built-in polyhedra that you can create, export and print. They are accessible using the command PolyhedronData[]. How do I know how many polyhedra Mathematica can represent? Execute the following statement:
Length[PolyhedronData[All]]
To find out the properties associated with PolyheronData[] execute the following command:
PolyhedronData["Properties"]
And here is a handy statement to explore all the polyhedra:
Manipulate[
Column[{PolyhedronData[g], PolyhedronData[g, p]}], {g,
PolyhedronData[All]}, {p,
Complement @@ PolyhedronData /@ {"Properties", "Classes"}}]
Here how to create a 3D object that you can see and then export:
myShape = Graphics3D[PolyhedronData["Icosahedron", "Faces"]]
![enter image description here][9]
Save your notebook. Then to export the object as an STL file :
Export[NotebookDirectory[] <> "myFile.stl", myShape]
And then to see the STL:
Import[NotebookDirectory[] <> "myFile.stl"]
#Back to name tags#
Name tags or nameplates often seem to me to be the Hello World of 3D printing. They are generally pretty simple to create with a CAD package and they provide an easy introduction to 3D space. There is nothing inherently wrong with creating name tags or nameplates, but I think 3D printing is capable of so much more, and I try to advocate for finding the real potential for 3D printing in education. Yet here I am, encouraging you to use Mathematica to create a name tag. Why? Because I think it is helpful to start off with a familiar object in an unfamiliar context. Remember, Mathematica won’t let you click and drag. You are going to have to build a name tag from the ground up, and in the process, you’re going to become familiar with some of Mathematica’s mesh commands.
At it’s simplest, to make a name tag, you’re going to need a base and then a top. Remember that an STL file is a watertight mesh. That means that where the base and the top meet you will need to eliminate the top surface on the base and the bottom surface of the top. Let’s start with some text:
Text[Style["Ultimaker", Bold, FontFamily -> "Futura", FontSize -> 50]]
![enter image description here][10]
You now need to convert this text to a 2D mesh. To do that you use the command DiscretizeGraphics[]:
meshText2d = DiscretizeGraphics[
Text[Style["Ultimaker", Bold, FontFamily -> "Futura",
FontSize -> 50]], _Text]
![enter image description here][11]
To make the 2D mesh 3D use RegionProduct[] with the mesh and a vertical line:
RegionProduct[meshText2d, Line[{{0.}, {5.}}]]
![enter image description here][12]
Next you’ll create a 2D mesh of a polygon to act as the base:
base = DiscretizeGraphics[Graphics[{RegularPolygon[8]}]]
![enter image description here][13]
To see the two meshes together:
Show[{RegionResize[base, 1.3], RegionResize[meshText2d, 1]}]
![enter image description here][14]
Next you need to remove the surfaces where the two meshes intersect (RegionDifference[]) and make the base big enough to support the text (RegionResize[]):
polygon = RegionResize[base, 1.3];
text = RegionResize[meshText2d, 1];
intersection = RegionDifference[polygon, text]
![enter image description here][15]
Now you need to create boundaries from the two regions so that you can create walls:
bdrypolygon = RegionBoundary[polygon]
bdrytext = RegionBoundary[text]
![enter image description here][16]
![enter image description here][17]
Now you need to build the actual mesh. You’ll need to create 3 levels: the floor, the top of the base and the top of the text (You must use a floating point number):
level0 = 0.;
level1 = 0.1;
level2 = 0.15;
Now it’s time to put all the parts together:
Show[{
RegionProduct[polygon, Point[{{level0}}]],
RegionProduct[bdrypolygon, Line[{{level0}, {level1}}]],
RegionProduct[intersection, Point[{{level1}}]],
RegionProduct[bdrytext, Line[{{level1}, {level2}}]],
RegionProduct[text, Point[{{level2}}]]
}]
![enter image description here][18]
Export and Import. You can use the % as shorthand for the last thing you created:
Export[NotebookDirectory[] <> "nametag.stl", %]
Import[NotebookDirectory[] <> "nametag.stl"]
![enter image description here][19]
If the export doesn’t work, it could be that your notebook hasn’t been saved yet. Save the notebook, then export and import.
But what if you want to use a logo instead of text? No problem. Start with an image, convert it to a 2D mesh, resize it, convert to 3D, create a base, eliminate the surface where the meshes intersect, create boundaries, establish level values, and then put them all together.
Find a black and white image online, copy it, and then create a variable to hold it. Use the semicolon to suppress the output:
![enter image description here][20]
To convert a bitmap to a mesh first negate the color then use ImageMesh[] instead of DiscretizeGraphics[]:
catMesh=ImageMesh[ColorNegate[cat]]
![enter image description here][21]
Next, you need to scale the image:
scaledCat = RegionResize[catMesh, {{-.8, .8}, {-.6, .6}}]
![enter image description here][22]
Lets use a disk for the base. You’ll need to convert it to a mesh and make it slightly larger than 1 unit. (Remember you just scaled your image to be slightly smaller than the unit length:
base = DiscretizeGraphics[Graphics[{Disk[{0, 0}, 1.1]}]]
![enter image description here][23]
Let’s make a hole in the base:
hole = DiscretizeGraphics[Graphics[{Disk[{0, .9}, .1]}]]
To make sure everything fits:
Show[{base, hole, scaledCat}, PlotRange -> All]
![enter image description here][24]
Let’s first make the hole in the base:
base = RegionDifference[base, hole]
![enter image description here][25]
Now find the intersection:
intersection=RegionDifference[base, scaledCat]
![enter image description here][26]
Now you need to get the boundary of the 2D mesh:
bdryCat = RegionBoundary[scaledCat]
bdryBase = RegionBoundary[base]
![enter image description here][27]
![enter image description here][28]
Create the levels:
level0 = 0.;
level1 = 0.15;
level2 = 0.25;
And now to put it all together:
Show[{
RegionProduct[base, Point[{{level0}}]],
RegionProduct[bdryBase, Line[{{level0}, {level1}}]],
RegionProduct[intersection, Point[{{level1}}]],
RegionProduct[bdryCat, Line[{{level1}, {level2}}]],
RegionProduct[scaledCat, Point[{{level2}}]]
}]
![enter image description here][29]
Export and print!
There you have it: a name tag in Mathematica. Not only did you get to learn a little about Mathematica, but you also got to see how meshes from two shapes are constructed. Where does Mathematica and 3D printing fit in the curriculum? Math class is an obvious answer, but it’s also well suited for a programming class, and with access to computers, patience and time, why not bring Mathematica and 3D printing to the art studio?
Here’s a challenge: Try [Mathematica][30] for 15 days and see what you can do with it. Upload your 3D models to [Youmagine][31] and tag them #MathematicaAnd3DPrinting.
[1]: https://ultimaker.com/en/blog/51553-im-okay-with-making-name-tags-with-mathematica
[2]: https://tisch.nyu.edu/itp
[3]: http://hanusadesign.com/
[4]: http://blog.mathzorro.com/
[5]: https://www.wolfram.com/mathematica/
[6]: http://saintannsny.org/
[7]: https://qcpages.qc.cuny.edu/~chanusa/mathematica/Basics.nb
[8]: https://qcpages.qc.cuny.edu/~chanusa/mathematica/GraphicsObjects.nb
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=2084polyhedra.png&userId=20103
[10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=text.png&userId=20103
[11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=01_mathematica_text.png&userId=20103
[12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=02_mathematica_3D.png&userId=20103
[13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=312203_polygon.png&userId=20103
[14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=713504_base_text_together.png&userId=20103
[15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=672905_intersection.png&userId=20103
[16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=326906_boundary_base.png&userId=20103
[17]: http://community.wolfram.com//c/portal/getImageAttachment?filename=943207_boundary_text.png&userId=20103
[18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=08_mesh.png&userId=20103
[19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=09_stl.png&userId=20103
[20]: http://community.wolfram.com//c/portal/getImageAttachment?filename=10_cat.png&userId=20103
[21]: http://community.wolfram.com//c/portal/getImageAttachment?filename=11_remove_color.png&userId=20103
[22]: http://community.wolfram.com//c/portal/getImageAttachment?filename=12_resize.png&userId=20103
[23]: http://community.wolfram.com//c/portal/getImageAttachment?filename=488713_base.png&userId=20103
[24]: http://community.wolfram.com//c/portal/getImageAttachment?filename=14_show.png&userId=20103
[25]: http://community.wolfram.com//c/portal/getImageAttachment?filename=719215_hole.png&userId=20103
[26]: http://community.wolfram.com//c/portal/getImageAttachment?filename=16_intersection.png&userId=20103
[27]: http://community.wolfram.com//c/portal/getImageAttachment?filename=735417_boundary_cat.png&userId=20103
[28]: http://community.wolfram.com//c/portal/getImageAttachment?filename=668918_boundary_base.png&userId=20103
[29]: http://community.wolfram.com//c/portal/getImageAttachment?filename=19_mesh.png&userId=20103
[30]: https://www.wolfram.com/mathematica/trial/
[31]: http://youmagine.com/Lizabeth Arum2017-12-12T18:51:20Zios App - Differential Equations
http://community.wolfram.com/groups/-/m/t/1244443
Does anyone know if the ios app can solve differential equations with steps?Jordan S2017-12-12T22:09:42ZImageAugmentationLayer usage
http://community.wolfram.com/groups/-/m/t/1243036
This code fails with "NetTrain::interr: An internal error occurred. Please contact Wolfram Research. " Any ideas?
lnet = NetChain[
{
ImageAugmentationLayer[{115, 115},
"ReflectionProbabilities" -> {0.5, 0.5}],
LinearLayer[1788],
LogisticSigmoid,
LinearLayer[1788],
2,
SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", {1, 2}}],
"Input" -> NetEncoder[{"Image", {125, 125}}]
] ;
tSet = Table[
RandomChoice[{RegionImage[Annulus[], RasterSize -> 125] -> "A",
RegionImage[Circle[], RasterSize -> 125] -> "C"}], 10]
NetTrain[lnet, tSet]Jeff Burns2017-12-11T21:10:40ZFind intersection points of lines using ListPlot?
http://community.wolfram.com/groups/-/m/t/1242003
Hello, I am trying to find the intersection points of the two horizontal solid lined with the dashed line. I would like to label each point as for example point a and the second point as b. I would also like to display the value of the intersecting point. Note that I am aiming to find the x value of the intersecting point since I know y. I find it easier with function and using Plot function. I tried with this one but it didn't work.
Thank you
list1 = {0, 1};
list2 = {0, 5};
ListLinePlot[Transpose[{list1, list2}], PlotStyle -> {Thick, Dashed},
PlotRange -> {{0, 5}, {0, 5}},
GridLines -> {None, {{2, {Black, Thick}}, {4, {Green, Thick}}}}]Joeseph A2017-12-08T18:27:16ZProblem: Light transport through biological tissue
http://community.wolfram.com/groups/-/m/t/1241248
I'm new to Mathematica and while it seems like there should be a way to do this (it is effectively simultaneous equations) I don't know how to input it to Mathematica. I've tried using solve and setting it in a table first but it seems I'm not realizing something or missing something in the documentation about how to play with a few.
The problem represents light passing through tissue. There are two variables in the equation that I need to know, a and b. (if there is a method to input equations/code here can someone point it out to me?)
![enter image description here][1]
I(lam), I0(lam) are measured values. I will know these, they are the intensity of the light coming out and going into the volume at wavelength lambda. M(lam) is the absorption of tissue at the wavelength lamda, this I will also know at all lambdas.
d thickness of the tissue, this is a set value.
a and b are what I would like to know. That term represents the light scattering function for the tissue.
What I would like mathematica to do is tell me how many lambda's, or colors of light, do I have to measure at to find what a and b are, and the equation that gives me a and b.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=KsqisKw.png&userId=20103Alan Riordan2017-12-07T12:03:56ZGet solutions to the gauged GL vortices in (1+1) dimensions?
http://community.wolfram.com/groups/-/m/t/1240500
I am trying to numerically solve the following differential equations for the profiles of the Gauged GL Vortices:
eqn1 = y''[x] + y'[x]/x - ((k - z[x])^2* y[x])/x^2 + ((1 - y[x]^2)*y[x])/2 == 0;
eqn2 = z''[x] - z'[x]/x + (k - z[x])*y[x]^2 == 0;
with the boundary conditions:
inf = 1000;
bc = {y[0] == 0, y[inf] == 1, z[0] == 0, z[inf] == 1};
I have tried a finite difference method but this seems to give large errors even for k = 1 so I am wondering if there is a better numerical method to yield a more accurate solution?
Below is my current function which I employ to solve these coupled differential equations:
Clear[fdd, pdetoode, tooderule, sollst]
fdd[{}, grid_, value_, order_] := value;
fdd[a__] := NDSolve`FiniteDifferenceDerivative@a;
pdetoode[funcvalue_List, rest__] :=
pdetoode[(Alternatives @@ Head /@ funcvalue) @@ funcvalue[[1]],
rest];
pdetoode[{func__}[var__], rest__] :=
pdetoode[Alternatives[func][var], rest];
pdetoode[rest__, grid_?VectorQ, o_Integer] :=
pdetoode[rest, {grid}, o];
pdetoode[func_[var__], time_, {grid : {__} ..}, o_Integer] :=
With[{pos = Position[{var}, time][[1, 1]]},
With[{bound = #[[{1, -1}]] & /@ {grid},
pat = Repeated[_, {pos - 1}],
spacevar = Alternatives @@ Delete[{var}, pos]},
With[{coordtoindex =
Function[coord,
MapThread[
Piecewise[{{1, # === #2[[1]]}, {-1, # === #2[[-1]]}},
All] &, {coord, bound}]]},
tooderule@
Flatten@{((u : func) |
Derivative[dx1 : pat, dt_, dx2___][(u : func)])[x1 : pat,
t_, x2___] :> (Sow@coordtoindex@{x1, x2};
fdd[{dx1, dx2}, {grid},
Outer[Derivative[dt][u@##]@t &, grid],
"DifferenceOrder" -> o]),
inde : spacevar :>
With[{i = Position[spacevar, inde][[1, 1]]},
Outer[Slot@i &, grid]]}]]];
tooderule[rule_][pde_List] := tooderule[rule] /@ pde;
tooderule[rule_]@Equal[a_, b_] :=
Equal[tooderule[rule][a - b], 0] //.
eqn : HoldPattern@Equal[_, _] :> Thread@eqn;
tooderule[rule_][expr_] := #[[Sequence @@ #2[[1, 1]]]] & @@
Reap[expr /. rule]
Clear@pdetoae;
pdetoae[funcvalue_List, rest__] :=
pdetoae[(Alternatives @@ Head /@ funcvalue) @@ funcvalue[[1]], rest];
pdetoae[{func__}[var__], rest__] :=
pdetoae[Alternatives[func][var], rest];
pdetoae[func_[var__], rest__] :=
Module[{t},
Function[pde, #[
pde /. {Derivative[d__][u : func][inde__] :>
Derivative[d, 0][u][inde, t], (u : func)[inde__] :>
u[inde, t]}] /. (u : func)[i__][t] :> u[i]] &@
pdetoode[func[var, t], t, rest]]Benjamin Leather2017-12-06T11:13:47ZGetting data from an analog-to-digital converter
http://community.wolfram.com/groups/-/m/t/1241573
I am using the Grove microphone and the Grove analog-to-digital converter to sample sound. The Grove platform documentation provides the following example C code to read data from the ADC that I am trying to port to Mathematica:
#include <Wire.h>
#define ADDR_ADC121 0x55
#define V_REF 3.00
#define REG_ADDR_RESULT 0x00
#define REG_ADDR_ALERT 0x01
#define REG_ADDR_CONFIG 0x02
#define REG_ADDR_LIMITL 0x03
#define REG_ADDR_LIMITH 0x04
#define REG_ADDR_HYST 0x05
#define REG_ADDR_CONVL 0x06
#define REG_ADDR_CONVH 0x07
unsigned int getData;
float analogVal=0; // convert
void init_adc()
{
Wire.beginTransmission(ADDR_ADC121); // transmit to device
Wire.write(REG_ADDR_CONFIG); // Configuration Register
Wire.write(0x20);
Wire.endTransmission();
}
void read_adc() //unsigned int *data
{
Wire.beginTransmission(ADDR_ADC121); // transmit to device
Wire.write(REG_ADDR_RESULT); // get result
Wire.endTransmission();
Wire.requestFrom(ADDR_ADC121, 2); // request 2byte from device
delay(1);
if(Wire.available()<=2)
{
getData = (Wire.read()&0x0f)<<8;
getData |= Wire.read();
}
Serial.print("getData:");
Serial.println(getData);
delay(5);
Serial.print("The analog value is:");
Serial.print(getData*V_REF*2/4096);
Serial.println("V");
}
The code writes 0x20 to 'register 2'. After some trial and error I found out that the Mathematica equivalent seems to be:
DeviceWrite[i2c, {0,0,32}]
because after that I can read data continuously using:
d = DeviceRead[i2c, 2]; n = d[[1]] * 256 + d[[2]]
Is this the way to set 'registers' on an ADC? Also, what does setting it achieve? The Grove documentation is rather vague on this point.
Thanks,
GijsbertGijsbert Wiesenekker2017-12-08T14:29:04ZBSplineFunction not evaluating as expected in RevolutionPlot3D?
http://community.wolfram.com/groups/-/m/t/1242827
Hello,
Why does the code (shown below) give this error?
> Dot::rect: Nonrectangular tensor encountered.
And how might this code be modified to produce the desired plot?
controlPoints = {{0., 1.48195}, {0.151384, 1.49651}, {0.330883, 1.39382}, {0.488076, 1.2461}, {0.575162, 1.06331}, {0.599079, 0.886118}, {0.547864,
0.698224}, {0.46997, 0.542705}, {0.386957, 0.404801}, {0.285357, 0.28673}, {0.314028, -0.0307762}, {0.202299, -0.0181826}, {0., 0.}};
RevolutionPlot3D[BSplineFunction[controlPoints][t], {t, 0, 1}]Rian Shams2017-12-11T04:51:43ZAvoid error in the DeviceConfigure?
http://community.wolfram.com/groups/-/m/t/1242965
Hi, I am trying to connect an Arduino UNO R3 to a Raspberry Pi and do the blink of the led. The device is connected but when I try to configure the sketche I receive the error messages and I coud not figure out where it is the error. Please help me, Juan
DeviceConfigure[ard, "Upload" -> {Initialization -> "int val = 0;", "Functions" -> <|
"BlinkInvert" -> <|"Code" -> "void blink() {pinMode(13,OUTPUT); digitalWrite(13,val); val \
= !val;}"|>, "BlinkArgument" -> <|"Code" -> "void blink(int pin, int val) {pinMode(pin,OUTPUT); \
digitalWrite(pin,val);}"|>|>}]
KeyExistsQ::invrl: The argument void blink() {pinMode(PIN,OUTPUT); digitalWrite(PIN,val); val = !val;} is not a valid Association or a list of rules.
KeyExistsQ::invrl: The argument void blink(int PIN, int val) {pinMode(PIN,OUTPUT); digitalWrite(PIN,val);} is not a valid Association or a list of rules.
StringJoin::string: String expected at position 1 in void blink() {pinMode(PIN,OUTPUT); digitalWrite(PIN,val); val = !val;}[Code]<>
<>void blink(int PIN, int val) {pinMode(PIN,OUTPUT); digitalWrite(PIN,val);}[Code]
StringJoin::string: String expected at position 3 in void blink() {pinMode(PIN,OUTPUT); digitalWrite(PIN,val); val = !val;}[Code]<><>void blink(int PIN, int val) {pinMode(PIN,OUTPUT); digitalWrite(PIN,val);}[Code]Juan Fuentes2017-12-11T17:40:48Z[✓] Refresh or clear cached CloudObjects[]?
http://community.wolfram.com/groups/-/m/t/1242497
[*cross posted on mathematica.stackexchange.com*](https://mathematica.stackexchange.com/q/161661/5478)
Let's create an API which creates one file each time it is called/accessed:
obj = CloudDeploy[
APIFunction[{}
, Put[$RequesterWolframID
, "testFiles/" <> DateString["ISODateTime"] <> ".txt"
] &
]
, "apiTest"
, Permissions -> "Public"
];
CloudEvaluate@CreateDirectory@"testFiles/";
and let's call it:
URLRead[obj]
CloudObjects["testFiles/"]
URLRead[obj]
CloudObjects["testFiles/"]
[![enter image description here][1]][1]
But this is not true, if you visit a browser interface they will be there:
[![enter image description here][2]][2]
In fact, once you visit it, `CloudObjects` cache changes, but only once:
URLRead[obj]
CloudObjects["testFiles/"]
URLRead[obj]
CloudObjects["testFiles/"]
[![enter image description here][3]][3]
So how to make sure `CloudObjects` returns up to date result?
I am fine with an additional step to flush the cache, I just want it to be possible programmatically.
[1]: https://i.stack.imgur.com/jBXTj.png
[2]: https://i.stack.imgur.com/5WLAs.png
[3]: https://i.stack.imgur.com/9zzA7.pngKuba Podkalicki2017-12-10T13:57:17Z[✓] Solve a system of two rather complicated power equations?
http://community.wolfram.com/groups/-/m/t/1242863
Hi
I am not a Mathematica user, I am just looking for a math package that can solve my problem.
I need to solve a system of two rather complicated power equations, like those in the image below. Here x and z are the unknown variables, all other constants are known. Can Mathematica do that?
But actually I need even more. I will have a set of values for the known constants I and D (A and a are fixed). So I will need not just one solution but a set of solutions for each pair of (I, D). So, if I feed the set of (I,D) pairs into Mathematica, can it produce a set of solutions for me, not just one solution?
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Untitled.png&userId=1242847Lev Dorosinskiy2017-12-11T11:39:37ZAvoid Time Limit Exceeded error in CloudCDF ?
http://community.wolfram.com/groups/-/m/t/1243126
We developed a CloudCDF that gets log events from a Data Drop bin, builds statistical charts and presents them. While the web output has always been on the slower side we proceeded to load historical data with JUN-AUG sitting around 5,000 events / 431kB. When refreshing the CloudCDF to review the results we're now getting the following error with no CDF being displayed...
> {"errorCode": "TimeLimitExceeded", "errorDetails": "1 minute" }
Anyone know what's causing this and how to fix it?Randy Schultz2017-12-11T15:28:18ZMachine learning benchmarking toolkit
http://community.wolfram.com/groups/-/m/t/1242563
Since Wolfram is investing in Machine learning (as I understand using MXNet) and using this nice Wolfram technology
might result in some ML production projects with or without Wolfram technology as a follow-up, a decision must be made on what
hardware infra to choose.
Hewlett Packard created a project (by the HPE Labs) on github that can be used to test several setups.
> Deep Learning Benchmarking Suite Deep Learning Benchmarking Suite
> (DLBS) is a set of command line tools for providing consistent and
> reproducible benchmark experiments on various hardware/software
> combinations. In particular, DLBS provides the following
> functionality:
>
> Implements internally various deep models. Our goal is to provide same
> model implementations for all supported frameworks. Deep models that
> are supported include various VGGs, ResNets, AlexNet and GoogleNet
> models. Benchmarks single node multi GPU configurations. Frameworks
> that are now supported: BVLC Caffe, NVIDIA Caffe, Intel Caffe, Caffe2,
> TensorFlow, MXNet and TensorRT. Supports inference and training
> phases. Can use real data if dataset is available. Else, falls back to
> synthetic data. Supports bare metal and docker environments.
If you think it's useful you can read more on:
[https://github.com/HewlettPackard/dlcookbook-dlbs][1]
[1]: https://github.com/HewlettPackard/dlcookbook-dlbsl van Veen2017-12-11T09:34:16Z[GIF] Lean In
http://community.wolfram.com/groups/-/m/t/1242836
![Spheres in projective space][1]
_Lean In_
A similar idea to [_Fall Out_][2], one dimension up. Now I have a 2-sphere in the 3-sphere which I map to 3-space by extending the line containing a point until it intersects the $w=1$ hyperplane, then inverting in the unit sphere and reflecting through the origin.
The underlying object is just the standard equatorial 2-sphere $(x,y,z,0)$ with $x^2+y^2+z^2=1$, which then gets rotated by $\pi/4$ in the plane spanned by $\cos s (0,0,1,0) + \sin s (1,0,0,0)$ and $(0,0,0,1)$ as $s$ varies from $0$ to $2\pi$.
Here's the code:
inversion[p_] := p/Norm[p]^2;
With[{n = 50, m = 31, d = .01,
cols = Darker[RGBColor[#]] & /@ {"#43DDE6", "#FC5185", "#364F6B"}},
Manipulate[
Graphics3D[
{Sphere[#, .02] & /@
Flatten[
Table[
i * inversion[#1[[1 ;; -2]]/#1[[-1]]] &[
RotationMatrix[π/4, {Cos[s] {0, 0, 1, 0} + Sin[s] {1, 0, 0, 0}, {0, 0, 0, 1}}]
.{Sqrt[1 - z^2] Cos[θ], Sqrt[1 - z^2] Sin[θ], z, 0}],
{i, {-1, 1}}, {θ, 0., 2 π - 2 π/n,
2 π/n}, {z, -1., 1, 2/m}], 2]},
PlotRange -> 1.2, Boxed -> False, ViewPoint -> {0, 5, 0},
ImageSize -> 540, Background -> cols[[-1]],
Lighting -> {{"Point", cols[[1]], 1/2 {Sin[s], 0, Cos[s]}},
{"Point", cols[[2]], 1/2 {-Sin[s], 0, -Cos[s]}}, {"Ambient", cols[[-1]], {0, 5, 0}}}],
{s, 0, 2 π}]
]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=projective5gc.gif&userId=610054
[2]: http://community.wolfram.com/groups/-/m/t/1239487Clayton Shonkwiler2017-12-11T05:12:17ZEdge detect code gives different outputs
http://community.wolfram.com/groups/-/m/t/1242353
I have often noticed that examples of the past when done in newer versions of Mathematica generate inconsistent results. A prime example related to the following post (Character edge finding):
pic = Thinning@Binarize[GradientFilter[Rasterize[Style["\[Euro]",
FontFamily -> "Times"], ImageSize -> 200] // Image, 1]];
pdata = Position[ImageData[pic], 1];
lcp = ListCurvePathPlot[pdata];
This simple piece of code gives different results in Mathematica 9.0, 10.4 and 11.2 with default options. I have posted the results on StackExchange
(click the [link][1] to see).
Note: this is not the only example where I have seen differences.
**To the WRI quality assurance department**:
Can you kindly check why similar functions do not behave the same across different versions ?? I think it is more crucial to establish whether
the built-in functions are working properly rather than releasing more and more functions without appropriate checks.
[1]: https://mathematica.stackexchange.com/questions/161667Ali Hashmi2017-12-09T19:32:04Z[✓] Use a delayed rule to substitute a multi-variable derivative?
http://community.wolfram.com/groups/-/m/t/1242466
I was using a delayed rule to substitute a multi-variable derivative, but syntax error encountered in my second input as the following and the attachments. I am a Newbie. Is there anyone who would like to tell me what's wrong and how to fix it? Thanks a lot!
kc1 = -\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(\[Eta][x, t]\)\) - U1 \!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\(\[Eta][x, t]\)\) + \!\(
\*SubscriptBox[\(\[PartialD]\), \(y\)]\(
\(\*SubscriptBox[\(\[Phi]\), \(1\)]\)[x, y, t]\)\)
temp1 = kc1 /. {(\[Eta]^(a1_, a2_))[x, t] :> \!\(
\*SubscriptBox[\(\[PartialD]\), \({x, a1}, {t, a2}\)]\((
\*OverscriptBox[\(\[Eta]\), \(^\)] Exp[I\ k \((x - ct)\)])\)\)}Leshan Fisher2017-12-10T01:22:36ZDistributionSmoothing option in Classify with NearestNeighbors Method
http://community.wolfram.com/groups/-/m/t/1241866
I had a need/desire to figure out how the DistributionSmoothing option in Classify really worked when the Method used was NearestNeighbors. After some poking around, I believe I figured it out. Here's conceptually what it does; I suspect it uses code that is several orders of magnitude more efficient. My code is more explanatory purposes only.
Get a list of the classes -- the right answers -- of the training set. Create another "augmentation list" that has one member of each possible class in the training set. Put these two lists together and find their distribution. Call this the "augmented global distribution."
Now get the distribution of the decisions your classifier makes about the neighbors. Call this the "local distribution."
Form a mixture distribution of the local distribution and the augmented global distribution. The weights on the distribution are 1 for the local distribution and s/n for the augmented global distribution where s is the distribution smoothing parameter and n is the number of neighbors you are using.
The idea is that as the distribution smoothing parameter gets bigger, the particular distribution of neighbors in the locality matters less and less and the global distribution matters more. I assume one augments the list to avoid problems (maybe division by zero?) that might occur if the global list had just one class in it.
Here's a simple example.
data = {1 -> True, 2 -> True, 3 -> True, 4 -> False, 5 -> True,
6 -> True, 7 -> False, 8 -> False, 9 -> True};
Now form the augmented distribution and create the augmentedGlobalDistribution using EmpiricalDistribution
augmentedList = Join[Last /@ data, {True, False}]
augmentedGlobalDistribution=EmpiricalDistribution[augmentedList]
Form the local distribution. I'll arbitrarily select person 5 as the individual of interest.
subject=5;
neighbors=3;
nf=Nearest[data];
localDistribution = EmpiricalDistribution[nf[subject, neighbors]]
Now let's form the mixture distribution of the augmented global distribution and the local distribution. I do so by creating a function in which the argument ds represents the data smoothing parameter.
predictedProbability[ds_] :=
MixtureDistribution[{1, ds/neighbors}, {localDistribution,
augmentedGlobalDistribution}]
We now use that to predict the probability that our subject (person 5) will be True when I use distribution smoothing parameters of 0, 1, 2 and 4.
Map[PDF[predictedProbability[#],2]&,{0,1,2,4}]
The answer is
{0.666667, 0.659091, 0.654545, 0.649351}
Now we see what happens when we use Classify with the same distribution smoothing parameters
Map[Classify[data,
Method -> {"NearestNeighbors", "NeighborsNumber" -> neighbors,
"DistributionSmoothing" -> #},
TrainingProgressReporting -> None][subject, "Probabilities"][
True] &, {0, 1, 2, 4}]
We get the same answers! So, is this proof that I have successfully reverse engineered the DistributionSmoothing option? No. But am I confident in my work? Yes. The algorithm makes sense.Seth Chandler2017-12-09T18:56:33Z[✓] One simple equation gets answer, similar one does not?
http://community.wolfram.com/groups/-/m/t/1241519
In Mathematica 11.2, when I try
Solve[{x + y == 12, y == 2 x}, {x}]
I get
{{x -> 4}}
Looks good. But, if I do
Solve[{x + y == 25, y == 4 x}, {x}]
I get
{{ }}
?Anthony Torrero Collins2017-12-08T05:04:11ZPack NonConvex Curve Into An Ellipse
http://community.wolfram.com/groups/-/m/t/1242150
Set Up Functions Describing Ellipse and Cassini Oval
rule to translate and rotate coordinates
rottransrl[{xc_, yc_, \[Theta]_}, {x_, y_}] =
Thread[{x, y} -> RotationMatrix[-\[Theta]].{x - xc, y - yc}];
function describing an ellipse with axes {a,b}, center {xc,yc} and orientation \[Theta]
ell[{a_, b_}, {xc_, yc_, \[Theta]_}] = (x/a)^2 + (y/b)^2 - 1 /.
rottransrl[{xc, yc, \[Theta]}, {x, y}];
function describing a Cassini oval with axes {a,b}, center {xc,yc} and orientation \[Theta]
oval[{a_, b_}, {xc_, yc_, \[Theta]_}] = ((x - a)^2 + y^2) ((x + a)^2 + y^2) -
b^4 /. rottransrl[{xc, yc, \[Theta]}, {x, y}];
Generate Regions for Elllipse and Cassini Oval
ellipse region with axes {a,b}, center {xc,yc} and orientation \[Theta]
el = ImplicitRegion[ell[{a, b}, {xc, yc, \[Theta]}] <= 0, {x, y}];
Cassini oval region with axes {1,5/4}, centered at {1/7,0} and rotated by \[Pi]/10
ov = ImplicitRegion[oval[{1, 5/4}, {1/7, 0, \[Pi]/10}] <= 0, {x, y}];
Attempt to find smallest area ellipse with oval contained in it, Using RegionWithin and NMinimze
TimeConstrained[
sln = NMinimize[{a*b, RegionWithin[el, ov], a >= 0, b >= 0}, {a, b, xc,
yc, \[Theta]}, Method -> {"NelderMead", "PostProcess" -> False}], 360]
$Aborted
Reformulate Problem Using Lagrange Multipliers
function to generate Lagrange multiplier equations for finding extreme values for function describing curve1 for points on curve2.
curveWithinLagMults[curve1_, curve2_, vars_List] :=
Join[Thread[D[curve1 == \[Lambda]*curve2, {vars}]], {curve2 == 0,
curve1 == r}]
use NSolve to find the solutions to the Lagrange multiplier equations
curveWithinNSolve[curve1_, curve2_, vars_List] :=
NSolve[curveWithinLagMults[curve1, curve2, vars], Join[vars, {\[Lambda], r}],
Reals]
function to find the maximum value of ellipse function for points on the Cassini oval
f[a_?NumericQ, b_?NumericQ, xc_?NumericQ, yc_?NumericQ, \[Theta]_?NumericQ] :=
Max[r /. curveWithinNSolve[ell[{a, b}, {xc, yc, \[Theta]}],
oval[{1, 5/4}, {1/7, 0, \[Pi]/10}], {x, y}]]
find the minimum area ellipse containing the Cassini oval
AbsoluteTiming[
sln = NMinimize[{a*b, f[a, b, xc, yc, \[Theta]] <= 0, a >= 0, b >= 0}, {a, b,
xc, yc, \[Theta]}, Method -> {"NelderMead", "PostProcess" -> False}]]
NMinimize::incst: NMinimize was unable to generate any initial points satisfying the inequality constraints {f[a,b,xc,yc,\[Theta]]<=0}. The initial region specified may not contain any feasible points. Changing the initial region or specifying explicit initial points may provide a better solution.
NMinimize::nosat: Obtained solution does not satisfy the following constraints within Tolerance -> 0.001`: {f[a,b,xc,yc,\[Theta]]<=0}.
{95.9544, {1.61441, {a -> 1.62478, b -> 0.993618, xc -> 0.145382,
yc -> -0.000172813, \[Theta] -> 0.305791}}}
plot the result
p = ContourPlot[{oval[{1, 5/4}, {1/7, 0, \[Pi]/10}] ==
0, (ell[{a, b}, {xc, yc, \[Theta]}] /. sln[[2]]) == 0}, {x, -2,
2}, {y, -2, 2}, ImageSize -> Small];
find the extremum points
pts = curveWithinNSolve[(ell[{a, b}, {xc, yc, \[Theta]}] /. sln[[2]]),
oval[{1, 5/4}, {1/7, 0, \[Pi]/10}], {x, y}]
{{x -> -1.34479, y -> 0.0336357, \[Lambda] -> 0.155498,
r -> -0.0117827}, {x -> 1.63088, y -> -0.0328177, \[Lambda] -> 0.154844,
r -> -0.0186086}, {x -> -0.0933478, y -> 0.711853, \[Lambda] -> 0.324496,
r -> -0.428871}, {x -> 1.6821, y -> 0.433738, \[Lambda] -> 0.121384,
r -> -0.0326298}, {x -> -1.39363, y -> -0.445365, \[Lambda] -> 0.121615,
r -> -0.0267585}, {x -> 0.38161, y -> -0.711032, \[Lambda] -> 0.323676,
r -> -0.431725}, {x -> -1.01925, y -> -0.913277, \[Lambda] -> 0.161002,
r -> 0.00116534}, {x -> 1.29604, y -> 0.91782, \[Lambda] -> 0.162165,
r -> -0.00179309}}
show the result with the extremum points
Show[p, Graphics @ Point[{x, y} /. pts]]
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=cassini_oval_in_ellipse.jpg&userId=29126Frank Kampas2017-12-09T15:51:13ZOptimize Get["..."] and RAM usage?
http://community.wolfram.com/groups/-/m/t/1242224
Hello everybody,
I have a little issue with my RAM during a Do loop. Within this do loop I use Get to open a file and thereafter to manipulate it. The memory used is increased by 120 every time the loop runs. This is not much but since I run the loop for several thousand times this small value accumulates. I could pin it down to the Get function and I have created a minimal example (see below) with all RAM tricks that I know of (although I assume that some of them are - in this case - not even necessary). Does anybody know what to do?
Unprotect[Out];
Unprotect[In];
$HistoryLength = 0;
Do[
Get[stringValueOfTheFile];
ClearSystemCache[];
Clear[In];
Clear[Out];
Print[MemoryInUse[]];
, {i, 1, 100}];
Thanks in advance
MarkusMarkus Thürmann2017-12-09T12:27:50Z[✓] Plot for numerical integration?
http://community.wolfram.com/groups/-/m/t/1240835
How can I plot a graph and interval table for the following function?
NIntegrate[0.00159155/(x^2 + 0.000025^2), {x, -10, 10, 0.2}, Method ->
{"MultiPanelRule", Method -> {"TrapezoidalRule", "Points" -> 2, "RombergQuadrature" -> False},
"Panels" -> 50}, MaxRecursion -> 0] // QuietMujtaba Mozumder2017-12-06T13:19:59Z[✓] Perform a specific substitution in an expression?
http://community.wolfram.com/groups/-/m/t/1240800
I was trying to substitute the "strain" in an expression with "displacement", and hopes to make it as general as possible in any dimensions. The relationship between the two is:
> e(i,j)=(du(i)/dx(j)+du(j)/dx(i))/2
where e(i,j) and u(i) are function of coordinates.
So I first created two lists, coor={x,y,z} and list={#1,#2,#3}, which are special case for 3D. This two lists can be generated by other function so it can be generalized to other dimensions.
Then, I try to substitute e(i,j) in some test expressions, like this one:
D[e[1,2][x, y, z], y]
But I don't know how to perform such a substitution, I have tried:
D[e[1,2][x, y, z], y] /.
e[i_ , j_] :> ((D[Evaluate[u[i] @@ list], coor[[j]]] +
D[Evaluate[u[j] @@ list], coor[[i]]])/2 &)
which doesn't work. But something like:
D[e[1,2][x, y, z], y] /. e[i_ , j_] :> (Evaluate[u[i] @@ list] &)
works fine. This is not what I want, though. I want to substitute the e(i,j) with derivative of u(i) instead. How can I achieve this?
Thanks in advance!
Edit: fix a mistake in the test expression.Ox Clouding2017-12-07T15:22:52ZBug with Block & Lookup: Scope Variable Leak.
http://community.wolfram.com/groups/-/m/t/1241974
After debugging a large chunk of code, I could identify this [MWE](https://en.wikipedia.org/wiki/Minimal_Working_Example).
ClearAll@test
test[var_String]:= Block[{association},
association = <|"x"-> <|"key01"-> "ok"|>|>[var];
Lookup[association,"key01",{}]
]
If I evaluate:
test["x"]
test["y"]
test["x"]
I get an error evaluating the last `test["x"]`. What is very strange, I expected to find an error just in the evaluation of `test["y"]`.
The same error does not occur if we change from Block to Module. In the Block case, we have some sort of unexpected scope leak.
Looks like a bug in `Lookup`.
Tested in Mathematica version 11.3
[Cross post](https://mathematica.stackexchange.com/questions/161616) in Stack ExchangeRodrigo Murta2017-12-08T21:32:33ZAvoid subsequent calculations to cause lost of prior calculations in nb?
http://community.wolfram.com/groups/-/m/t/1241366
It seems that the only way that I can calculate the attached notebook is by first going into "Evaluate" and then selecting "Quit Kernel" then selecting "Local" and finally press the "Enter" key on my number pad. If I later press the "Enter" key on my number pad, while in the notebook, I loose my evaluations and then need to through the "Evaluate" and then selecting "Quit Kernel" procedure again.
It appears that the first top down calculation works fine, but any additional calculations really seems to mess the notebook up. Additionally, I am getting a "Set::write: Tag Function in (0&)[0.000263158] is Protected" message as well.
Could someone please tell me what I am doing wrong.
Thanks,Mitchell Sandlin2017-12-07T19:14:34Z[✓] Simplest method for computing cross correlation?
http://community.wolfram.com/groups/-/m/t/1241550
I have two lists, x and y, of equal length, Nx, and I wish to construct the cross-correlation of the two. To compute the autocorrelation of just x (or y) I simply used
Rxx = CorrelationFunction[x, {Nx - 1}]
For the cross-correlation, I first attempted to construct a function using the following:
Rxy[n_] = Sum[x[[m]]*y[[m + n]], {m, 1, Nx - n}],
where n denotes the prescribed lag. This resulted in an error message "The expression m cannot be used as a part specification."
I'm not sure as to what this error means. Also, is there a simple way to use the ListConvolve function to create the desired cross-correlation? (I'm a bit confused by the description at http://reference.wolfram.com/language/ref/ListConvolve.html)Paul Fishback2017-12-08T11:32:06ZExport a PNG file with ColorMap and RawData?
http://community.wolfram.com/groups/-/m/t/1241941
Some database for machine learning, like VOC dataset, use .PNG file to store information. They store information in 0~255, and display it by using ColorMap.
I import it by using this code:
data=Import[path, "RawData"]
cmap=Import[path, "ColorMap"]
But I cannot find a way to export a PNG file in this format. A .PNG file in this format is included.Zhang Yanbo2017-12-08T14:38:40ZWhere can I get MRAALink version 1.0.5 (or higher)?
http://community.wolfram.com/groups/-/m/t/1231695
Hi,
I am getting errors with Mathematica 11.0.1 on Raspbian with kernel 4.9.59-v7+. These are related to the supplied version of MRAALink which is 1.0.2 and version 1.0.5 (or higher?) resolves these errors (see other discussions in this group). PackletUpdate however says that no newer version of MRAALink is available. Where can I get version 1.0.5 (or higher)?
Thanks,
GijsbertGijsbert Wiesenekker2017-11-28T00:07:25ZSolve a system of equations?
http://community.wolfram.com/groups/-/m/t/1241479
I need to solve this apparently simple system of equations in Mathematica, but it gives me an error message, that Equations may not give solutions for all "solve" variables. The command is
sol = Solve[{x1 == x A1/(x A1 + y A3), x2 == x A2/(x A2 + y A4),
x3 == y A3/(x A1 + y A3), x4 == y A4/(x A2 + y A4),
x1 + x2 + x3 + x4 == 2, x + y == 1}, {x1, x2, x3, x4, x, y}]
Any help is appreciated.Alex Token2017-12-08T08:28:45Z$5K Mathematica Machine
http://community.wolfram.com/groups/-/m/t/1241177
Suppose you had \$5K to spend on a computer that was to be devoted to computation-intensive Mathematica-based explorations. What features would you look for? Is there a particular computer you'd recommend? Extra credit if the recommended machine costs less than \$5K.
Thanks in advance for any insight.Scott Guthery2017-12-07T15:53:33ZDynamic List Plot of Serial Input in Mathematica via Arduino Serial.Print()
http://community.wolfram.com/groups/-/m/t/1241353
Hey everybody,
I'm trying to read the serial input of my USB Port into Mathematica dynamically to create a live ListPlot.
My Arduino Uno sends strings in the format of a pair via Serial.print() to the Serial Port:
![\]\[1\]][1]
(the constant Output "{0,1}\n" is just a test value)
In Mathematica 11 I connect to the Serial Port via DeviceOpen[] and start a Task that reads out the Buffer Data on my Arduino and converts it to a string.
Then I split that string into substrings at any "\n" to get pairs and interpret them in Wolfram Language as a pair.
I add these pairs to a list and then Plot that list dynamically via ListLinePlot[].
![\]\[2\]][2]
My Problem is that Mathematica doesn't read that data correctly and mostly mashes up the data and crashes.
It would be great if you guys could help me out with that!
Thanks!
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=arduino.JPG&userId=1241339
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=8486signaltransfer.JPG&userId=1241339Franz Biermann2017-12-07T18:41:19Z[✓] Join solutions to the Scrödinger Equation for a barrier potential?
http://community.wolfram.com/groups/-/m/t/1240280
I want to obtain the the solutions to the time independent Schrödinger Equation for a barrier potential. I have created three equations:
tise1 = -\[HBar]^2/2 m D[\[Psi]1[x], {x, 2}] == e0 \[Psi]1[x]
tise2 = -\[HBar]^2/2 m D[\[Psi]2[x], {x, 2}] == (e0 - v0) \[Psi]2[x]
tise3 = -\[HBar]^2/2 m D[\[Psi]3[x], {x, 2}] == e0 \[Psi]3[x]
and the boundary conditions
bc = {\[Psi]1[0] == \[Psi]2[0], \[Psi]2[a] == \[Psi]3[a],
D[\[Psi]1[x], x] == D[\[Psi]2[x], x] /. x -> 0,
D[\[Psi]2[x], x] == D[\[Psi]3[x], x] /. x -> a}; ic = {}
(I intended to use ic to remove "left moving" waves right of the potential (x>a), but I could no figure out how to do this)
Next I used
sol = DSolve[
Join[{tise1, tise2, tise3}, bc, ic], {\[Psi]1, \[Psi]2, \[Psi]3},
x]
But the results are overwhelming and as far as I can tell: wrong. I would like to be able to get the wave function as an piecewise concatenation of psi 1-3 to add the time development and to calculate transmission and reflection rates.
Hopefully this makes sense. Any help (or pointers to such) will be appreciated.
/Mogensjallberg2017-12-05T22:01:45ZAccelerate computations using GPU?
http://community.wolfram.com/groups/-/m/t/1237212
Hi,
I am trying to accelerate computation using GPU. I started with the textbook example
Needs["CUDALink`"]
ListLinePlot[
Thread[List[CUDAFoldList[Plus, 0, RandomReal[{-1, 1}, 500000]],
CUDAFoldList[Plus, 0, RandomReal[{-1, 1}, 500000]]]]]
This code should use GPU to accelerate the computation.
Then for comparison, I tried to generate similar result with
ListLinePlot[
Thread[List[FoldList[Plus, 0, RandomReal[{-1, 1}, 500000]],
FoldList[Plus, 0, RandomReal[{-1, 1}, 500000]]]]]
In both cases it took about 4 sec. to finish the computation i.e. there was no significant difference in time required to get the result. Why?Rafael Petrosian2017-12-03T01:43:49ZFITS Import incompatible between 11.2 and earlier versions
http://community.wolfram.com/groups/-/m/t/1239196
I was happy to note that the FITS Im/Export got some attention in the lates Update to Version 11.2. However, Import is now incompatible to its earlier incarnations. I am not sure wether I discovered all changes in its behavior and I am asking here for any experience others got with Import of FITS files.
This is what I found:
- Header, i.e. Metadata, information is now imported as an Association with the first key "GENERAL INFORMATION" . This is far from any FITS standard. Compare the header import from 11.1.1 and 11.2:
**11.1.1**
{"SIMPLE" -> {True, ""}, "BITPIX" -> {-32, ""}, "NAXIS" -> {4, ""},
"NAXIS1" -> {121, ""}, "NAXIS2" -> {121, ""}, "NAXIS3" -> {221, ""},
"NAXIS4" -> {1, ""}, "DATAMIN" -> {0., ""}, "DATAMAX" -> {0., ""},
"BUNIT" -> {"K (Tmb)", ""}, "CTYPE1" -> {"RA---GLS", ""},
"CRVAL1" -> {306.861, ""}, "CDELT1" -> {-0.00166667, ""},
"CRPIX1" -> {61.6741, ""}, "CROTA1" -> {0., ""},
"CTYPE2" -> {"DEC--GLS", ""}, "CRVAL2" -> {37.38, ""},
"CDELT2" -> {0.00166667, ""}, "CRPIX2" -> {61.5654, ""},
"CROTA2" -> {0., ""}, "CTYPE3" -> {"VRAD", ""}, "CRVAL3" -> {0., ""},
"CDELT3" -> {500., ""}, "CRPIX3" -> {101., ""},
"CROTA3" -> {0., ""}, "CTYPE4" -> {"", ""}, "CRVAL4" -> {1., ""},
"CDELT4" -> {1., ""}, "CRPIX4" -> {1., ""}, "CROTA4" -> {0., ""},
"OBJECT" -> {"S106", ""}, "RA" -> {306.861, "Right Ascension"},
"DEC" -> {37.38, "Declination"}, "EQUINOX" -> {2000., ""},
"LINE" -> {"CII", ""}, "ALTRPIX" -> {101., ""},
"ALTRVAL" -> {1.90054*10^12, ""}, "RESTFREQ" -> {1.90054*10^12, ""},
"VELO-LSR" -> {0., ""}, "VELREF" -> {257, ""},
"SPECSYS" -> {"LSRK", ""}, "BMAJ" -> {0.00416667, ""},
"BMIN" -> {0.00416667, ""}, "BPA" -> {0., ""},
"ORIGIN" -> {"GILDAS Consortium", ""},
"DATE" -> {"2017-06-01T10:55:26.668", "Date written"}}
**11.2**
<|"GENERAL INFORMATION" -> <|"SIMPLE" -> True, "BITPIX" -> -32,
"NAXIS" -> 4, "NAXIS1" -> 121, "NAXIS2" -> 121, "NAXIS3" -> 221,
"NAXIS4" -> 1, "DATAMIN" -> 0., "DATAMAX" -> 0.,
"BUNIT" -> "K (Tmb)", "CTYPE1" -> "RA---GLS", "CRVAL1" -> 306.861,
"CDELT1" -> -0.00166667, "CRPIX1" -> 61.6741, "CROTA1" -> 0.,
"CTYPE2" -> "DEC--GLS", "CRVAL2" -> 37.38, "CDELT2" -> 0.00166667,
"CRPIX2" -> 61.5654, "CROTA2" -> 0., "CTYPE3" -> "VRAD",
"CRVAL3" -> 0., "CDELT3" -> 500., "CRPIX3" -> 101., "CROTA3" -> 0.,
"CTYPE4" -> Missing["NotAvailable"], "CRVAL4" -> 1.,
"CDELT4" -> 1., "CRPIX4" -> 1., "CROTA4" -> 0., "OBJECT" -> "S106",
"RA" -> 306.861, "DEC" -> 37.38, "EQUINOX" -> 2000.,
"LINE" -> "CII", "ALTRPIX" -> 101., "ALTRVAL" -> 1.90054*10^12,
"RESTFREQ" -> 1.90054*10^12, "VELO-LSR" -> 0., "VELREF" -> 257,
"SPECSYS" -> "LSRK", "BMAJ" -> 0.00416667, "BMIN" -> 0.00416667,
"BPA" -> 0., "ORIGIN" -> "GILDAS Consortium",
"DATE" -> "2017-06-01T10:55:26.668"|>|>
Note that the comment entry of each header is is now omitted (last entry "DATE" This violates the FITS standard as far as I understand? In any case it breaks my code that expects to import a List and not an Association - and yes I know that I can use Normal to transform it into a List again. I didn't check yet how the header is imported if data is stored in a more complex arrangement, such as Bintable or another Extension format.
- Data is imported in reverse order now. Image and RawData Import now return the same row ordering. I don't know what the standard order should be, but it changed after 11.2. As an example I Import an array of spectra:
11.1.1
In[9]:=Dimensions[raw]
Out[9]:={1, 1, 221, 121, 121}
In[10]:=raw[[1, 1, All, 50, 50]]
Out[10]:= {0.125237, 2.99011, 0.571144, -0.834969, 1.56174, 0.110322, -1.4104, \
-2.62194, -1.9974, 1.81346, 1.41345, -0.346708, -0.284448, 1.31853, \
-1.36181, -3.43505, 2.01738, 3.3406, -0.353997, 3.28855, -0.4002, \
-0.415156, 2.57086, -0.826749, -0.493768, -1.06639, -0.795575, \
0.438714, 1.41906, -1.45034, -1.13682, -1.06962, 0.349537, -1.69687, \
-0.618968, -1.31552, -1.63609, -1.14806, -1.78705, -1.59089, \
-0.0172433, -1.34023, -1.68296, -0.169548, 0.525515, 2.61707, \
-0.10389, 1.23272, -1.37291, 2.35375, 1.26516, -0.9361, -2.47334, \
0.319303, 0.574864, -1.37799, 2.33915, 2.38415, -0.855974, 0.500247, \
1.93797, -0.510813, -1.4609, 1.37657, -1.31001, 1.82468, -0.0288664, \
0.788793, -0.0313442, 1.0192, 0.661234, -0.551474, 3.03574, \
-0.258694, 0.83997, -0.590292, -0.164056, -0.675589, 1.22346, \
1.87058, -0.421079, -0.670318, 0.758016, 1.17182, -1.83596, 0.130186, \
-1.47637, 0.0714399, -0.381047, -0.654595, 0.337103, 0.0541637, \
3.54652, 0.473411, -0.751777, 2.00137, 1.23871, 0.964236, 0.697787, \
0.745029, 1.64881, 3.73721, -1.57351, 0.0654506, 1.01008, -3.37733, \
0.536895, 1.05536, -2.57754, -0.439541, -1.92688, -1.43538, \
-0.580122, -2.33661, 1.18908, -0.270191, -1.23731, -1.61967, \
-2.18623, -1.54892, -2.25664, -1.60237, -1.10626, -3.27524, -2.8534, \
-1.30801, -2.94565, -1.62026, -1.18614, -1.68366, -3.44239, -4.29097, \
0.139907, 1.39606, 0.885509, 1.06719, -0.0184753, -1.556, 1.02081, \
-0.15279, 1.59421, -0.582037, 0.377889, -0.0525626, 1.52673, \
0.449664, 0.628198, 2.56478, 1.04696, -0.246007, -1.73447, 0.984217, \
1.40674, -1.03528, 1.74808, 0.661529, -1.55615, 2.12005, 0.0215735, \
-0.843181, -0.187671, 2.10022, 1.94109, 0.461266, -0.836785, \
-1.85344, 1.4057, -1.1845, -0.0455038, -2.07055, -1.30267, -0.957898, \
-0.813964, 0.0770546, 1.1605, -0.0788292, 0.352559, -2.4903, \
-0.0513624, 0.927214, -1.23293, -0.846625, -2.09944, -0.909728, \
-0.178735, -0.756856, -0.0954211, -2.28924, -0.616761, -0.295874, \
0.97779, -0.325473, 1.3985, 0.176696, -0.936313, 0.919589, 2.14291, \
-0.287233, 1.11923, 1.55756, 0.128433, 0.739541, -0.211153, 0.56651, \
2.30676, 0.714307, 1.81921, 0.0436757, 0.384643, 0.223706, 1.79563, \
-0.512, 1.53679, 1.84418, 0.788868, 2.69285, 0.688162, 1.14756, \
-0.599565, -1.12756, 0.227808}
**11.2**
In[11]:= raw[[1, 1, All, 50, 50]]
Out[11]= {0.741499, 2.69608, -0.835699, 0.260684, 0.344929, \
-0.862212, 0.103039, -0.406144, 1.25696, 2.21517, -3.61728, \
-0.390149, -0.20015, -0.221925, -0.133629, -0.127833, -0.537916, \
-1.6329, 0.529082, 2.89574, 2.174, 0.509376, -0.12798, -2.91033, \
-0.936878, 1.72893, -0.144214, -1.6564, -0.203739, 1.31158, 0.482649, \
-2.29575, 1.49968, -1.43943, -0.907162, 2.33743, -0.134048, -1.52299, \
0.700724, -1.32794, 0.0540263, -0.0130849, -1.3927, -0.358867, \
0.457883, 0.920364, 0.0981134, 0.398595, 2.10525, -1.26789, \
-0.120008, 1.87544, 1.49796, 1.14598, -0.445654, 0.0828433, -0.5025, \
0.48467, -0.903544, 0.721465, -1.19323, 1.8576, -0.913446, \
-0.0233543, -0.130562, 0.171933, -1.76813, 1.22534, -0.769345, \
0.596699, -1.53008, -0.806187, 0.376273, 0.274861, 0.879051, \
-0.285103, 0.652643, -2.05536, -1.18484, 1.23708, -0.524947, \
-1.10875, 0.632588, 0.362561, 0.521122, 1.09359, 2.34802, 0.219165, \
0.528764, 3.89038, 2.3092, 4.25087, 2.91008, 3.86056, 4.43583, \
5.34523, 3.33701, 5.04292, 6.16093, 3.11196, 4.95334, 3.44107, \
3.13834, 1.72268, 1.4871, 2.09813, -1.24582, 1.52399, 1.33164, \
-1.41426, -0.438202, 1.09399, 1.99072, -0.0511786, 1.6797, 1.81019, \
0.234106, 0.0070522, -0.191584, -1.71418, 0.300965, 1.56744, 2.86724, \
-0.710091, -0.042246, 0.0861327, 0.404054, 0.245493, 1.15148, \
-0.107975, -0.609298, -0.358749, -0.93885, -0.575624, 1.58488, \
0.605153, -0.148833, 1.31476, 0.886797, -0.500806, 0.690805, 1.55135, \
-2.82947, -1.44928, 0.0264999, 0.0159517, 0.381241, -0.710363, \
0.308564, -0.362335, 0.384097, 0.0797061, -0.522967, -2.15822, \
0.146816, 1.26085, 1.6938, 0.86811, 1.65988, -0.939591, -0.786369, \
-0.473823, 0.299186, 2.18688, -0.564252, -1.95808, -0.297, \
-0.00392977, 0.0266746, -0.849348, 1.03588, 0.392564, 0.383135, \
0.955122, -0.398982, 0.96028, 0.159508, -0.806305, -0.292513, \
0.168193, 1.60123, 0.0350197, -2.45768, -0.809964, -0.966695, \
0.389624, -0.296024, 1.07444, -0.276236, -0.0449804, 0.135233, \
0.994279, -0.915011, -0.196694, 0.568144, -0.0751389, 0.0356748, \
-1.49772, -2.33957, 2.12178, -0.122009, 1.63197, 1.28452, -1.27409, \
1.67394, -0.64527, -1.91461, 0.0593593, -0.0333713, -0.355916, \
0.164881, 1.38631, 2.90664, 1.8102, -0.422445, 0.256066, 0.393217, \
1.07279, 2.3621, -0.935344, 1.38919}
In[12]:= raw[[1, 1, All, -50, 50]]
Out[12]:= {0.125237, 2.99011, 0.571144, -0.834969, 1.56174, 0.110322, -1.4104, \
-2.62194, -1.9974, 1.81346, 1.41345, -0.346708, -0.284448, 1.31853, \
-1.36181, -3.43505, 2.01738, 3.3406, -0.353997, 3.28855, -0.4002, \
-0.415156, 2.57086, -0.826749, -0.493768, -1.06639, -0.795575, \
0.438714, 1.41906, -1.45034, -1.13682, -1.06962, 0.349537, -1.69687, \
-0.618968, -1.31552, -1.63609, -1.14806, -1.78705, -1.59089, \
-0.0172433, -1.34023, -1.68296, -0.169548, 0.525515, 2.61707, \
-0.10389, 1.23272, -1.37291, 2.35375, 1.26516, -0.9361, -2.47334, \
0.319303, 0.574864, -1.37799, 2.33915, 2.38415, -0.855974, 0.500247, \
1.93797, -0.510813, -1.4609, 1.37657, -1.31001, 1.82468, -0.0288664, \
0.788793, -0.0313442, 1.0192, 0.661234, -0.551474, 3.03574, \
-0.258694, 0.83997, -0.590292, -0.164056, -0.675589, 1.22346, \
1.87058, -0.421079, -0.670318, 0.758016, 1.17182, -1.83596, 0.130186, \
-1.47637, 0.0714399, -0.381047, -0.654595, 0.337103, 0.0541637, \
3.54652, 0.473411, -0.751777, 2.00137, 1.23871, 0.964236, 0.697787, \
0.745029, 1.64881, 3.73721, -1.57351, 0.0654506, 1.01008, -3.37733, \
0.536895, 1.05536, -2.57754, -0.439541, -1.92688, -1.43538, \
-0.580122, -2.33661, 1.18908, -0.270191, -1.23731, -1.61967, \
-2.18623, -1.54892, -2.25664, -1.60237, -1.10626, -3.27524, -2.8534, \
-1.30801, -2.94565, -1.62026, -1.18614, -1.68366, -3.44239, -4.29097, \
0.139907, 1.39606, 0.885509, 1.06719, -0.0184753, -1.556, 1.02081, \
-0.15279, 1.59421, -0.582037, 0.377889, -0.0525626, 1.52673, \
0.449664, 0.628198, 2.56478, 1.04696, -0.246007, -1.73447, 0.984217, \
1.40674, -1.03528, 1.74808, 0.661529, -1.55615, 2.12005, 0.0215735, \
-0.843181, -0.187671, 2.10022, 1.94109, 0.461266, -0.836785, \
-1.85344, 1.4057, -1.1845, -0.0455038, -2.07055, -1.30267, -0.957898, \
-0.813964, 0.0770546, 1.1605, -0.0788292, 0.352559, -2.4903, \
-0.0513624, 0.927214, -1.23293, -0.846625, -2.09944, -0.909728, \
-0.178735, -0.756856, -0.0954211, -2.28924, -0.616761, -0.295874, \
0.97779, -0.325473, 1.3985, 0.176696, -0.936313, 0.919589, 2.14291, \
-0.287233, 1.11923, 1.55756, 0.128433, 0.739541, -0.211153, 0.56651, \
2.30676, 0.714307, 1.81921, 0.0436757, 0.384643, 0.223706, 1.79563, \
-0.512, 1.53679, 1.84418, 0.788868, 2.69285, 0.688162, 1.14756, \
-0.599565, -1.12756, 0.227808}
I am not asking how to correct this - I can do it. I am curious on why this was implemented and what else had been changed. I would also like to see a mentioning of such changes in the Documentation. Any other experiences so far?Markus Roellig2017-12-04T17:19:55ZCalculate the following integral with assumptions?
http://community.wolfram.com/groups/-/m/t/1236495
Can this integral be approached in a different way? Mathematica 11.2 spits out the input.
$Assumptions = p1 > 0 && Element[p1, Reals]
$Assumptions = p4 > 0 && Element[p4, Reals]
$Assumptions = p5 > 0 && Element[p5, Reals]
$Assumptions = r1 > 0 && Element[r1, Reals]
Integrate[Pi*(Sin[p1*r1]/(p1*r1))*((Log[(p1 - p3)^2/(p1 + p3)^2]*Log[(p1 - p4)^2/(p1 + p4)^2])/(p3*p4)), {p1, a, b}]
(* Integrate[(Pi*Log[(p1 - p3)^2/(p1 + p3)^2]*Log[(p1 - p4)^2/(p1 + p4)^2]*Sin[p1*r1])/(p1*p3*p4*r1), {p1, a, b}]*)Arny Toynbee2017-12-02T04:02:09ZVary Interpolation or add specific number to eliminate unwanted points?
http://community.wolfram.com/groups/-/m/t/1240993
Hello,
Is there any way to vary interpolation or adding specific number to eliminate unwanted points. For example, in my case the arrows in the opposite direction. In other words, what I should add in this: Interpolation[data]
In[5]:= data = MapThread[{{#1, #2}, #3} &, {z, x, ffun}]
Out[5]= Out[5]
In[6]:= q = Interpolation[data]
Out[6]= InterpolatingFunction[{{0.336, 0.352}, {0.439, 0.455}}, <>]
In[7]:= gradient[a_, b_, i_] :=
Evaluate[Grad[q[a[[i]], b[[i]]], {a[[i]], b[[i]]}]]
In[8]:= gr =
Reap[Do[Sow[{z[[i]], x[[i]], gradient[z, x, i]}], {i,
Length[z]}]][[-1, 1]]
Out[8]= Out[8]
In[9]:= vunorm = Im[gr[[;; , 3]]];
In[10]:= vn = Normalize /@ vunorm;
In[11]:=
vnn = Table[{z[[i]], x[[i]], vn[[i]]}, {i, 1, Length[vn]}]
Out[11]= Out[11]
In[12]:= list = Partition[Flatten[vnn], 4];
In[13]:= vl =
ListVectorPlot[list, VectorScale -> Small, VectorPoints -> {25, 25}]
For more details, please see the attachment.
Many thanks in advance!Ghady Almufleh2017-12-06T15:46:13ZChange stdlink to other WSLINK when using WSPut @ WSTP
http://community.wolfram.com/groups/-/m/t/1240579
Is it possible to create some other WSLINK instead of stdlink with WSMain function?
The following WSTP code I tested with mathematic 10.0 and it didn't work:
std::cout<<"this is a test message."<<std::endl;
WSPutString(stdlink, "test a reply message");
The error output from Mathematica is: LinkObject::linkd: Unable to communicate with closed link LinkObject[......]
However if I removed the std::cout line, it works fine. I can get the reply message on Mathematica.
I guess it is because they're all using stdlink, so I would like to change to another WSLINK. Is it possible to change it?chad andy2017-12-06T07:49:33ZCreate (Header + Main area + Settings pane) notebook layout?
http://community.wolfram.com/groups/-/m/t/1239940
[*cross-posted in mathematica.stackexchange*](https://mathematica.stackexchange.com/q/161203/5478)
The goal is something like in the picture below.
Basic? I dare you to try to implement it in a manageable, scalable and flexible way.
[![enter image description here][1]][1]
## Requirements:
*The goal is a natural experience as this is a standard layout in many places. Keep that in mind if anything is not clear.*
Points 1. and 2. are required. 3. is optional.
1. Behavior:
- 'head' has fixed heigth and notebook's width (minus margins). Would be nice to not have to know the height before.
- notebook is resizeable and when it happens:
- 'main' and 'sett' adapt heights to fill the notebook
- 'sett' width remains the same, only 'main's' width is affected
- 'sett's' width can be changed by inner 'resizeArea' element. (not present above, usually one can dragg the vertical area between 'main' and 'sett' but how it will be done here does not matter.
- needs to work well at least on Mac and Win
- needs to work in a .cdf launched inside FreePlayer
- needs to work smoothly as this is only a template for further app, perfect solution would be completely FrontEnd side but it is enough if panels' contents are not *bothered* too much
2. Style: (*equally important*)
- panel's frames need to be aligned (like above)
- margins/spacings/cellmargins should be consistent. e.g. outer margins should be the same as spaces between panels inside, or whatever user desires.
3. Bonus points for:
- easily adaptable for different window frames e.g.: palette/default.
- max/min notebook size restrictions
- should handle magnification changes gracefully, e.g. panel layout should be left intact or scale notebook size together with it, while contents of panels should scale normally
## Wishes
The ideal answer should provide a general approach for multipanel layout that supports resizing/locking specific values and the final result is aligned nicely with adjustable margins etc.
A good test case would be to handle something like:
Grid[{
{"header", SpanFromLeft, SpanFromLeft},
{"left panel", Pane["main panel", ImageSize -> {300, 300}, Alignment -> {Center, Center}], "rightPanel"},
{"footer", SpanFromLeft}
}, Frame -> All]
### What have you tried?
A lot... and I always ended up with a really project specific solution that needed to sacrifice few features. I lost hope for `Full/Scaled` `ImageSize` spec, in terms of expected response, respecting margins or scalability for multiple panels.
Managing image size via `Dynamic` `ImageSize` for `Panes` quickly escalates to not worth the effort stage. And is not stable, I can cook up and example which works well till you move the window to a secondary screen... despite the fact it only uses WindowSize.
## Here is something to start with:
CreateDocument[
DynamicModule[{headerH = 50, settW = 150}
, Grid[
{ { Panel@ Pane["head", Dynamic@{AbsoluteCurrentValue[{WindowSize, 1}] - 28, headerH}]
, SpanFromLeft
}
, { Panel @ Pane["main", Dynamic[AbsoluteCurrentValue[
WindowSize] - {settW + 15 + 18 + 12, headerH + 15 + 18 + 12}]]
, Panel @ Pane["sett", Dynamic[{settW, AbsoluteCurrentValue[{WindowSize, 2}] - headerH - 15 - 18 - 12}]]
}
}
, Spacings -> {0, 0}
, Alignment -> {Left, Top}
]
, BaseStyle -> {
PanelBoxOptions -> {
FrameMargins -> 0, ImageMargins -> 5, BaseStyle -> FontSize -> 25
}
, PaneBoxOptions -> {FrameMargins -> 0, ImageMargins -> 0
, Alignment -> {Center, Center}
}
}
]
, WindowSize -> 500
, StyleDefinitions -> "Dialog.nb"
, CellMargins -> {{5, 5}, {5, 5}}
, CellFrameMargins -> {{0, 0}, {0, 0}}
, WindowFrameElements -> All
]
## Additional reading:
- https://mathematica.stackexchange.com/q/158835/5478
[1]: https://i.stack.imgur.com/Z3hOe.pngKuba Podkalicki2017-12-05T10:20:01ZPlot a function with x, y and a variable?
http://community.wolfram.com/groups/-/m/t/1240094
I'm trying to plot a function with x, y and a variable. The code worked when I did a contour plot, but now I need a regular plot. Can somebody tell me what is wrong?
p1=Import["....xlsx"][[1]];
Stressfunc1 = LinearModelFit[p1, {1, x, y, x^2, x*y, y^2, x^3, x^2*y, x*y^2, y^3}, {x, y}];
Stressfunc1r = Stressfunc1["BestFit"]
Plot[Stressfunc1r, {x, 0, 1.4}, PlotLegends -> True, PlotLabel -> "A11 for Mesh 1", FrameLabel -> {"x", "y"}]Ellen vdE2017-12-05T16:54:45ZWolfram Alpha Bot
http://community.wolfram.com/groups/-/m/t/1240551
**Wolfram|Alpha Bot is now available!**
====================================
I decided a while ago when I created the Wolfram|Alpha .NET library that I should create something meaningful with it. After all, with that library, interacting with the WolframAlpha API from C# has never been easier.
After a bit of development I developed Wolfram|Alpha Bot, and with the approval of Facebook it has been released to the general public.
You may interact with it through it's facebook page: https://www.facebook.com/WolframAlphaBot
Go ahead and try it! Here are some examples of what you can ask it: http://www.wolframalpha.com/examples/
Keep in mind that neither the library nor the bot are an official product of Wolfram Research.
![bot1][1]
![bot2][2]
![bot3][3]
LINKS:
======
Original post in Wolfram Community Forums: http://community.wolfram.com/groups/-/m/t/1220925
Wolfram|Alpha .NET repository: https://github.com/xjose97x/WolframAlpha
Wolfram|Alpha .NET NuGet package: https://www.nuget.org/packages/Wolfram.Alpha/
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=screnbot.png&userId=1151285
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=scren2.png&userId=1151285
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=wolfscree.png&userId=1151285Jose Escudero2017-12-06T02:56:06ZMathematica 11.2: No printers to select (Ubuntu)
http://community.wolfram.com/groups/-/m/t/1239408
Me and a colleague of mine cannot print directly to our printers. If we want to print Mathematica offers only "Print to file (PDF)" but not the printers that are available to other applications. We are both running systems based on Ubuntu 16.04 x64 which uses CUPS 2.1 and Qt 5.5.
Any tips how to debug this? Or is it a known problem?Andreas Schamanek2017-12-04T19:52:44ZMultiColumn + ArrayPlot
http://community.wolfram.com/groups/-/m/t/1240261
Here's an idea for a new function. I don't know what its name should be but it would be nice to make some of the graphics you see in [A New Kind of Science (Wolfram 2002)][1] like this one of rule 1599
![code 1599][2]
like the one found on [p.70][3] The idea is to take an array and instad of just plotting it with ArrayPlot you slit it into columns first.
Maybe it is a combination of ArrayPlot and Multicolumn that would automatically rearrange narrow arrays, e.g.,
Row[Map[ArrayPlot, ArrayReshape[#, {3, Quotient[Length[#], 3], Length[#[[1]]]}]] &[
CellularAutomaton[{1599, {3, 1}}, {RandomInteger[2, 150], 0}, 499]]]
[1]: http://www.wolframscience.com/nks/
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=image-1599.png&userId=23275
[3]: http://www.wolframscience.com/nks/p70--more-cellular-automata/Todd Rowland2017-12-05T19:09:10ZAvoid error with the coordinate of a plot?
http://community.wolfram.com/groups/-/m/t/1239212
Hi guys.
I don't understand why I get this error:
"Coordinate {10, 8, 3, 1} should be a triple of numbers, or a Scaled form."
T[x_, y_, z_] := {{1, 0, 0, x}, {0, 1, 0, y}, {0, 0, 1, z}, {0, 0, 0, 1}};
Rx[α_] := {{1, 0, 0, 0}, {0, Cos[α], -Sin[α], 0}, {0, Sin[α], Cos[α], 0}, {0, 0, 0, 1}}
Ry[α_] := {{Cos[α], 0, Sin[α], 0}, {0, 1, 0, 0}, {-Sin[α], 0, Cos[α], 0}, {0, 0, 0, 1}}
Rz[α_] := {{Cos[α], -Sin[α], 0, 0}, {Sin[α], Cos[α], 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}
T01 = T[x0, 0, 0].Rz[α0]; MatrixForm[T01]
T12 = T[0, 0, z1].Rz[θ1]; MatrixForm[T12]
T23 = T[-a1, 0, 0].Ry[-θ2]; MatrixForm[T23]
T34 = T[L1, 0, 0].Ry[π - θ3]; MatrixForm[T34]
T45 = T[L2, 0, 0]; MatrixForm[T45]
T05 = FullSimplify[T01.T12.T23.T34.T45]; MatrixForm[T05]
O1 = T01.{0, 0, 0, 1}; O1 = O1[[1 ;; 3]];
O2 = T01.T12.{0, 0, 0, 1}; O2 = O2[[1 ;; 3]];
O3 = T01.T12.T23.{0, 0, 0, 1}; O3 = O3[[1 ;; 3]];
O4 = T01.T12.T23.T34.{0, 0, 0, 1}; O4 = O4[[1 ;; 3]];
O5 = FullSimplify[T01.T12.T23.T34.T45.{0, 0, 0, 1}]; O5 = O5[[1 ;; 3]];
Manipulate[
Block[
{x0 = 10, z1 = 3, a1 = 2, α0 = π/2, L1 = 30,
L2 = 20, θ1 = q1, θ2 = q2, θ3 = q3},
Graphics3D[{Red, Thick, Line[{O1, O2, O3, O4, O5}], LightBlue,
Cuboid[{0, 0, 0}, {0, 30, 40}], LightGray,
Cuboid[{0, 0, 0}, {10, 30, 0}]} ,
PlotRange -> {{0, 10}, {0, 30}, {0, 40} }]
],
{{q1, 0}, -π, π}, {q2, 0, 3π/4}, {q3, 0, π}
]
I guess the problem comes from the origins O1,O2, etc.
Could you help me?Lorenzo Cristofori2017-12-04T13:01:07ZSolve equations in the package GaloisField?
http://community.wolfram.com/groups/-/m/t/1235215
Hi all, i'm new here and i need help, i'm working with the package GaloisField and over field GF[2^m] with m>1. What i really need is to know wich x, y in GF[8], for example, satisfies the equation x^2+xy^ay^2=b, where a and b are choosen elements of the field. Or i need to solve at least the equation x^2+cx+a=b, with c,a,b in the field..
I was able to solve x^2+a=b and ax+c=b, but when i put the equation x^2+cx+a=b it doesn't work.. anyone can help me please? Thanks
In[55]:= Solve[x^2 + F8[2] == F8[4], x]
Out[55]= {{x -> F8[5]}, {x -> F8[5]}}
In[56]:= Solve[x*F8[2] + F8[3] == F8[5], x]
Out[56]= {{x -> F8[3]}}
In[57]:= Solve[x^2 + x*F8[2] + F8[4] == F8[7], x]
Out[57]= {{x -> 0}, {x -> 0}}maycow carneiro2017-11-29T14:05:51ZFree Wolfram Language on Raspberry Pi tutorial
http://community.wolfram.com/groups/-/m/t/418132
*NOTE: the main tutorial notebook is attached at the end of this post.*
----------
I wanted to share the attached *Mathematica* notebook that I created for teaching kids (ages 9-14) about the Wolfram Language on the Raspberry Pi. It has a simplified (and colored) interface for students and easy editing tools for authors (even those with little or no experience using *Mathematica*). It includes a self-paced tutorial designed for beginning programmers who are young or young-at-heart. It also includes instructions for authoring your own tutorials. The interface is minimally dynamic so the tutorial will run as smooth as possible on the Raspberry Pi model B; if there is interest, then we could build a prettier dynamic interface for more powerful hardware. Please comment below with any improvements/changes that you would like to see and of course please comment or upvote if you find this useful or interesting :)
----------
## Sample of the attached tutorial:
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-12-05at11.46.57AM.png&userId=11733Kyle Keane2015-01-07T18:16:20ZTest for reals and integers in expression?
http://community.wolfram.com/groups/-/m/t/1239097
To test that a numerical expression (typically a list of numbers) contains only reals, I wrote this function
ReV[expr_]:=VectorQ[expr,NumericalQ[#]&&(Head[#]===Real)&
Works fine. How do I extend this to test for the presence of only reals and integers? Changing the last (..) to
(Head[#]===Real||Head[#]===Integer)
doesn't work.Carlos Felippa2017-12-04T18:19:20Z