Tag Info

Hot answers tagged

13

The separation-of-variables solution you quoted has two indices appearing in it: n and j (the subscripts of the coefficient $A_{nj}$). Here, n is azimuthal mode order, i.e. it counts the number of nodes along the direction in which the polar-angle $\theta$ varies (divided by 2). The index j is needed because the wave is supposed to satisfy the boundary ...


13

RegionFunction is the option you are looking for. ContourPlot[ Evaluate[Sum[Sin[RandomReal[5, 2].{x, y}], {5}]], {x, -3, 3}, {y, -3, 3}, BoundaryStyle -> {Thick, Black}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 9] ]


12

I had the same problem after switching to Mathematica 10. The issue here is the following: Export uses Rasterize to create the png image. The StyleEnvironement, which is used in Rasterized, cannot be specified as an option but is given by the $FrontEnd object (not by the EvaluatingNotebook[]!). You can change the StyleEnvironement by SetOptions[$FrontEnd, ...


11

This is an intentional change to make PlotLegends -> "Expressions" more consistent with PlotLegends -> Automatic. Both now do not produce legends when only one line is present. What you are looking for is PlotLegends -> "AllExpressions" which has the old behavior, e.g. Plot[x, {x, 0, 1}, PlotLegends -> "AllExpressions"] More generally, ...


10

General approach If {x0, y0} is a root of a polynomial system {p1, p2} such that there is no other root of the form {x0, y1}, the multiplicity is given by the multiplicity of the zero x0 of the resultant Resultant[p1, p2, y] We can compute the multiplicity of this zero with SparseArray[ CoefficientList[Resultant[p1, p2, y] /. x -> x0 + u, u] ...


9

You can explicitly see that the degree of intersection at (0,0) is 6 using: p1 = y - x^3; p2 = y^4 + 6 x^3 y + x^8; Factor[p2 /. y -> x^3] Also revealing is: Factor@GroebnerBasis[{p1, p2}, {y, x}] Giving {x^6 (x^6+x^2+6), y-x^3} This result is connected to Bezout's Theorem (covered in your textbook).


9

Update Almost ten times faster again, or about 90 times faster than the OP's way (0.069 sec v. 5.46 sec): For the second integral, we can find its derivative with respect to x and then integrate with NDSolve. The derivative of the integral has two components, one from differentiating under the integral sign dxdz1 and one from plugging in the limit of ...


9

Update 2: A function to generate tori: toroidalF[n_, h_: (1/4), w_: (1/2), opts : OptionsPattern[]] := Module[{top, bottom, verts, outer = {Cos[#], Sin[#], 0} & /@ Range[0, 2 Pi, 2 Pi/n], faceverts = Flatten[#[[{1, 2, 4, 3}]] & /@ # & /@ (Join @@@ Subsets[#, {2}] & /@ ...


9

I agree with beli that an answer is desriable, with mfvonh that closing of questions is a bit out of control, and with m_goldberg that Prolog should be used. I'd happily wait for m_goldberg to post an answer but, since there's 4 close votes already, here's a simple example of the difference between Epilog and Prolog. The difference, of course, is that ...


9

Your question is a little vague but one possible mapping from a square to a circle is the following. This transformation wrapped into a Mathematica function: transformation[points_] := {#[[1]] Sqrt[1 - (#[[2]]^2/2)], #[[2]] Sqrt[1 - (#[[1]]^2/2)]} & /@ # & /@ points; And a little demonstration: points = Table[{a, b}, {a, -1, 1, 0.2}, ...


9

Edit Here is a version that avoids the use of Inset and instead uses Overlay. I think this version covers all of the OPs requests. I have not tried to functionalize the code at this point since there will likely be some tweaking of parameters based on the actual functions plotted. optsall = {Axes -> False, Frame -> True, ImageSize -> 600, ...


8

Download the data (csv file) from U.S. Energy Information Administration; http://www.eia.gov/countries/country-data.cfm?fips=uk data = Import[ "/Users/hanlonr/Downloads/United_Kingdom_proved_Reserves_(1980-2014).csv"];\ ListLinePlot[data[[5 ;; -6]], Frame -> True, Axes -> False, PlotRange -> All, PlotLabel -> StringReplace[data[[1, ...


8

data = Reverse@Table[{2^n, 1}, {n, 1, 6}]; Graph[Table[DirectedEdge[i, i + 1], {i, Length@data - 1}], VertexLabels -> "Name", VertexCoordinates -> ({#2 Cos[#1], #2 Sin[#1]} & @@@ data), Axes -> True, ImageSize -> 300]


8

Count[Solve[y^4 + 6 x^3*y + x^8 == 0 /. {y -> x^3}], {x -> 0}] (* 6 *)


8

I could not get it to work with $FrontEnd, but setting the ScreenStyleEnvironment on $FrontEndSession worked for me. Here text cells get two different backgrounds and font sizes, depending on the environment. ("Printout" is pink and large.) sseOpt = Options[$FrontEndSession, ScreenStyleEnvironment]; SetOptions[$FrontEndSession, ScreenStyleEnvironment ...


8

An alternative to RegionFunction is ConditionalExpression. Using @paw's cool example z = Sum[Sin[RandomReal[5, 2].{x, y}], {5}]; ContourPlot[Evaluate[ConditionalExpression[z,Norm[{x, y}, 2] < 3]], {x, -3, 3}, {y, -3, 3}, BoundaryStyle -> {Thick, Black}] ContourPlot[Evaluate[ConditionalExpression[z, z Norm[{x, y}] < 3]], {x, -3, ...


8

As noted by Eldo, this works out of the box on Mathematica 10. On Mathematica 9 LineLegend does the trick: data2 = {{2, 1}, {3, 4}, {3.5, 4.2}, {4, 6}}; data1 = {{2, 1}, {3, 4}, {3.5, 4.2}, {4, 6}, {4.5, 6.6}, {5, 7}, {6, 9}, {8, 11}}; ListPlot[ {data1, data2}, Joined -> True, PlotStyle -> {Dotted, Dashing[Large]}, PlotLegends -> ...


7

Not sure how robust it is, but the following seems to work for PlotRange: ClearAll[plt]; plt = Plot[Sin[x], {x, 0, 3 Pi}, PlotRange -> Automatic, PlotLabel -> Dynamic@("PlotRange is " <> ToString@PlotRange[plt])] and ClearAll[plt1]; plt1 = Plot[Sin[x], {x, 0, 3 Pi}, PlotRange -> Automatic, PlotLabel -> ...


7

An alternative syntax for Contours that combine contours and styles: cntrplt[expr_, arg1_, arg2_, contours : {{_, _} ..}, opts : OptionsPattern[]] := ContourPlot[expr, arg1, arg2, Contours -> Join @@ Thread /@ contours, opts]; Using @rhermans' example: cntrplt[1 - Exp[-x - y], {x, 0, 2}, {y, 0, 2}, {{Range[0, .9, 1/10], Thick}, ...


7

Something like this? ContourPlot[ 1 - Exp[-x - y] , {x, 0, 2} , {y, 0, 2} , PlotRange -> {0, 1} , Contours -> Join[Range[0, 0.9, 0.1], Range[0.9, 1, 1/100]] , ContourStyle -> Join[Table[Thick, {10}], Table[Thin, {9}]] ] EDIT: About the follow-up question, the function should look like this: ContourPlot[ ueislexpl[0.1, 5, n1, n2] ...


7

You can Partition the data into pairs of successive values. Reverse the data to make the previous day the dependent variable. Examples: Partition[{1, 2, 3, 4, 5}, 2, 1] (* {{1, 2}, {2, 3}, {3, 4}, {4, 5}} *) Partition[Reverse@{1, 2, 3, 4, 5}, 2, 1] (* {{5, 4}, {4, 3}, {3, 2}, {2, 1}} *) Reverse /@ Partition[{1, 2, 3, 4, 5}, 2, 1] (* {{2, 1}, {3, 2}, {4, ...


7

This is not an answer, but is too long for a comment. NSolve produces different results for NSolve[{y^4 + 6 x^3*y + x^8 == 0, y - x^3 == 0}, {x, y}, Reals] according to the Mathematica version it is evaluated in. In V9, it produces {{x -> 0, y -> 0}} while in V10 it produces {{x -> 0., y -> 0.}, {x -> 0., y -> 0.}, {x -> 0., ...


7

The problem is your range is too large for the plot. But as suggested by @kguler you can increase PlotPoints Plot[x && 0 <= x <= (1/8), {x, -9, 9}, PlotPoints -> 100]


7

Another alternative is to use ConditionalExpression using the second-order condition for a local maximum as the second argument: f = Sin; Plot[f[x], {x, 0, 20 Pi}, Mesh -> {{0}}, MeshFunctions -> {ConditionalExpression[f'[#], f''[#] < 0] &}, MeshStyle -> {PointSize[Large], Red}] f = Sin[#] - 1/2 Cos[Pi #] &; ...


7

Your plot is not symmetric since your plot has an AspectRatio of 1 while it should be 4/3. This also helps the problem with the cusp not going all the way to the boundary. I also made your boundary a bit cleaner. [...] boundary = Show[Graphics[{Black, Thick, Dashed, Line[#]}] & /@ Permutations[ {{0, Sqrt[6]/3}, {-(1/Sqrt[2]), -Sqrt[6]/6}, ...


6

A quick-and-dirty way: get the contours for the .0000001st and .9999999th quantiles as approximations for min and max dp = DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}]; cp1 = ContourPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}, ContourShading -> None, ContourStyle -> {Directive[Red, Thick], Directive[Orange, Thick]}, ...


6

In version 10 the PointSize of the legend will automatically match the PointSize of the Plot: ListPlot[Table[RandomReal[NormalDistribution[], {20, 2}], {2}], PlotLegends -> {"a", "b"}, PlotStyle -> PointSize[0.02]] Edit: The answer by @eldo made me realize, that this is only true up to a PointSize that is equal to the default ...


6

The answer is 0, if the question is what is the value of Mean[fit["FitResiduals"]] and fit is a linear, least-squares fitted model. data = WeatherData["London", "Temperature", {{2004, 1, 1}, {2013, 12, 31}, "Day"}]; normaldata = Partition[Reverse[data["Values"][[All, 1]]], 2, 1]; fit = LinearModelFit[SetPrecision[normaldata, Infinity], x, x, ...


6

MeshFunctions, according to the documentation, "should normally be chosen to be continuous monotonic functions." Failing that, the mesh functions should be transverse to the mesh levels (i.e., cross them, not have a local extremum); in this case, however, one might have trouble with sampling missing a small region where the mesh function very briefly ...


6

Make rotate transform like this. And change some options of ListPolarPlot. I modified the PolarTicks option. rotatePolar[a_List] := Module[{l = Length[a]}, Table[{2 Pi*(i - 1)/l + Pi/2, a[[i]]}, {i, l}] ] ListPolarPlot[rotatePolar[Reverse[Range[20]]], PolarAxes -> True, PolarAxesOrigin -> {Pi/2, 20}, PolarTicks -> {Drop[ Table[{i, Mod[i ...



Only top voted, non community-wiki answers of a minimum length are eligible