Tag Info

Hot answers tagged

7

You need the magic of "Pseudospectral": n = 35; g = 9.81; a = 1350; L = 3500; T = 30; h0 = 4; v0 = Sqrt[2 g h0]; R = 0.003; sol = NDSolve[ {D[h[x, t], x] - R v[x, t] Abs[v[x, t]] == D[v[x, t], t]/g, D[v[x, t], x] == g D[h[x, t], t]/a^2, v[x, 0] == v0, v[0, t] == v0 Exp[-(t^2/0.4)], h[L, t] == h0, h[x, 0] ...


7

The recursion limit error which you observe looks like a bug in N. Here is a shorter code to reproduce the issue: N[obj[args__]] := obj[args] N@obj[1, 2, 3] During evaluation of In[2]:= $RecursionLimit::reclim: Recursion depth of 1024 exceeded. >> obj[1, 2, 3] In the comments Oleksandr R. provided a workaround via combined usage of Verbatim ...


5

The problem is not FixedPointList - the problem is that Mathematica by default doesn't display that many digits. Consider for example FixedPoint[newton3, 1.0] // InputForm which displays several more decimals. Another option is to increase PrintPrecision: SetOptions[InputNotebook[], PrintPrecision -> 10] This increases the number of decimals shown ...


5

With the option MaxStepSize -> 1., it seems to work. (A little bit magic) sol = NDSolve[{ D[h[x, t], x] - R*v[x, t]*Abs[v[x, t]] == 1/g D[v[x, t], t], D[v[x, t], x] == g/a^2*D[h[x, t], t], v[x, 0] == v0, v[0, t] == v0 Exp[-t^2/0.4], h[L, t] == h0, h[x, 0] == h0}, {h, v}, ...


4

$Version "10.0 for Mac OS X x86 (64-bit) (December 4, 2014)" f[x_] = Sin[x]^6 + Cos[x]^6; sol = FullSimplify[Minimize[ {f[x], 0 <= x <= 2 Pi}, x]] {1/4, {x -> (7*Pi)/4}} However, this is just one of the four minima. To find all four: pts = {x, f[x]} /. Solve[ {f'[x] == 0, f''[x] > 0, 0 <= x <= 2 Pi}, x] // FullSimplify ...


3

The problem you face here is that your function has several minima in the range you specified: If you want them all, you can use Reduce, but for this, you need the approach you learned in school: calculate the derivative of your function and calculate where it is zero. Then use the second derivative and check whether it is >0 to indicate that you want a ...


3

Fixed in 10.0.2 v1 = Table[i, {i, 1, 100000}]; v2 = Table[i, {i, 1, 100001}]; s1 = BitShiftRight[v1]; s2 = BitShiftRight[v2]; s1[[1 ;; 10]] s2[[1 ;; 10]] v = Range[100001]; a = BitShiftRight[v[[;; 10]]]; b = BitShiftRight[v][[;; 10]]; a == b


2

Perhaps something like this: allNumeric[vars_] := VectorQ[{vars}, NumericQ] (* define once, use many times *) f[x_, y_, z_, t_] /; allNumeric[x,y,z,t] := ...


2

Your data: data = {{0.067, 0.423}, {0.30, 0.408}, {0.60, 0.433}, {0.25, 0.3512}, {0.37, 0.4602}, {0.44, 0.413}, {0.60, 0.390}, {0.73, 0.437}, {0.8, 0.47}}; errors = {0.055, 0.0552, 0.0662, 0.0583, 0.0378, 0.080, 0.063, 0.072, 0.08}; ErrorListPlot[Transpose[{data, ErrorBar /@ errors}], PlotRange -> {0, 1}] Assume that the errors are distributed ...


2

Since you haven't provided some code I can run, I will use the example of the documentation. As you can read in the details section of the documentation of WhenEvent, what you want can probably be implemented using something like the following: Reap@ NDSolve[{(2 - f[x]) f'[x] == f[x], f[0] == 1, WhenEvent[Abs[f'[x]] > 10^6, Sow[x]; ...


1

Minimize returns a symbolic result as it is designed to do. It is working correctly. To force the return of a numeric result you must "encourage" Minimize to do so. This makes it call NMinimize instead. A simply way is to multiply any portion by 1. to make it floating point. The decimal point is important. Minimize[{1.Sin[x]^6 + Cos[x]^6, 0 <= x <= 2 ...


1

The problem is, that NDSolve always returns a list of solutions, in this case a list of length 1. You can see it here: d[1, 1] Out[58]= {0.942309} If you know there is only one solution, you can use d[x_, t_] := Evaluate[u[x, t] /. First@sol] to make d[1,1] evaluate to 0.942309 instead of {0.942309} .



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