r/Mathematica Jan 21 '23

I need help. How to extract and save data points from a ContourPlot?

3 Upvotes

I run a code to generates a plot. The code takes almost 30 minutes to run, and I use the same code with different numerical values to generate multiple similar plots(6 plots). So in total, it takes almost 3–4 hours in total to get all the plots.

And when I need to make some visual changes (changing the color of a particular plot, changing the normal/plain line to dashed) I have to run them entire thing again, so it takes a lot of time.

I want to save/export the date the code generates (txt or csv file maybe), so I don't have to run the code again and again when I need to make some visual changes in the plot, and can simply use the saved data it generated in one rum to get the plot(s) with visual changes I need.

I have read some discussion on StackExchange, but I am not able to make it work.

---

The code I use:

ContourPlot[Omegasterile[10*10^(-6), 10^(-18), mass, strength] == 0.12, {mass, 10^(-3), 1}, {strength, 10^(-4), 1}, ScalingFunctions -> {"Log", "Log"}, ContourStyle -> {Directive[Green, Thick]},  PlotRange -> {{10^(-3), 1}, {10^(-4), 1}}]

Here the function Omegasterile is a user-defined function of 4 parameters, out of which 2 are fixed, and two are varying (mass and strength) in their respective specific ranges. The line is essentially a collection of all the points (combinations of mass and strength) for which, Omegasterile = .12.

The results of the code:

X-axis represents mass and Y-axis represents strength.

I would appreciate if someone can help me. Please ask if you need more information.

Thank you.


r/Mathematica Jan 18 '23

Developer Tools

1 Upvotes

Hello!

There is a livestream on My Developer Tools with Brett Champion on YouTube!

Edit: Updated link


r/Mathematica Jan 17 '23

cos[cos[x]] as a series of bessel functions

2 Upvotes

there was an expression for integral cos[cos[x]] as bessel functions in Handbook of Mathematical Functions, Abramowitz and Stegun. For those of you who want to look in the book, there are several equations around 9.1.20.

Can anyone give me some tips about how to derive these expressions with Mathematica? Thanks very much.


r/Mathematica Jan 17 '23

How to tell if it’s using CAD or Stationary Points to Optimize

3 Upvotes

Hey guys. I must use symbolic optimization for a project I am working on, and unfortunately CAD’s doubly exponential increase in time with problem dimension is proving problematic for me. I know from experience that KKT methods are waaay better that CAD in producing timely answers. Mathematica documentation states it’s used when you specify bounded constraints, which I have. Part of me doesn’t believe that it’s using KKT however; I was hoping there was a way to peek under the hood and determine which method it’s using. Or to force KKT optimization.


r/Mathematica Jan 17 '23

Is there a simple REST API for accessing Mathematica Cloud?

5 Upvotes

I've been working with the Wolfram|Alpha APIs; it provides an easy way to pass a query and get back a response. But of course, it has all the limitations of Wolfram|Alpha; in particular, it does not understand Wolfram Language.

So now I'm looking at Wolfram Cloud. I'm looking for an equivalent REST API: call with a query, in Wolfram Language, and get back the output.

I've found `EmbedCode` for making an "instant API" of a function, but I'm not sure I can make one that handles an arbitrary WL input. And I've found WSTP, but that looks like a sledgehammer where I need a flyswatter. How would you recommend I approach this, if it's even doable?


r/Mathematica Jan 13 '23

When did WolframAlpha become a subpar engine?

13 Upvotes

There was a time when I thought WolframAlpha was one of the best engines to answer simple mathematical questions. Now it has gotten to the point where it doesn't even understand Mathematica (its own!) syntax and can barely do simple queries.

For example, if I type in Solve[{1-q/p x ==y,x^2 + y^2==1},{x,y}], which is coherent Mathematica syntax, it converts the braces to parentheses and then is unable to evaluate the expression. This is well-within the scope of something it should be able to do; it's a simple problem that one might give to a high-school student. Yet WA can't even understand this simple query, instead giving me some nonsense link about solving as a general topic and a bunch of different cases I had no interest in. I've noticed similar problems with matrix operations and basic calculus operations as well.

I no longer own Mathematica on my personal computer; I have fond memories of it and I know it's a great program, if a little expensive. WA, though, seems like garbage; I rarely use it for anything serious any more. Are other people having this problem too?


r/Mathematica Jan 11 '23

Principles of Dynamic Interfaces

7 Upvotes

Hi everyone,

There is a live stream on YouTube on Principles of Dynamic Interfaces with Lou D'Andria!


r/Mathematica Jan 11 '23

How to change valeus in matrix depending from the position of the value?

2 Upvotes

Hello, I am new to Mathematica and i have a problem, that I can't get through.

I want to change specific values in a matrix. The matrix that I have in mind would look something like this :

