Tag Info

New answers tagged

2

Using ListPlot3D with Mesh: data = Table[{i, j, Sin[j^2 + i]}, {j, 0, 2 Pi, 2 Pi/11}, {i, 0, 2 Pi, 2 Pi/24}]; Dimensions[data] (* {12, 25, 3} *) colors = Directive[Thick, #] & /@ ColorData["Rainbow"] /@ Range[0, 1, 1/11]; lp3d = ListPlot3D[Join @@ data, PlotStyle -> Opacity[0.3], BoundaryStyle -> None, Mesh -> {0, Thread[{Range[0, 2 Pi, 2 ...


1

The reason is that you have an inefficient inner loop when you use myBBBlik. Every time you call myBBBlik, it takes a certain amount of time to calculate the result (on my computer, about 1/2 second of mucking around because your likelhood function is a bit complex). But myBBBlik2 creates an algebraic expression once (?or twice?) and can substitute the ...


1

The curve in the Question, or more precisely the upper half of it, also can be obtained using InverseFunction Plot[InverseFunction[rd, 2, 2][x, 2.], {x, -3, 3}, PlotRange -> {0, 3}, AxesLabel -> {x, y}] Unfortunately, attempting to find the discontinuity in the slope by direct computation is both slow and noisy. Plot[D[InverseFunction[rd, 2, ...


1

I expect you are after something more general, but for this case we can analyze the lines generated by contourplot: (I dont have RegionDistance but this should be the same ) rd[x_?NumericQ, y_?NumericQ] := Min[EuclideanDistance[{x, y}, #] & /@ {{-1, 0}, {1, 0}}]; points = List @@ First@Cases[ Normal@First@ Cases[ ContourPlot[ ...


2

To elaborate on my Comment (and assuming uniform spacing of the data), consider the toy problem in 1-D: f = Table[Sin[2 Pi ( i - .5)/10], {i, 10}] Generating an InterpolatingFunction and then using NIntegrate yields: g = Interpolation[f] NIntegrate[g[x], {x, 1, 10}] (* 3.3306690738754696*^-16 *) Simply forming the Total yields the same result to ...


9

As was pointed out above, this is a good summary of Mathematica's constrained optimization methods. Read through this if you want to know a lot more. A quick answer is below: The answer to your question is strongly dependent on the function you want to maximize. Convex functions can be maximized quite easily, with the error controlled by the PrecisionGoal ...


0

This can be handled by Solve straightforwardly: r = RandomInteger[{-10, 10}, {2, 2}]; a = {{a1, 0}, {0, a2}}; b = {{b1, b2}, {b1, b2}}; c = {{c1, c1}, {c2, c2}}; Solve[r.a + b == c, {a1, a2, b1, b2, c1, c2}] {{a2 -> 18 a1, b2 -> -45 a1 + b1, c1 -> -9 a1 + b1, c2 -> 9 a1 + b1}} You can interpret this as saying that for any a1 and b1, the other ...


2

X = RandomReal[1, {194, 32}]; With[{arr = ArrayFlatten[{{0.0, -Total[Outer[Plus, X, -X, 1]^2, {3}]}}]}, k[sigma_] := Exp[arr/(2 sigma^2)]] AbsoluteTiming[Do[k[s], {s, 1, 1000}]] (* {0.257026, Null} *)


1

Create the matrix once, substitute sigma... (* fake some data *) X = N@RandomInteger[{1, 10}, {194, 32}]; array = ArrayFlatten[{{1, E^(1/(2 sigma^2) Map[Tr, -(Outer[Subtract, X, X, 1]^2), {2}])}}]; //Timing (* do new for sigma 1 to 20 *) sigs = Table[Replace[array, sigma -> N@sig, {5}], {sig, 1, 20}]; // Timing (* op method *) (* ...


3

Change the method used by NIntegrate: pdf[s_?NumericQ] := combn NIntegrate[ N[q^k (1 - q)^(n - k), 100] (E^(4 n q s) (1 - q)^(-1 + 4 n \[Mu]) q^(-1 + 4 n \[Nu]))/ NIntegrate[ E^(4 n q s) (1 - q)^(-1 + 4 n \[Mu]) q^(-1 + 4 n \[Nu]), {q, 1/(2 n + 1), 1 - 1/(2 n + 1)}, MaxRecursion -> 12, Method -> ...


4

Not an answer at all but some insight. Let's first define two global variables we will use for looking at how fast your integral is evaluated: calledIntegrate = 0; evalStep = 0; Now, let me redefine your target function by compiling the integrand to make it faster. Additionally, we will increase calledIntegrate on each call: With[{ cf = Compile[{{q, ...


1

Far from what the OP asked... Crude table based linear interpolation approach to learning more about the PDF: n = 25000; k = 24991; \[Mu] = 10^-4; \[Nu] = 10^-4; q = k/n; combn = Binomial[n, k]; pdf[s_?NumericQ] := combn NIntegrate[N[q^k (1 - q)^(n - k), 100] (E^(4 n q s) (1 - q)^(-1 + 4 n \[Mu]) q^(-1 + 4 n \[Nu]))/ NIntegrate[E^(4 n q s) (1 - ...


2

N@PolyLog[3,e] or N[PolyLog[3,e]] Also if by e you mean Exp[1](Mathematicas notation), then you'll have to change that.


5

Translated that roots() function from Matlab code to Mathematica, about 4 times faster than NRoots . Clear["`*"]; n=2000; m=RandomReal[1,{n,10}]; res1=x/.(ToRules@NRoots[FromDigits[#,x]==0.,x]& /@ m);//AbsoluteTiming (*-------------------------------*) roots[c_List]:=Block[{a}, a=DiagonalMatrix[ConstantArray[1.,Length@c-2],-1]; a[[1]]=-Rest@c/First@c; ...


4

Here is another way, which is more straightforward than my other answer. At first, I got stumped by couple of things, including, it turns out, a Bug in ArcLength?, and I didn't have time to explore the issues. Instead of using a "BoundaryMarkerFunction" we can list the markers directly in LineElement[elements, markers]. We can make a fairly general ...


7

You might create a NearestFunction to help pick the particular boundary you want. You can use it to mark the boundary elements of an ElementMesh (FEM). plot = ParametricPlot[ bezierfunc[ξ, η], {ξ, 0, 1}, {η, 0, 1}]; edges = Map[ First@Cases[ Normal@ParametricPlot[#, {t, 10^-5, 1 - 10^-5}, PlotPoints -> 100], Line[p_] :> p, ...


8

In V10 there has been added some symbolic processing of integrands containing an InterpolatingFunction. In particular if the interpolation grid divides the domain of integration into a number of subintervals, the number being at most the value of the option "MaxSubregions", the integrand will automatically be integrated over each subinterval. In V9, this is ...


1

[Update notice: It seemed convenient to give a parametrization of the solutions. See mysols below.] Probably NSolve should be able to do this, given enough time and memory, because the equations are reducible to a polynomial system. NSolve gives up after a while, though, and says it can't solve it. So we can manually convert it to a polynomial system by ...


1

In V10,D can symbolically differentiate NIntegrate if it is Inactive. In the case that the integral can only be evaluated with NIntegrate the following defines an arbitrary Derivative of the OP's function numericalModelInternalEnergy. ClearAll[numericalModelInternalEnergy, numericalModelHeatCapacity]; Block[{NIntegrate, Alpha, ground, T, Td}, integrand = ...


2

First I'll provide a symbolic workaround, and then I'll explain why your attempt doesn't work. The integral can be symbolically evaluated, like this: ModelInternalEnergy[Td_, T_] := Evaluate[Simplify[ Alpha*T^4* Integrate[x^3/(Exp[x] - 1), {x, 0, Td/T}, Assumptions -> Td/T > 0] + ground]] which for reference gives ground - 1/15 ...



Top 50 recent answers are included