/r/Mathematica
For information and tips about Mathematica features.
related reddits:
/r/Mathematica
V[x_] = (1 - Exp[-Sqrt[2/3]*x])^(2);
drV[x_] = D[V, x];
Solve[-drV/V == -Sqrt[2], x];
phif = 0.940;
X = (1 + (2 - a)*phi/(2 Sqrt[3 b]))^(2/(2 - a));
M[phi_] = -Sqrt[b/3] (X^a (a + 6 X) - 3 b*X)/(X^(1 + a/2)*(2 X^a - b));
drM[phi_] = D[M[phi], phi];
Mf[a_, b_] := M[phif] == V[phif];
drMf[a_, b_] := drM[phif] == drV[phif];
Solve[{Mf[a, b], drMf[a, b]}, {a, b}]
Processing img c28obgpgex1e1...
dbgbb!(...) makes it easy to debug array data using notebooks just like the dbg!(...) macro. It sends the data to the BulletinBoard server, and then it can be read from Mathematica/Jupyter notebooks
BulletinBoard is an in-memory object storage that mediates data between a Rust program and a notebook. The BulletinBoard server is available on crates.io, DockerHub, and GitHub. There is also a GUI application that acts as both client and server.
Data is stored as ArrayObjects, which is a self-describing binary data format optimized for array data and for object storage.
Check it out and enjoy the accelerated coding experience!
https://github.com/YShoji-HEP/dbgbb
Here is the code generated taking help of an AI tool (ChatGPT):
Count[WordList[], StringMatchQ[#, "q" ~~ ___] &]
There is definitely something wrong as the output should not be zero.
The syntax StringMatchQ[#, "q" ~~ ___] & is something I find difficult to relate. It will help if someone could explain the relevance of #, ~~ ___, & within the code. Of course since the code is apparently giving wrong output, first need to revive the correct code.
Thanks in advance!
On running TextSentences[x], it will help if anyone can explain how the Wolfram Languages infers for example "Resrly" is not the first word of a new sentence.
StringLength[MaximalBy[WordList[],StringLength]]
Not sure why the output is in list form. Obviously there should be a way to convert this list form into integer form.
The problem is to make a string from the first letters of all the sentences in the Wikipedia article about computers.
Here is my tentative code:
StringJoin[StringTake[StringSplit[WikipediaData["computers"],"."], 2]]
Not sure about the error messages shown in red above.
I chose 2 instead of 1 for StringTake argument as there seems to be a whitespace after period.
Help is sought also for how to ensure that the first letter after a sentence is selected irrespective of it appears after the period or followed by one or more whitespaces.
StringSplit[stringsample,{"."}][[ 1]]
The double square bracket syntax appears not that intuitive with otherwise the usual way which is putting one function above the other.
If I understand correctly, the output of StringSplit function which is a list is being used by [[1]] to show just the first element of the list. What appears strange is the syntax.
The goal is to by using StringSplit, split the text on the basis of comma appearance.
StringSplit["Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",","]
The above syntax generated after referring to Wolfram docs on StringSplit:
It seems the comma is indeed split but difficult to discern from the output. So trying to take help of InputForm function in order to show each substring with quotes.
The docs uses InputForm[%] as second code after the StringSplit code. Not sure how the second code using InputForm function will know that it is the previous code of which referred.
I tried to do the same with my code and here is the screenshot:
How can I solve this problem? When I try to click to select, I cannot select it. When I click on the details, I see the license (free trial account). My university provides a code, so I want to use it, but there is no place to enter my code. I uninstalled and reinstalled Mathematica, but I still couldn’t solve the issue.
StringPosition[WikipediaData["Strings"],"."]
The aim is to find the positions where the periods occur in the article. The output is strange with only 3 results.
For finding how many words are there in the Wikipedia article "Computer", after running the below code, getting 9358 (instead of 9239):
Length[StringSplit[WikipediaData["computer"]]]
If I am correct, StringSplit counts each word based on the number of times it encounters white space while parsing through the whole string. So even if there are punctuation marks like commas, that should not affect the count of words.
This is a question in exercises part of Strings & Text (An Elementary Introduction to the Wolfram Language).
Not sure what it means by Wikipedia and 'computer' in this context. Is WikipediaData function designed so as to access the content of wikipedia.org?
Also what it exactly means by Wikipedia article for 'coimputer'. Will it refer to this url page: https://en.wikipedia.org/wiki/Computer?
BarChart[StringLength[StringSplit["A long time ago, in a galaxy far,far away", ","]]]
While I can follow the reason for three bars as there are 2 commas in the string, unable to grasp the reason why first unit in the x axis left empty (or with zero value).
I have an equation that i need to solve but Mathematica only outputs empty brackets
di = 0.1;
dRI = 0.11;
da = dIA + 0.01;
ai = 1000;
lR = 47;
lI = 0.08;
lA = 220;
aa = 15;
ka = 0.5299;
eq = 1/ka ==
da/di*ai + da/2*lR*Log[dRI/di] + da/2*lI*Log[dIA/dRI] +
da/2*lA*Log[da/dIA] + 1/aa
Solve[eq, dIA]
Ouput:
1.88715 ==
1/15 + 10002.2 (0.01 + dIA) + 0.04 (0.01 + dIA) Log[9.09091 dIA] +
110 (0.01 + dIA) Log[(0.01 + dIA)/dIA]
{}
I asked ChatGPT but that didnt help. What am I doing wrong?
Hello!
I am about to buy a new laptop and I would like some advice in terms of which specs I should focus on, given that my main usage for work is Mathematica (plus all the usual stuff, email, web, etc). Since Mathematica can be used in many ways and for different purposes here some details for my use case.
I am a theoretical physicist and I use Mathematica constantly everyday. 90% of what I do is symbolic calculations that involve a huge amounts of terms. I usually reduce most of operations to basic ones, in order to speed things up. A typical example (for those among you that do a similar job) is calculation of many Feynman diagrams, which in principle are integrals but can be easily reduced to algebraic operations and the most time-consuming part is the simplification of terms (typically hundreds of thousands). By simplifications I mean applying some rules to substitute terms so they sum up and simplify.
Another example in my daily usage are perturbative expansions. In many situations I have to derive some expressions which are functions of quantities that are power series and then derive the power series of the result.
Less often I do numerical calculations or graphics (but I do them). I also sometimes do some numerical scans.
Please, also consider that, besides the heavy usage of Mathematica, I use other coding language like FORM. Also, I don't do any graphic design or video editing, but I am considering some online teaching, so a good camera and screen-sharing fluidity is important (also important when giving online seminars or work meetings). Finally, as a pure hobby, I also make some ambient music using ableton live :).
Since the new macbook pro with the M4 chips are out, and they seem a huge upgrade, I am considering buying one.
But there are many different specs and many golden coins involved.
What would be the most important aspect(s) to look at? I have zero knowledge on which Mathematica functionality uses which laptop's feature. I can only note that, when Mathematica takes long time and the fans are on, CPU is 100%, while RAM is mostly fine. So, should I focus more on number of cores rather than ram (which anyway should be 16GB, at least)?
Just to keep it in context with the laptop I am looking at, there is a huge jump in performance from the M4 [16 GB of ram, 512 ssd, 10 core (4+6)] and the M4 pro [24 GB of ram, 512 ssd, 12 core (8+4)], but I am not sure if it is worth for my usage.
At the moment I have a Lenovo yoga slim 7 from 2020 with Ubuntu. At that time I switched from Windows to Ubuntu simply because I couldn't stand Windows anymore and I have zero regrets ;). However, I am not really a typical Linux user and the fact that I need to access the terminal for any tiny thing is frustrating (still less than using Windows...). This is why I am thinking of switching to macOS which may be the right half-way between dumb Windows and Linux.
A final note, the Macbooks mentioned above are the devices that I am considering now but your answers do not need to be specifically on those models (although any advice is welcome), it was just for context.
Thanks and cheers!
Hello, I'm going to present a Calculus 2 seminar on Fubini's Theorem and I need to solve contextualized situations in the area of Engineering that involve this topic. Could anyone help me with 3 practical examples, applied to Engineering, using Fubini's Theorem, with detailed resolution? Thank you very much for the help!
f[x_Integer] := x + 108
h[x_Integer] :=x + 77
SetAttributes[f, Listable]
f[x_List] := h/@x
f[{44,444}]
Given I have referred h function here: f[x_List] := h/@x , I expected the output of f[{44,444}] to be 121 (77 + 44) and 521 (77 + 444). So my query is how even after inclusion of h, the output of list still referring to f. Is it then wrong to code:
f[x_List] := h/@x
And what is the implication or utility of mentioning h (as part h/@x) when anyway it will be g/@x.
Continuing with my earlier post Difference between prefix and map and why they produce the same output in this code, it will hep if someone can clarify the difference between these 3 codes giving the same output:
The first one is the most intuitive and this is the way till now I have been using functions most of the time:
StringLength[StringSplit["A long time ago, in a galaxy far, far away", {",", " "}]]
If I understand correctly, the second one and third ones are giving the same output as StringLength function has listable attribute added by default.
StringLength@StringSplit["A long time ago, in a galaxy far, far away", {",", " "}]
StringLength/@StringSplit["A long time ago, in a galaxy far, far away", {",", " "}]
If listable attribute were not added by default to the StringLength function, then mapping was needed (by using /@).
This now brings the need to use prefix (by using @) when even without the use of prefix, there is the same output as in the first code.
Running the two operations produces same result for these codes:
StringLength /@ StringSplit["A long time ago, in a galaxy far, far away", {",", " "}]
Output:
{1,4,4,3,0,2,1,6,3,0,3,4}
StringLength@StringSplit["A long time ago, in a galaxy far, far away", {",", " "}]
Output:
{1,4,4,3,0,2,1,6,3,0,3,4}
On further check, it appears first one performs map operation while the second one is called prefiix. Both are meant to do different things apparently.
how i found the positive inverse of x^2 +2 in mathematica? i tried using
f[x_] := x^2 + 2
Solve[y == f[x] && x >= 0, x]
but it doesnt work
BarChart[StringLength[StringSplit["A long time ago, in a galaxy far,far away"]]]
The above code seems counting ago, as a word of length 4 instead of 3 due to comma.
Requesting help for correct usage of StringSplit function that takes into account adjusting comma (or other punctuations).
ImageAdd[
Negate[EdgeDetect[Import["https://wolfr.am/EIWL-SW-Image"]]],
Import["https://wolfr.am/EIWL-SW-Image"]
]
I have a family of graphs, and I only need to see that an automorphism exists which contains a specific single vertex mapping, for example [1->96], to see that the entire graph is vertex-transitive. Is there a way to restrict the search based on this? I’ve tried somethings but nothing has run faster than just checking with VertexTransitiveGraphQ.
I have about 1.2 million points in [1,2]^2. I lay down about 250000 of them in red, another 200 thousand of them in slightly less red, and so on, putting dozen dozens in blue, and several purple (30 different colors, each color has fewer points as we fade throught the rainbow from red to purple). This creates a stunning graphic, but its 100MB+ when I save it. After compressing in Adobe, it's still 40MB.
Presumably, the size is because each point is being stored with its color, even though most of them are not visible since other points get plotted on top of them.
My question is how to compress the plot.
One approach is to save it as a jpg, which is certainly compressed but behaves horribly when people zoom in.
I am trying to plot t for value l starting from 0.0001 to 0.001.
I've been trying various methods for past few hours and I either get tag list error, the value is too small, " is too small to represent as a normalized machine number" error and such.
I guessing the issue is that my values are very small that it approximates as 0, or just my codes are trash. probably both.
T = ((16*3*(v-3))/25)*E^(-2*k*1)
k = Sqrt[(2*9.109*(10^-31)*(v-3))/((1.055*(10^-34))^2)]
Plot[T,{v,4,20},FrameLabel->{"L[nm]",T},PlotPoints->10000,MaxRecursion->15,Mesh->All,ImageSize->Full,PlotRange->Automatic]
Hello,
I find that the default font in Mathematica is not very pretty and is not very pleasant to use. For example, the width of the bars in the equal sign is not the same.
Am I the only one who is bothered by this? And if not, what font do you use?
I’m using mathematica to write notes for some classes and hw in others, and when I try to use the control commands for inserting subscript, superscript, fractions, etc. if it is the first instance it creates an equation box (which is perfect) but it forces my screen to the nearest subsection cell, which I use to label lectures or questions.
It’s normally not a huge problem but when the thing is 8 pages long and I have to write a lot of separate things between equations, it becomes a major PITA.
Does anyone have any ideas on how to turn this off?? I’ve tried searching so many things and no one talks about it.
#^2&[{1,2,3,4,5}]
#^2& /@{1,2,3,4,5}
I understand a similar problem can be solved in many ways in Wolfram.
If I interpret correctly first one is an example without using mapping. The syntax here is to use square bracket and then curly braces for list.
In the second example with mapping /@, no need to use square bracket and curly brace as part of list ensures each element of the list iterated.
Without label, this is the code:
Manipulate[
ColorData["Rainbow"][#] & /@ Rescale[Range[1, n], {1, n}, {0, 1}],
{n, 5, 50, 1}
]
With label in slider:
Manipulate[
ColorData["Rainbow"][#] & /@ Rescale[Range[1, n], {1, n}, {0, 1}],
{{n, 5, "Number of Hues"}, 5, 50, 1}
]
It is difficult for me to figure out this part:
{n, 5, "Number of Hues"}
5 is the beginning of the slider which is already mentioned as 5, 50, 1. So why 5 is once again placed within {n, 5, "Number of Hues"}.
Competify Hub provides high quality problems monthly for the reddit server, we will provide the solution in the next month's post.
October POTM Solution: 65/8. Let H and O be the orthocenter and circumcenter of ∆ABC, respectively. Since H is one of the foci, O must be the other focus because H and O are isogonal conjugates. Now, let H’ be the reflection of H over BC. It is well-known that H’ lies on the circumcircle of ∆ABC, so the length of the major axis is OH’ = (13)(14)(15)/(4[ABC]). The semiperimeter of ∆ABC is (13 + 14 + 15)/2 = 42/2 = 21, so by Heron’s Formula, we get [ABC] = √(21 * (21 - 13) * (21 - 14) * (21 - 15)) = √(21 * 8 * 7 * 6) = 84. Thus, the length of the major axis is (13)(14)(15)/(4 * 84) = 65/8.
November POTM If A is a point on the graph of y = x^2 and B is a point on the graph of y = 2x - 5, find the minimum possible distance from A to B. Express your answer as a common fraction in simplest radical form.
If you are interested in discussing about math in general, free math competition resources or competing in international competitions check out our website (https://competifyhub.com/) or discord server here: https://discord.gg/UAMTuU9d8Z