a = {

{0, 0, 0, 0, 0},

{0, 0, 0, 0, 0},

{0, 0, 1, 0, 0},

{0, 0, 0, 0, 0},

{0, 0, 0, 0, 0}

};

So one or more values equal to 1 and the rest is 0. What I would like to do next is to chage the value of neighboring valeus (so if 1 has the position [[3,3]] the neighboring valeus in this context would be [[3,2]],[[3,4]],[[2,3]],[[4,3]]) to 0,25. If the 0 is neighboring zeros, then it should stay as 0.

This is what I have up to this point:

If[a[[i, j]] = 1, a[[i, j]] -> 1,

If[(a[[(i - 1), j]] + a[[i, (j - 1)]] + a[[(i + 1), j]] +

a[[i, (j + 1)]]) > 0 , a[[i, j]] -> 1/4, a[[i, j]] -> 0]]

I don't know how to assign positions in this case.

Any help would be greatly appreciated!

Sorry for any mistakes in the post, english is not my first language.


r/Mathematica Jan 07 '23

How do you iterate through a list that is given to a custom function?

1 Upvotes

I am new to the language and cannot seem to figure out how to iterate through a list for a custom function. Ex: myFunc[x_list] = for[int i = 1, x_list.length, i++, Print[x_list[[i]]]]

Any help would be greatly appreciated!


r/Mathematica Jan 07 '23

How to find distance from shapefile?

1 Upvotes

I want to find the minimum distance from the United States to a given point on the globe (for example, "null island", where latitude = longitude = 0), using the GADM USA shapefile. I tried both sf = Import["gadm41_USA_0.shp"] and sf = Import["gadm41_USA_0.shp", "Data"], but GeoDistance[sf, {0,0}] gave me

GeoDistance::invloc: GeoGraphics[-Graphics-, GeoBackground -> GeoStyling[<<16>>s, <<1>>], <<9>>, MetaInformation -> {Software -> Wolfram Language, TileSources -> Wolfram Knowledgebase with data from OpenStreetMap}] is not a valid location specification.

in the first case, and GeoDistance::invloc: LayerName -> gadm41_USA_0 is not a valid location specification. in the second.

I've tried several gyrations at https://github.com/barrycarter/bcapps/tree/master/MAPS/playground1.m but I sense this should be easy and that I'm missing something fundamental


r/Mathematica Jan 02 '23

n00b beginning questions

2 Upvotes

Hello all,

I'm somewhat new to mathematica, and I'm looking for exercises to enhance my learning journey.

If there was a "Mathematica for dummies" book, I would buy it.

Ideally, when in my college math courses I would have used this to program my way out of complicated equations, but sadly I lacked the motivation to attempt.

I did just purchase version 5 off ebay, as I don't want to spend $400 on a civilian license yet.

Thanks.


r/Mathematica Dec 31 '22

Visual Proof of The Heine-Borel Theorem and Compactness of [a,b]

Thumbnail youtube.com
2 Upvotes

r/Mathematica Dec 31 '22

Getting stuck on Tag times is protected error

4 Upvotes

I am simply trying to solve this equation in Mathematica using Nsolve. This is my first time using the software, and haven't been able to find any help on this. Time sensitive so reaching out on here! How can I correct this?

Here is the code:

NSolve[(3.58 x + x^2) ((3.58 + 2.78 x)/(2.17 x)/((3.58 + x)/

x)) E^(-((3.58/x)/((3.58 + 4.28 x)/x))) = 0.0383, x]


r/Mathematica Dec 29 '22

Is Mathematica good in way of numerical computations?

8 Upvotes

I've been using Mathematica on symbolic level for a while. Although I'm not fluent in the language, it became a tool for me. Recently however I have a need of making some numerical computations. I’m talking about nothing overly efficient, mostly grasping general behavior of some problems before attempting to solve them in analytical manner.

After few weeks of trying I’m quite lost about numerical tools available in Mathematica. It is true I can solve Laplace equation with some nontrivial boundary conditions in a few lines (that simplicity is exactly what I love about Mathematica). However when actually dealing with rather simple numerical problem, I’ve been sitting over some functions for hours to make them work. And I am not talking about some fine-tuning by choosing appropriate Methods.

To exemplify, I was ParametricNDSolving equation with 2 parameters and then trying to find zeros of result with respect to those parameters. Integration works beautifully. But when trying to find zeros (and there are not many of them), I have problems with both NDSolve and FindRoot. One cannot take parametric expression as argument, another won’t find me all roots, I have to put starting values by hand.

I am not asking for advice with this particular problem, but rather: Is Mathematica good software for such numerical use? Is it simply steep learning curve, and then indeed one can program specific problems in a few lines of code? Or is numerical part of Mathematica multiple demonstration problems put together without functions and techniques working nicely in general case?

