Tag Info

Hot answers tagged

6

Ok, at first you don't solve your equation properly, the grid spacing is not enough for the entire time range. So first increase resolution, e.g.: tmax = 10; mdfun = NDSolveValue[ {D[h[x, t], t] + D[h[x, t]^-1*D[h[x, t], x], x] + D[h[x, t]^3*D[h[x, t], {x, 3}], x] == 0, h[0, t] == h[2 Sqrt[2] \[Pi], t], h[x, 0] == 1 + 1/10*Sin[x/Sqrt[2]]}, h, {x, 0, ...


5

A system with approximate (Real) coefficients sometimes has only approximate solutions. Minimizing the norm of the residuals, approach 3 below, may be the best way to approximate the solutions. In this case, we have seven equations in six unknowns. equations = { β1 - (β2 β3)/α1 == 0.1867, α2 - (β3 β3)/α1 == 1.9867, α3 - (β2 β2)/α1 == 0.9867, ...


5

Well, both $(1-x)$ and $(x-2)$ evaluate to $-1/2$ when $x\rightarrow 3/2$, and Log[-1/2] its well defined in the complexes, for instance $e^{iπ}= −1$, implies that $\ln(−1)=i π$, and therefore Log[-1/2]= I π - Log[2] so you are subtracting two well defined identical complex numbers to get zero. Therefore, this solutions does really solve the original ...


4

These are your definded gradient of functions gradf = Grad[y E^(x - z), {x, y, z}] gradg = Grad[9 x^2 + 4 y^2 + 36 z^2 - 36, {x, y, z}] gradh = Grad[x y + y z - 1, {x, y, z}] I think you can use following this, firstly I eliminated L, M. eq1 = Eliminate[{ gradf == L gradg + M gradh, 9 x^2 + 4 y^2 + 36 z^2 == 36, x y + y z == 1}, {L, M}]; sol = ...


4

It's pretty straightforward to make this work, so I'll just post my interpretation of what you're trying to do. In addition to neglecting to define the velocities and accelerations in terms of the positions, you also had some typos in there (capital XX etc.). There was also a redundant initial condition for XX[td] that I removed. It's important to define the ...


4

First put all your equations into a list (I'm not copying the full code here for brevity) eq = { eq1 == xx, eq2 == yy ...} And then: {val, sol} = NMaximize[{q@2, And @@ eq}, Array[q, 13], Method -> {"SimulatedAnnealing", "PerturbationScale" -> 10}]; sol // TableForm


3

The magic words are MATlink, which can be found on matlink.org


3

eq = {x[7] == 0, 6 x[4] x[5] + 6 x[3] x[5] x[6] + z*x[4] x[7]^2 + z*x[4] x[5] x[7]^2 == 0} Solve@FullSimplify[And @@ eq] (* {{x[4] -> -x[3] x[6], x[7] -> 0}, {x[5] -> 0, x[7] -> 0}} *)


3

As mentioned in the comments, Mathematica is assuming a complex valued logarithm (and hence can take negative inputs). If you query this on Wolfram Alpha (here) you can see the pod clarifies the solution is assuming this complex valued logarithm:


3

f[y_] = y Exp[(x - z)] /. Solve[ 9 x^2 + 4 y^2 + 36 z^2 == 36 && x y + y z == 1, {x, y, z}] // Simplify // Quiet; cons = List @@ Reduce[ Cases[f[y], Sqrt[t_] -> t, Infinity][[1]] > 0, y]; ptsMax = {y /. #[[2]], #[[1]]} & /@ (Outer[NMaximize[{#1, #2}, y] &, f[y], cons, 1] // Flatten[#, 1] &) ...


3

Even if there is some kind of mistake (typo) the solution is to use WhenEvent with Sow and Reap: {sol, {pts}} = Reap@NDSolve[{x''[t] == x[t]/(2*Sqrt[x[t]^2 + (1 - y[t])^2]), y''[t] == -0.2 - (1 - y[t])/Sqrt[x[t]^2 + (1 - y[t])^2], x[0] == x'[0] == Pi/3, y[0] == y'[0] == 0.5, WhenEvent[y[t] == 0 && y'[t] > 0, Sow[{t, x[t]}]]}, ...


3

Not general enough, of course. But: FullSimplify[ Or @@ Join @@ ((s = Solve[y^2 - x^3 + x == 0, {y}, Reals]) /. (y -> ConditionalExpression[__, b__]) :> b)] (* -1 <= x <= 0 || x >= 1 *) Plot[y /. s, {x, -2, 2}] The same for your sphere: s = FullSimplify [ Or @@ Join @@ (Solve[x^2 + y^2 + z^2 == 1, {z}, ...


3

The key is in the use of the variable x, which is used as a dummy variable in both the function z[y] and in the function Plot. When you rename one of them, e.g. z[y_] := Max[Solve[x^2 == y, {x}][[All]] /. Rule -> (#2 &)] z[3] Plot[Max[z[xx]], {xx, 0, 3}] your code works as expected.


3

there is no solution for the system. sol = Solve[res[[;; 3]] == p[[;; 3]]] (*{{x1 -> -3.16146, x2 -> 20.0611, x3 -> -13.5576}}*) res /. sol (*{{{0.}, {0.}, {0.}, {-3.92175}}}*)


3

Sorry, but this afternoon I'm too lazy to think too much. Therefore here is the simple literal translation of the four conditions letting Boole[] do the main job and giving the unique result Select[ Flatten[Table[(10^3 a + 10^2 b + 10 c + d)* Boole[a != b && a != c && a != d && b != c && b != d && c != d ...


3

Select[IntegerDigits@Prime[Range[1, PrimePi[10^4]]], Length@Union@# == 4 && (* 4 different digits *) Equal @@ Times @@@ Partition[#, 2] && (* the product condition *) #[[1]] > 3 & (* #[[1]] >3 *) ] (* {6,3,2,9} *)


3

Introduction There are a few ways to make such a table: (1) a symbolic way that seems conceptually clear and whose slowness is not prohibitive for a table of at most a few thousand entries; (2) using the table created by NDSolve in solving the equation by integrating its derivative either (a) directly or (b) correcting the errors in it; and (3) making a ...


2

Concerning the follow-up question in a comment: ...just for curiosity, if someone knows how to impose a positive codomain to not yet known function, I would very much like to know. One way is to define the system so that x'[t] is positive whenever x[t] < 0. Then when x[t] reaches 0, it will be stuck at 0, unless x'[t] becomes positive for x[t] > ...


2

NSolve can deal primarily with polynomial systems. In this problem one can easily eliminate the exponential term from the gradient of f. Since stationary point conditions depend only on directions of gradients and not on their magnitudes, one can divide gradients by nonzero functions. scaledgradf = Grad[y E^(x - z), {x, y, z}]/E^(x - z); gradg = Grad[9 x^2 ...


2

Since qIndoor + qOutdoor + qField + qVeg == 400000 there are only three independent variables alphaIndoor = 1.46172*10^6; alphaOutdoor = 1.61956*10^7; priceTap = 977.554; alphaField = 2.41546*10^7; alphaVeg = 547723; eqns = {(qIndoor/alphaIndoor)^(-10/3) - (qOutdoor/alphaOutdoor)^(-4/3) == 0, (qOutdoor/alphaOutdoor)^(-4/3) - priceTap - ...


2

Belisarus in his comment gave one solution which can be referred to as a post-processing. Here is the pre-processing as you mentioned: eq = Cos[x] - b Sin[x] == 0; Map[Divide[#, Cos[x]] &, eq] // Expand (* 1 - b Tan[x] == 0 *) In my version 10, however, your equation is perfectly solved by itself yielding Solve[eq,x] (* {{x ...


2

An additional option, that might not be known (I did not know about this until Daniel mentioned this on another post), is that if one have an idea about the range of values of the variable being solved for, and possibly other parameters, then NSolve and Solve will now be able to find solutions. At least from the examples I've tried so far f = ...


2

If you only need a numerical solution, then FindRoot should be one option: FindRoot[f, {x, 4}] (* {x -> 6.91844} *) and Plot[f, {x, 0, 10}, Epilog -> {Red, PointSize[.03], Point[{x, f}] /. FindRoot[f, {x, 4}]}]


2

sol = (x /. Solve[Sin[x] == 1/10, x]); sol2 = Minimize[{#, (# > 0)}, C[1], Integers] & /@ sol {{Pi - ArcSin[1/10], {C[1] -> 0}}, {ArcSin[1/10], {C[1] -> 0}}} Min[sol2[[All, 1]]] ArcSin[1/10]


2

So I wrote a thing. It's a bit ugly, but it seems to work: Clear[bounds]; bounds[eq_Equal, var_] := bounds[#, var] & /@ List @@ List @@@ LogicalExpand@Reduce[eq, var, Reals]; bounds[cond_List, var_] := Module[{collect, ranges = ConstantArray[0, Length@var], n = Length@var}, collect = Table[Select[cond, ! FreeQ[#, var[[i]]] && ...


2

The issue is that Solve is not HoldAll In[42]:= Attributes@Solve Out[42]= {Protected} so that the plot variable, x, is being substituted into Solve in the variable specification. There are a couple of ways to prevent this, but the most effective in the long term is to uniquely rename x in z, as follows z[y_] := Module[{x}, Max[Solve[x^2 == y, {x}][[All]] ...


2

Many of the numerical functions require the function that is passed as an argument be defined for numerical arguments to that function. This is explained as one of the pitfalls here: link to SE frequent pitfalls Your code will work as is if you use a pattern restriction ?NumericQ in your function definition: Clear[profikfun]; proflikfun[f0_?NumericQ] := ...


2

The code NSolve[Rationalize[f1[x] == f2[x], 0], x, Reals], 100] yields three solutions (with or without N), which is the minimum number of solutions if Zl ρ is positive. The following, which sets the precision of the input to match the working precision, NSolve[SetPrecision[f1[x] == f2[x], 100], x, Reals, WorkingPrecision -> 100] also yields three ...


2

Here is a case where you should take a close look at the magniture of your quantities and do some manipulation to normalize things before throwing the system at the computer: Zl = 2.05*10^-15 \[Alpha] = 1.6381 \[Rho] = 0.326*10^-10 k = 8.9875517873681764*10^9 e = 1.602176565*10^\[Minus]19 divide both of your expressions by ( \[Rho] e ) : ...


2

I'll try to address this one step at a time. Since a is assigned a value of 0.022 I shall assume we will be working numerically. Let's plot our function. a = 0.022; expr = (1/2) x Sqrt[1 + 4 a^2 x^2] + ArcSinh[2 a x]/(4 a) Plot[expr, {x, -1*^5, 1*^5}] 1/2 x Sqrt[1 + 0.001936 x^2] + 11.3636 ArcSinh[0.044 x] There appear to be no complications so ...



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