I'm encountering numerical accuracy issues when computing the infinite series: NSum[Sin[Sqrt[k]]/k, {k, 1, ∞}, WorkingPrecision -> 20] Despite setting WorkingPrecision -> 20, Mathematica seems to produce inconsistent or inaccurate results for this slowly convergent series. I've identified several computational errors in the evaluation. Has anyone experienced similar issues with NSum for oscillatory series like this? Are there better approaches or alternative methods to reliably compute such...| Recent Questions - Mathematica Stack Exchange
Hello Wolfram Community, I’m working on a project called "Search Engine Realm" where I want to generate high-quality, realistic images based on detailed textual prompts, similar to text-to-image generation tools. I want to ensure that the main character or subject in my prompts remains visually consistent across different generated scenes, while only the backgrounds or context change. Specifically, I’m looking for: Best practices and built-in functions in Wolfram Language for image synthe...| Recent Questions - Mathematica Stack Exchange
I'm writing a function to split an EmpiricalDistribution into a mixture of unimodal distributions. It works well, returning the result as a MixtureDistribution. Except, when the original distribution is already unimodal, the resulting md=MixtureDistribution[{1}, ...] is automatically simplified to a DataDistribution (which makes sense in general). Can I prevent this somehow, so I can always extract the weights with md[[1]] and the components with md[[2]]? This would be more elegant than havin...| Recent Questions - Mathematica Stack Exchange
Here are two examples with ordinary extensions: Factor[1 + x^4, Extension -> Sqrt[2]] Factor[x^2 + 2 Sqrt[3] x + 3, Extension -> Automatic] --- But what about "generalized" extension? This does not work but maybe someone can see a trick to do the job. Factor[3 + 3 x + 5 x^2 - x^3 + Sqrt[1 + x^2] (3 + x^2 + 2 x^3), Extension -> Sqrt[1 + x^2] Explicit example with known factorization: expr = -8 + 17 x + 11 x^2 + 2 x^3 + 6 x^4 + 2 x^5 + Sqrt[2 + x + 2 x^2] (2 - 7 x + 9 x^2 + x^3 + x^4); f1 = (x^...| Recent Questions - Mathematica Stack Exchange
I wanted to integrate $\phi$ with respect to $\eta$. But Mathematica cannot perform the integration. The problem is with the $\sinh$ function but I could not replace it with any simple function except nonlinear model fit which I don't want to do. Can somebody help to perform the integration by doing, may be, some simplification in $\phi$? phi=-((5 Sqrt[ 3] (5/4 - 3/4 Cos[2 eta]) Sech[Log[3]/ 2] (Sqrt[1 - sinalp^2] Cos[eta] (1/4 - 3/4 Cos[2 eta]) + 1/2 sinalp (-(11/4) - 3/4 Cos[2 eta]) Sin[eta...| Recent Questions - Mathematica Stack Exchange
I'd like multiple smooth histograms on a single set of axes with legends. Legends do not seem to be among the options for SmoothHistogram. So I thought I'd calculate smooth histograms and use Plot. The formula given in the Mathematica documentation uses a k, which appears to be a function. I'd like the PDF version of the histogram. The smooth histograms that I generate using SmoothHistogram look good. Does anyone know the function k used for the PDF flavor of SmoothHistogram, or alternatively...| Recent Questions - Mathematica Stack Exchange
This is a recreational question. At my workplace within the same stairwell there are different steps numbers per floor on certain floors. I have tried to automate counting the steps by binarising the image (Binarize and Dilation, Erosion, DeleteSmallComponents) to minimize lines. ImageLines, ImageCorners and GradientOrientahitionFilter did not yield helpful results (this is most likely my lack of experience and understanding). I have not tried AI queries. I can manually count the steps (as it...| Recent Questions - Mathematica Stack Exchange
According to the document of Dynamic: If the displayed form of Dynamic[expr] is interactively changed or edited, an assignment expr = val is done to give expr the new value val that corresponds to the displayed form. In Details and Options section: Dynamic[expr] is equivalent to Dynamic[expr, (expr = #) &]. But we all know that, we can do something like this: Dynamic[1 + x] x = (* anything *) If Dynamic[1 + x] is equivalent to Dynamic[1 + x, (1 + x = #) &], then the code should cause Set::wri...| Recent Questions - Mathematica Stack Exchange
Here is an example how to use Dynamic inside Manipulate for smooth rotation. But it does not work for the following code. Manipulate[ Show[Graphics3D[Cube[]], ViewPoint -> RotationMatrix[Dynamic@fi, RotationMatrix[Dynamic@fi, {0, 1, 1}] . {0, 0, 1}] . {1.3`, -2.4`, 2.`}], {fi, 0, 2 Pi}] It can be solved by wrapping whole view point expression by Dynamic instead of using Dynamic@fi. Manipulate[ Show[Graphics3D[Cube[]], ViewPoint -> Dynamic[RotationMatrix[fi, RotationMatrix[fi, {0, 1, 1}] . {0,...| Recent Questions - Mathematica Stack Exchange
I am trying to solve the following quartic equation eq = -w^4 + w^3 x Sqrt[1 - ϵ^2] + (w^3 X Sqrt[1 - ϵ^2])/ϵ + w^2 x X ϵ - (w^2 x X)/ϵ + w^2 y^2 ϵ - (w^2 y^2)/ϵ - w^2 ϵ - w^2/ϵ + (w x Sqrt[1 - ϵ^2])/ϵ + w X Sqrt[1 - ϵ^2] - 1 == 0; I know that for $y=0$ this equation can be factorised as (w^2 - w x Sqrt[1 - ϵ^2] + ϵ) (w^2 ϵ - w X Sqrt[1 - ϵ^2] + 1) == 0 so that for $x=X=y=0$, the four solutions are $$|w_{1,2}|^2 = \epsilon , \quad |w_{3,4}|^2 = 1/ \epsilon.$$ However, when I f...| Recent Questions - Mathematica Stack Exchange
I am trying to solve this equation: Solve[ ge r (5 (1 + fro) r^5 (-3 + 2 r) + fe^2 (20 Q^2 r^4 - 2 Q^4 L)) == 0, r] for r and plot it as a scatter point plot in 3D for 3 variables (L,fro,fe) like a contour plot. First to get the solution of r, I used Solve. This is the output: {{r -> Root[-2 fe^2 Q^4 \[Lambda] + 20 fe^2 Q^2 #1^4 + (-15 - 15 fR0) #1^5 + (10 + 10 fR0) #1^6 &, 1]}, {r -> Root[-2 fe^2 Q^4 \[Lambda] + 20 fe^2 Q^2 #1^4 + (-15 - 15 fR0) #1^5 + (10 + 10 fR0) #1^6 &, 2]}, {r -> Root[-...| Recent Questions - Mathematica Stack Exchange
The system of equations is as follows: ub'[x] == I m/x ub[x] + I (1 + (2 xi)/x) vb[x]; vb'[x] == -I m/x vb[x] + I (1 + (2 xi)/x) ub[x]; with initial conditions ub[xin]==1 and vb[xin]==1. An example set of parameters is xin=600xi where xi=3000 and m=1, and the ODES are to be solved from xin to xout=0.1. In order to get the correct physical solution xin has to be far greater than 2xi at the initial moment. Attempting to solve the equations numerically yields a solution with a very high frequenc...| Recent Questions - Mathematica Stack Exchange
For a package, we use ParallelNeeds to make its functions available on all kernels for ParallelMap. For a .m file with function definitions that I load with Get, do I need to do something similar to make the functions available on all kernels, or does Get automatically load them on all kernels?| Recent Questions - Mathematica Stack Exchange
Evaluate the following code and use your mouse to rotate the graphics - it is fluent without any delay. pl = Plot3D[{Sin[x] + Cos[y]}, {x, 0, 2 Pi}, {y, 0, 2 Pi}, PlotPoints -> 300, SphericalRegion -> True] Now rotate the same graphics pl by slider of Manipulate: Manipulate[ Show[pl, ViewPoint -> RotationMatrix[fi, {0, 0, 1}] . {1.3`, -2.4`, 2.`}], {fi, 0, 2 Pi}] We see huge decrease in performance with delays compared to front-end rotation. How to achieve the same performance with Manipulate...| Recent Questions - Mathematica Stack Exchange
I am importing an external CSV file using Import["myfname.csv", "Tabular", HeaderLines -> 1] The first row is a header row, and the first column is named Date. The first column holds dates in the format 08/29/2025. Import gives this column a "String" type. I can convert it after, but I would like it to be a "Date" type at import. There are potentially many columns, so I do not want to specify a type for every column. I know this has to be simple but the documentation and two AIs have failed m...| Recent Questions - Mathematica Stack Exchange
I want to programmatically create a set of variables (each corresponds to an index n, for example: {a1,b1} or {a2,b2}), and subsequently save their values using DumpSave. For example, at n=1, I can manually write: a1 = Range[2]; (*The value can be anything*) b1 = Range[3]; (*The value can be anything*) DumpSave["values1.mx", {a1, b1}]; For another example, at n=2, I can manually write: a2 = Range[5]; (*The value can be anything*) b2 = Range[10]; (*The value can be anything*) DumpSave["values2...| Recent Questions - Mathematica Stack Exchange
I wanted to construct an object based on a pyramid for 3D printing an am stuck on the question how to convert the construction into Mathematica code. The process of construction went along like this, as shown with the top-view of the object: a) defining the number of points of the pyramid: 4 b) defining the height difference between each step c) connecting the bottom-left corner with the bottom-right edge on the next-highest step of the pyramid and moving this point along the diagonal line to...| Recent Questions - Mathematica Stack Exchange
Bug introduced in 14.2 and fixed in 14.3. --- Why is Tabular shifting the date by one day (as documented by the snapshot)? mytable = {{1, x, Today}, {2, y, Tomorrow}} mytabular = Tabular[mytable] Normal[mytabular]| Recent Questions - Mathematica Stack Exchange
In the geometric figure, the point p is the center of a circle and the two angles marked are 20 Degree (converted to radians): GeometricScene[{{a, b, c, p}, {r}}, {CircleThrough[{a, b, c}, p], GeometricAssertion[PlanarAngle[{a, b, p}] == \[Pi] 20/180], GeometricAssertion[PlanarAngle[{a, c, p}] == \[Pi] 20/180], GeometricAssertion[PlanarAngle[{b, p, c}] == r]}]; RandomInstance[%, RandomSeeding -> 500] The angle $\angle bpc$ is fully determined by the geometry and must have angle $80^{\circ}$, ...| Recent Questions - Mathematica Stack Exchange
I am trying to come up with a generic formula for the below integral, which is analogous to the upper incomplete gamma function, Clear[x, t, n]; x1 = FullSimplify[Integrate[(1 + I t)^(-1 - I x) E^(2 \[Pi] I n t) , {t, 0, 1}, Assumptions -> x > 0 && n > 0]] I used assumptions to increase the likelihood of getting a correct answer. It gives me the not so neat function below: But I usually don't blindly trust Mathematica's results, so I tried to validate the formula it gave me, Clear[t]; x = 2; ...| Recent Questions - Mathematica Stack Exchange
I am trying to make a video by generating many images of a process, exporting them to the disk by the Export command in the PNG format, and finally making a video with FFmpeg. My images have a title on the top with the values of the parameters. I optimized the font size of the title. When I show these images in the Mathematica notebook and save them by rightclicking and choosing "Save graphics as", I obtain saved images that look the same as in the Mathematica notebook. However, when I save t...| Recent Questions - Mathematica Stack Exchange
I have a real-valued function of four variables, namely $L[\phi, m0, m1, m2]$. I am interested in taking the partial derivative $\partial_{\phi}L$ thereof and setting the partial derivative to zero, that is $\partial_{\phi}L = 0$. Then solving for $\phi \in [0,2\pi]$ in terms of $m0, m1, m2 \in \mathbb{N}_{0}$. I have reached the point in the attached code where I have generated the partial derivative $\partial_{\phi}L$, but I am having difficulty setting the partial derivative to zero and ge...| Recent Questions - Mathematica Stack Exchange
I have 6 huge expressions I want to integrate. Is there any way to break them piecewise and then send them for integration? Two sample expression are: Expression 1: -((Sqrt[1 - cp^2] Sqrt[1 - cq^2] E^(-((Ep^2 + Eq^2 - 2 m^2)/( 2 \[Sigma]^2))) (Ep - m) (Ep + m) (-Eq + m) (Eq + m) \[Pi]^2 (3 Ep Eq - 2 cp^2 Ep Eq - 2 cq^2 Ep Eq + 3 cp^2 cq^2 Ep Eq + cp^2 Ep m + 2 cq^2 Ep m - 3 cp^2 cq^2 Ep m + 2 cp^2 Eq m + cq^2 Eq m - 3 cp^2 cq^2 Eq m + 3 m^2 - cp^2 m^2 - cq^2 m^2 + 3 cp^2 cq^2 m^2 - 2 cp cq Sq...| Recent Questions - Mathematica Stack Exchange
The differential equations I want to solve is $$ \frac{\partial c_0(t)}{\partial t}=-\frac{1}{2} \kappa c_0(t)-\kappa \sum _{n=1}^N \alpha ^n c_0(t-\text{n$\tau $}) e^{i n \phi _{\tau }} \Theta (t-\text{n$\tau $}) $$ Here $\Theta(t)$ is the step function, $N$ is determined by $N=Integer[\frac{tmax}{\tau}]$. This equation has multipile time delays. By solving this equation, I think there may be chaos in this equation for certain parameters. evofback[\[Tau]_, m_, \[Alpha]_, \[Phi]_, tlist_, cin...| Recent Questions - Mathematica Stack Exchange
After updating to version 13.1 on macOS 12.4, I discovered that the keyboard shortcut for typesetting a fraction (Insert > Typesetting > Fraction) has changed. In previous versions, the shortcut was Ctrl + /, but now is Ctrl + ´. The old shortcut doesn't do anything in 13.1. I tried following this answer to change the keyboard shortcut. To my surprise, line 65 of the file KeyEventTranslations.tr reads Item[KeyEvent["/", Modifiers -> {Control}], "Fraction"], which is just the old shortcut. So...| Recent Questions - Mathematica Stack Exchange
I have about a million 3D points, say data = Table[{1. x, 1. y, 0.}, {x, 1000}, {y, 10^3}]~Flatten~1; I want to visualize them, but Graphics3D@Point@data or ListPointPlot3D@data are too slow. MeshL...| Mathematica Stack Exchange
I suspect that 1.0982 is (close to) the root of a low degree (2 or 4) polynomial with small coefficients. How do I find this polynomial? I tried RootApproximant[1.0982] which gives 5491/5000. This is not what I want.| Recent Questions - Mathematica Stack Exchange
Suppose we have a list and a list of lists of positions to extract from the list. list={a,b,c,d,e,f,g,h,i}; positions={{1,2,3},{5,6,7},{2,5,9}}; result=list[[#]]&/@positions; {{a, b, c}, {e, f, g}, {b, e, i}} Is there a more efficient way to do this?| Recent Questions - Mathematica Stack Exchange
Trying Wolfram 14.3. It was with great surprise I saw the engine cannot symbolically handle Sum with a symbolic upper limit. I’m copying here the response I got from GPT-5. The key beyond this simple case is that I would like a symbolic solution without assuming anything about the format of the expression. Has anyone stumbled on this and successfully overcome it? Solving a Summation Equation for $u$ in $q(u)$ (Wolfram 14.3) Problem Overview We have a function defined by a summation: $q(u)=\...| Recent Questions - Mathematica Stack Exchange
How to convert a Markdown file (or text) into a Mathematica notebook? For example, easy conversion of comprehensive MSE posts is desirable. --- Possible approaches ordered according to their convenience: [ ] Extensions of "pandoc" and/or "jupytext". [ ] Web service that does that. [ ] A Mathematica package that does the conversion. (An inverse of "M2MD".) [X] A stand-alone implementation (in some programming language.) --- This question is an inverse of "How to export a Mathematica notebook i...| Recent Questions - Mathematica Stack Exchange
Is there a way to export a Mathematica notebook into Markdown? I'm sure it's possible to implement rules for converting each Mathematica cell subexpression into Markdown, but I'm also sure that I...| Mathematica Stack Exchange
So I have a displacement function sigx as a function of "t" (time) and sig.pre (pre-stress). At some time "dx": force "fo" goes to 0, and the same displacement functi...| Mathematica Stack Exchange
I have files of data that come with a whole bunch of junk in the beginning before the actual columns of data start. Is there any way to tell Mathematica to start putting the data into a table from ...| Mathematica Stack Exchange
I want to simply use a CDF deploy to export a text file onto the notebook directory CDFDeploy["ExportCDF", SetDirectory[NotebookDirectory[]]; Button["Export", Export["new.txt&| Mathematica Stack Exchange
I have a set of data as follows denvals={{1.*10^-10, 0.0810057333956}, {0.1000000001, 0.0803383352917}, {0.2000000001, 0.0783764221896}, {0.3000000001, 0.0752361768031}, {0.4000000001, 0.| Mathematica Stack Exchange
Why does the following pattern matching not succeed? ClearAll[f]; SetAttributes[f,Orderless]; HoldForm[f[a,d[],b,c]]/.HoldPattern[f[a,d[],b,z_]]:>{z} (* f[a,d[],b,c] *) I expected that because ...| Mathematica Stack Exchange
I'm surprised that I can't find this question already, so perhaps I'm missing something obvious. I would like to take a list of associations and remove any with value "red". I ran into the following| Mathematica Stack Exchange
I have a large number of replacement rules where the right hand side (RHS) is always the same. To avoid repetition, I separated the two sides to add the same RHS to all of them. This is a minimal e...| Mathematica Stack Exchange
Hello I need some help on how to add a list to a list of list. The program would have to do as below: {{0,0}, {0}, {0,0,0}}+{1,2,3,4,5,6} will give {{1,2}, {3}, {4,5,6}}. Could this be done? An...| Mathematica Stack Exchange