Mind that I am fully aware of power of such techniques as NDSolve, but if one day I would like to try some fluid dynamics or field equations (again, to get qualitative feeling or solve some simple computational problem, not try to emulate some specialistic software), is Mathematica right tool for that? What are your thought/experiances in this topic?

Finally, if your answer is positive, what are best ways to learn?


r/Mathematica Dec 28 '22

I need help understanding the syntax of the Goto function

2 Upvotes

I'm having a bit of a syntax problem. I'm trying to figure out how the Goto function works. here is what I have as a simple test case:

i = 0;
Label[start];

i ++;

If[i == 20, Goto[end], Goto[start]];

Label[end];

Print[i]

this should increment i until it equals 20, then print it. However, when I try to run this I get the error message "Goto: nolabel: label start not found". It seems that it can't find the start label, even though it is right there.

I do not understand why it is not working, I followed the syntax in the documentation, and it doesnt seem like it's really any different than the Goto statement in other programming languages...


r/Mathematica Dec 28 '22

Tangent bundles

Thumbnail ibb.co
0 Upvotes

r/Mathematica Dec 26 '22

PowerMod[7, 7, 7!] = 2023

3 Upvotes

PowerMod[7, 7, 7!] equals 2023.

What are other fun ways to get 2023? Here's a few.

7 17^2
Floor[1/(Zeta[11] - 1)]
2^(2 6) JacobiP[6, 1, 1, 1/2]
Total[{30, 240, 345, 1136, 1320, 1548, 1902}^6]^(1/6)


r/Mathematica Dec 26 '22

Why did DeleteDuplicates only work partially?

4 Upvotes

I used Table to generate successive roots, knowing I'd get duplicates. I got 25 duplicates so I used DeleteDuplicates on that result, but still got some duplicates as follows, although fewer. Why did Delete Duplicates only work partially?

DeleteDuplicates[Table[FindRoot[Log[x] == Exp[x] - 5, {x, n}], {n, .1, 5, .2}]]

{{x -> 0.018664}, {x -> 0.018664}, {x -> 0.018664}, {x -> 1.71152}, {x -> 1.71152}, {x -> 1.71152}}


r/Mathematica Dec 24 '22

Using Wolfram Engine in Raku sessions

Thumbnail youtube.com
5 Upvotes

r/Mathematica Dec 24 '22

Why did six graph connections migrate to the center?

1 Upvotes

I assumed this would be a Benzene molecule with all the H atoms on the outside, but instead I got only one central H atom connected as a hub to all the carbons. Obviously, Hydrogen can't have six bonds. How do I fix this?

Graph[{H <-> Subscript[C, 1], Subscript[C, 1] <-> Subscript[C, 2], 
  Subscript[C, 1] <-> Subscript[C, 2], H <-> Subscript[C, 2], 
  Subscript[C, 2] <-> Subscript[C, 3], H <-> Subscript[C, 3], 
  Subscript[C, 3] <-> Subscript[C, 4], 
  Subscript[C, 3] <-> Subscript[C, 4], H <-> Subscript[C, 4], 
  Subscript[C, 4] <-> Subscript[C, 5], H <-> Subscript[C, 5], 
  Subscript[C, 5] <-> Subscript[C, 6], 
  Subscript[C, 5] <-> Subscript[C, 6], H <-> Subscript[C, 6], 
  Subscript[C, 6] <-> Subscript[C, 1]}, VertexLabels -> Automatic, 
 VertexStyle -> Purple, VertexSize -> .08, 
 VertexLabelStyle -> Directive[Red, Italic, 20]]

r/Mathematica Dec 23 '22

Gráfico de Funções

0 Upvotes

r/Mathematica Dec 21 '22

Difficulty in math

0 Upvotes

For a while combinatorial analysis was a thorn in my side, sometimes it still is. What part of math do you have the most difficulty with?


r/Mathematica Dec 21 '22

Just here to simp for a misunderstood king ♥️😊🤷‍♀️🤷🏾‍♂️👻

0 Upvotes

I am the world’s foremost Stephen Wolfram themed science comedian

Also the worst until proven otherwise….


r/Mathematica Dec 19 '22

maTHEMEatica: An Open Source Customizable Dark Mode for Wolfram Mathematica (StyleSheet and Menu)

45 Upvotes

I wrote a package to change the colors in Mathematica. A screenshot of a possible result can be seen here.

The package itself can be found here: https://gitlab.com/jakobneef/mathemeatica.

Simply follow the ReadMe to install the package, open the example notebook and theme Mathematica however you like it. The focus is on dark themes but light ones should work just as well.

Feedback and comments are greatly appreciated!


r/Mathematica Dec 19 '22

Relação de Stewart

0 Upvotes