Hot answers tagged

10

I can't find any confirmations in the documentation, but through numerical and visual checks I think when at least one input to Mod is not real, we have This definition doesn't equal the definition one would think to have over the reals, so my guess is a piecewise definition is used to modify the function over the real line. Testing mod[z_, n_, d_] := z ...


8

Is there a way to get coordinate of just a particular point? You can convert Line into the corresponding set of Points each of which will be a Button which Prints the coordinates of that Point when you click on it (try this!): plot = BodePlot[1000/((1 + s/10^3)*(1 + s/10^6))]; plot /. Line[pts_] :> Map[Button[Point[#], Print[#]] &, pts, {-2}] ...


7

ClearAll[fuzzyLCS]; fuzzyLCS[strings__List] := Module[ {subsets, aligned, intersections}, subsets = Subsets[strings, {2, Length@strings}]; aligned = Select[SequenceAlignment[#[[1]], #[[2]]], StringQ[#] &] & /@ subsets; intersections = Intersection @@ (Subsets[#, {1, Length@#}] & /@ (Flatten[Characters[#]] & /@ ...


7

Sure, try for example: pr[14709321003111578837870501266345370175409, 2, 2] There are many things in MMA where small cases/edge cases can be done much more quickly with user code, this is one of them. The advantage here is that PowersRepresentation can handle huge cases...


6

Below is an extended comment showing the effects that can happen when one ignores the correlations among parameter estimators (either on purpose or because journal authors or editors don't know enough about statistics to include necessary information). First I create some data with the same curve form as the function CDDHybrid and a set of predictor values ...


5

lists = RandomInteger[10, {20, 3}]; pareto = Internal`ListMin[lists]; Row[{Panel[Grid[lists /. Thread[pareto -> (Style[#, Red, Bold] & /@ # & /@ pareto)]]], ListPointPlot3D[{lists, pareto}, PlotStyle -> {Blue, Red}, ImageSize -> 400, PlotRangePadding -> 1, BoxRatios -> 1, AspectRatio -> 1] /. Point -> (Sphere[#, .5] ...


5

Picking up on Marius tip on Inner in the comments: Inner[Apply[#1, {#2}] &, {{a, b}, {c, d}}, {h, k}] And @ciao offered a better version in comments: Inner[#1[#2] &, {{a, b}, {c, d}}, {h, k}]


5

This is simple enough to do analytically.. assuming l2>l1 you can readily find the transition points and invert each piece of the Piecewise expression: myfuninv[x_, l1_, l2_ /; l2 > l1] = Piecewise[{ {Sqrt[x], x <= l1^2}, {x + l1 - l1^2, l1^2 < x <= l2 + l1^2 - l1}, {Exp[x + l1 - l2 - l1^2] - 1 + l2, l2 + l1^2 - l1 < x}}] Plot[ ...


5

This could be done with a custom function for the first argument of Inner that treats a differently (it's just a more convenient form of expressing your original idea). For example, consider this: ClearAll[f]; f[a, x_] := a[x] f[x_, a] := a[x] f[x_, y_] := x y Now for your first example: Inner[f, {{a, b}, {c, d}}, {h, k}] (* {b k + a[h], c h + d k} *) ...


5

You can do it by using the MessageName operator (::). Here is an example.


5

This does what I think you're after, fiddle with options as desired: With[{a = Interval[1.01 + .18 {-1, 1}], b = Interval[.92 + .11 {-1, 1}], c = Interval[2.2 + .2 {-1, 1}]}, Plot[{Min[a + b*x + c*x^2], 1.01 + .92 x + 2.2 x^2, Max[a + b*x + c*x^2]}, {x, -5, 5}, Filling -> {1 -> {3}}, FillingStyle -> Darker, PlotStyle -> {None, Red, ...


5

Introduction The first thing that I noticed is that the functional form for all of your CDD and LHS functions are identical. I propose that rather than defining six functions for each, we define one function and change the input arguments to cover the various cases. cdd[s_, a_, b_, c_] := 10^(a + b*c - b*s)*Exp[-10^(s - c)] lhs[s_?NumericQ, a_?NumericQ, ...


4

Use BoundaryDiscretizeGraphics, RegionDifference, Select, and MemberQ points1 = CirclePoints[3, 40]; points2 = CirclePoints[1, 40]; {region1, region2} = BoundaryDiscretizeGraphics@*ListCurvePathPlot /@ {points1, points2} region3 = RegionDifference[region1, region2] Show[ RegionPlot@region3, Select[RandomReal[{-5, 5}, {1000, 2}], RegionMember[region3]] ...


4

Plot3D[g[x, y], {x, -5, 5}, {y, -5, 5}, MeshFunctions -> {f[#, #2] &}, Mesh -> {{{0, Directive[Thick, Red]}}}, BoxRatios->1] Plot3D[g[x, y], {x, -5, 5}, {y, -5, 5}, PlotStyle -> None, BoundaryStyle -> None, MeshFunctions -> {f[#, #2] &}, Mesh -> {{{0, Directive[Thick, Red]}}}, BoxRatios->1] cp = ContourPlot[f[x, ...


4

You can see what you get with the body of your function myInvFun over parameter instances: In[215]:= FindRoot[myfun[x, 2, 5] == 2.0, {x, 0}] Out[215]= {x -> 0.} FindRoot::jsing: Encountered a singular Jacobian at the point {x} = {0.}. Try perturbing the initial point(s). >> So, if you change your definition as advised by the message you'll get ...


4

You may start with this, add whatever you need and then remove the unnecessary manipulation parameters: Manipulate[Show[{ Graphics[{Opacity[0.5], Red, Rectangle[{1 + a, c + b}, {2 + a, 4 + b}]}, PlotRange -> {{0, 2}, {-3, 0}}, Axes -> True, AxesOrigin -> {1 + a, c}], Plot[{-(P*x^2/6) (3 - x), -k*x}, {x, 0, 1}, Axes -> ...


4

bp[s_] := 1000/((1 + s/10^3)*(1 + s/10^6)) mybp = BodePlot[bp[s]] Have a look at Short Cases Short[Cases[Normal@mybp, Line[s_] :> s, Infinity], 25] ...


4

Could use Filling -> {4 -> {{1}, LightRed}, 1 -> {{3}, LightBlue}, 3 -> {{6}, LightRed}} and omit FillingStyle. Or Filling -> {1 -> {3}, 4 -> {6}}, FillingStyle -> {{LightBlue, Opacity[0.5]}, {LightRed, Opacity[0.5]}} which respectively produce the plots below.


3

Description The reason why your function doesn't execute as you'd expect is due to it expecting two arguments whilst you pass a single argument of type List containing two elements. Your function views it as hh[{3,4},y_]. Although, x parameter is passed successfully; y parameter is not available. Example: hh[3,4] Output: 7


3

Can use NDSolve to parametrize numerically. f[x_, y_] = x^2 + y^2 - 4; g[x_, y_] = x^2 - 3*y^2; pt = {2, 0}; xyvals = NDSolveValue[ Flatten[{D[f[x[t], y[t]], t] == 0, x'[t]^2 + y'[t]^2 == 1, Thread[{x[0], y[0]} == pt]}], {x[t], y[t]}, {t, 0, 11}]; (If you want to see the better part of a circle, do ParametricPlot[xyvals, {t, 0, 11}, AspectRatio ...


3

It doesn't do anything, it just formats in a certain way. You can assign your own definition if you like. References: Operators without builtin meanings


3

According to this MathGroup post the function SpaceForm was documented only via Information (i.e. the SpaceForm::usage Message) even in Mathematica 3.0. With current version 10.4.1 the situation is still the same: ? SpaceForm SpaceForm[n] prints as n spaces. So you shouldn't worry: this function is in the current situation right from the start, ...


3

Using Cases[] plot = BodePlot[1000/((1 + s/10^3)*(1 + s/10^6))] Cases[plot, Line[x___] :> x, Infinity] (*two group of data*)


2

Just for reference, the sum depicted in the OP has a representation in terms of the $q$-hypergeometric function. In particular, $$\sum_{n=0}^{\infty}\frac{(-1)^nq^{6n^2}}{(q^3;q^3)_n(-q;q)_{3n}}={}_1\phi_4\left({{0}\atop{-q,-q^2,-q^3,0}}\mid q^3,-q^6\right)$$ Compare: Series[QHypergeometricPFQ[{0}, {-q, -q^2, -q^3, 0}, q^3, -q^6], {q, 0, 15}] 1 - q^6 + ...


2

I learned a lot from WReach's and Leonid's answers and I'd like to make a small contribution: It seems worth emphasizing that the primary intention of the list-valued second argument of Flatten is merely to flatten certain levels of lists (as WReach mentions in his List Flattening section). Using Flatten as a ragged Transpose seems like a side-effect of ...


2

f = OpenWrite["test.txt"]; nsp[n_] := OutputForm[StringJoin[ConstantArray[" ", n]]] Write[f, 1, nsp[3], 2, nsp[1], 3]; Close[f] FilePrint["test.txt"] 1 2 3


2

u[x1_, x2_] = Log[x1] + 2*Log[x2]; cp = ContourPlot[u[x1, x2], {x1, 0, 10}, {x2, 0, 10}, PlotPoints -> 100] Solve for x2 along the contours f[x1_, c_] = x2 /. Solve[c == u[x1, x2], x2, Reals][[1]] (* E^(c/2)/Sqrt[x1] *) Plot the contours plt = Plot[ Evaluate[ Table[ Tooltip[f[x1, c], c], {c, -2, 6, 2}]], {x1, 0, 10}, PlotRange ...


2

The following uses NDSolve to construct interpolations along lines in the domain. We then construct an interpolation between the solutions to NDSolve, which represents a as a function of l1 and l2. {dadl1, dadl2} = grad = PiecewiseExpand /@ (-D[myfun[a, l1, l2], {{l1, l2}}]/ D[myfun[a, l1, l2], a]) /. ComplexInfinity -> 0 // Quiet; sols = ...


2

General Inversion You can use FindRoot to do a general inversion of a Piecewise function. The strategy will be to extract the smooth continuous function from the piecewise function and use that as input to FindRoot. Below is a copy of your function: myfun[a_, l1_, l2_] = Piecewise[{ {a^2, a < l1}, {a - l1 + l1^2, a >= l1 && a ...


2

To the best of my knowledge, the answer to your question is simply: no. Meta comments: I don't think your question ought to be closed as "out of scope", since you are not actually asking for anyone to write the function for you. My suggestion would be to write the function yourself and edit the question to include your attempt, making the focus of the ...



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