Tag Info

Hot answers tagged

7

In addition to what I wrote in the comment, you can get a result much faster if you avoid using the explicit eigenvalues. Their product is the constant term of the characteristic polynomial so use that instead and rearrange the last equation as needed. M = {{α1, β3, β2}, {β3, α2, β1}, {β2, β1, α3}}; Timing[ sol2 = NSolve[{ β1 - (β2 β3 )/α1 == 2/3, ...


6

Introduction My first suggestion is to learn a little more about optimization. A good tutorial can be found here from Wolfram: http://reference.wolfram.com/language/tutorial/ConstrainedOptimizationGlobalNumerical.html Analysis Now let's have a closer look at your problem. der1 = (a (0.50984 + 2.75322 b))/(0.0649842 + 0.70185 b - 0.871367 b^2)^2 ...


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, ...


6

I like this short one: Solve[w^2 c^2 - 1 == 0 && (c == 1 || c == 2), {w, c}] (*{{w -> -1, c -> 1}, {w -> 1, c -> 1}, {w -> -(1/2), c -> 2}, {w -> 1/2, c -> 2}}*) It can be generalized as: cvalues = {1, 2, 5, 6}; Solve[w^2 c^2 - 1 == 0 && Or @@ Thread[c == cvalues], {w, c}]


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

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, ...


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

This is a bit long for a comment. You can use a tandem of LinearSolve and NullSpace. But for exact problems this will, I'm fairly sure, use dense matrices. That takes you back to what Solve is doing anyway, under the hood. Assuming your inputs are integer or rationals you might avoid dense matrix algebra as follows. Use numerical methods to find a single ...


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 ...


3

For your second question, you could use (tabletry = Table[p1*p2, {p1, 0, 2}, {p2, 0, 2}]) // MatrixForm; (* or (tabletry = Array[# #2 &, {3, 3}, 0]) // MatrixForm; *) (tst = Map[{# == 0} &, tabletry, {-1}]) // MatrixForm or (tst2 = Array[# #2 /. {0 -> {True}, _ -> {False}} &, {3, 3}, 0]) // MatrixForm Note the parantheses wrapping ...


3

I guess you are looking for this. Solve[x1 == !x2 && x2 == !x1, x1] // Quiet {{x1 -> ! x2}} I transpose Unequal to Not Equal like following code. Solve[x1 != !x2 && x2 != !x1 /. a_ != b_ :> (!a) == b, x1] // Quiet {{x1 -> x2}}


3

Unless I'm misunderstanding your question, I think its worth pointing out that {{x1 -> x2}} is not a valid solution to your original equation. Indeed, if x1 == x2, then $$x_1=1-x_2=1-x_1$$ which is always false modulo 2. Mathematica's solution {{x2 -> 1 - x1}} is correct since the two original equations are not linearly independent, and thus ...


3

ArrayReshape[Tuples /@ ({#, Solve[(w^2*c^2 /. #)-1 == 0, w]} & /@ {{c -> 1}, {c -> 2}}), {4, 2}] or Partition[Flatten[Tuples /@ ({#,Solve[(w^2*c^2 /. #)-1 == 0, w]} & /@ {{c -> 1}, {c -> 2}})], 2] both give (* {{c -> 1, w -> -1}, {c -> 1, w -> 1}, {c -> 2, w -> -(1/2)}, {c -> 2, w -> 1/2}} *)


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

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

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]}]]}, ...


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

sol = Flatten[Solve[{w^2*c^2 - 1 == 0, c == #}, {c, w}] & /@ {1, 2}, 1] {{c -> 1, w -> -1}, {c -> 1, w -> 1}, {c -> 2, w -> -(1/2)}, {c -> 2, w -> 1/2}} sol == Flatten[ Solve[{w^2*c^2 - 1 == 0, c == #}, {c, w}] & /@ (c /. {{c -> 1}, {c -> 2}}), 1] True


2

cc = {c -> 1, c -> 2}; sol = Solve[(w^2*c^2 /. #) - 1 == 0, w] & /@ cc; Partition[Riffle[Riffle[cc, cc], Flatten @ sol], 2] cc = {c -> 1, c -> 2, c -> 3}; sol = Solve[(w^2*c^2 /. #) - 1 == 0, w] & /@ cc; Partition[Riffle[Riffle[cc, cc], Flatten @ sol], 2]


2

Your p3 definitions seem different. The following uses 3p3 -5=p1+p2. set = Tuples[Range[0, 2], 2]; set /. {x_, y_} :> (x + y + 5)/3. /; x y == 0 yields: {1.66667, 2., 2.33333, 2., {1, 1}, {1, 2}, 2.33333, {2, 1}, {2, 2}} or if you wish to couple results and {p1,p2}: set /. {{x_, y_} :> Rule[{x, y}, (x + y + 5)/3.] /; x y == 0, {x_, y_} :> ...


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

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

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 = ...


1

I post this as another answer (using again $ 3p3=p1+p2-5$) if the matrices are the main aim: sa0 = SparseArray[{i_, j_} :> (i - 1) (j - 1), {3, 3}] // MatrixForm; sa = SparseArray[{{i_, j_} /; ((i - 1) (j - 1) != 0) :> (i - 1) (j - 1), {i_, j_} /; ((i - 1) ( j - 1) == 0) :> (i + j + 5)/3.}, {3, 3}] // MatrixForm; Row[{sa0, ...


1

delay = 4*10^-9; gamma = (25*10^3)/0.511; beta = Sqrt[1 - gamma^-2]; c = 3*10^8; rho = lb/theta; drift = 4 lb; time = (4 rho*theta + 2 drift - 4 lb - 2 drift*Cos[theta])/(beta*c); disp = lb^2/rho + lb/rho*drift*Cos[theta]; ContourPlot[{time == delay, disp == .6}, {theta, -12, 5}, {lb, 0, .3}, FrameLabel -> (Style[#, 14, Bold] & /@ {theta, ...


1

Updated answer: Thanks to hint by Daniel below, one can give NSolve region to search on. NSolve[{time == delay, disp == 0.6 && (-4 Pi < theta < 4 Pi) && (0 < lb < 10)}, {theta, lb}] gives {{theta -> -10.6056, lb -> 0.108685}, {theta -> -8.28907, lb -> 0.105523}, {theta -> -3.97865, lb -> 0.089839}, ...



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