Tag Info

New answers tagged

0

This could also be an example for InfinitLine. If your line is a vertical line the intersection is just the function value, i.e.{x,f[x]}. Given p1 = {1, 1}; p2 = {2, 3}; and f[x_] := Sqrt[4 - x^2] one can define line = InfiniteLine[p1, p2] and calculate the intersection points via sols = NSolve[{x, y} \[Element] line \[And] {x, f[x]} \[Element] ...


0

There is no missing point for the function as defined. g[-2] is not defined an returns undefined. Mathematica just joins. Plot[g[x], {x, -6, 6}, Exclusions -> {-2}] is the appropriate plot of function Consider also: Limit[g[x], x -> -2, Direction -> 1] Limit[g[x], x -> -2, Direction -> -1] The following achieves aim of second set of ...


2

Your equation is easier to handle if it put into an equivalent form. eq1 = Sqrt[l1] + Sqrt[t1] + Sqrt[w1] == d; It is also to convenient to write the rules as r1 = {l1 -> (pw^2 w1)/((1 + a e1)^2 w^2)}; r2 = {t1 -> (pw^2 w1)/((1 + a e1)^2 r^2)}; and substitute u^2 for w1 getting a new equation eq2 = eq1 /. Join[r1, r2] /. w1 -> u^2 ...


6

In short: There is no closed solution, but you can get solutions for specific values of ϵ. Detailed explanation: First, we can transform your equation into a more compact form by using FullSimplify (and replacing ϵ with e for less typing within Mathematica): eq = (x ϵ + (-ϵ) x^-ϵ - c (-ϵ) x^(-ϵ - 1) /. ϵ -> e //FullSimplify) == 0 (* e x^(-1 - e) (c - x ...


4

In this case, I recommend Manipulate to investigate the function. Note as x, c and ϵ are used. With the information found You can start better studies Manipulate[ Plot[x ϵ + c x^(-1 - ϵ) ϵ - x^-ϵ ϵ , {x, -6., 6.}] , {c, -6., 6.} , {ϵ, -6, 6}]


1

For given numeric values of ϵ and c you can use FindRoot: eq = x ϵ + (-ϵ) x^-ϵ - c (-ϵ) x^(-ϵ - 1) == 0; FindRoot[eq /. {c -> 2, ϵ -> 3/4}, {x, 1}] (* {x -> 1.38718} *) For arbitrary analitycal values of ϵ and c the equation seems to be unsolvable. However, if you can threat ϵ as a small parameter (like in perturbation theory), I would suggest to ...


1

First (for a given Epsilon): eq = x ϵ + (-ϵ) x^-ϵ - c (-ϵ) x^(-ϵ - 1) == 0 then: FullSimplify @ eq Thus it suffices to solve: c - x + x^(2 + ϵ) == 0 Then sol = Solve[(c - x + x^(2 + ϵ)) == 0, x] delivers the solutions. If you want the solutions for e.g.,c = 5, then c = 5; x /. sol will show them. When Epsilon is is not given, Solve is not ...


3

According to your statement, I think what you need is just 4th-order Runge-Kutta method, and a completely self-made implementation of 4th-order Runge-Kutta method isn't necessary, then the answer from J.M. has shown you the optimal direction: (* Unchanged part omitted. *) ClassicalRungeKuttaCoefficients[4, prec_] :=With[{amat = {{1/2}, {0, 1/2}, {0, 0, ...


2

There's a misunderstanding here. The third "dom" argument is not simply a set over which we solve the equation. There are only a few choices that can be used for the domain argument, and they have very specific effects on how Solve works. An example from the documentation: If dom is Reals, or a subset such as Integers or Rationals, then all constants ...


1

{Solve [ x^2 == 1, {x}], Solve [ x^2 == 1 && x > 0, {x}]} (* {{{x -> -1}, {x -> 1}}, {{x -> 1}}}*)


1

So I think I found a way following this post: Find Roots in Do loop I added these commands: t = List[0, 0.5, 1, 1.5, 2] Table[FindRoot[{e1, e2, e3, e4} /. dat, {{w, 0.5}, {r, 2}, {p2, 0.8}, {pw, 1.8}}], {a, t}] And it does calculate FindRoot over the different values of a.


0

No, it's not too much for Mathematica. What you expect and the result given by Mathematica are the same thing. This can be tested by e = Eliminate[{x == t + t^3, y == t - t^3, z == 1 + t^4}, t]; s = Solve[e, {x, y}]; AllTrue[s, ((x^2 + y^2)^2 == (x^2 - y^2) z^2 /. # // FullSimplify) &] which gives True. The question is more like how you could ...


2

This expression can be simplified substantially as follows. Beginning with ((a - 1) (1 + d x^2))/(a (Exp[b x + c] - 1)) - e multiply the expression by its denominator and Simplify Numerator[Together[%]] (* -1 + a + a*e - a*e*E^(c + b*x) - d*x^2 + a*d*x^2 *) Collect[b^2/(d (a - 1)) %, x^2, Simplify] (* (b^2*(-1 + a*(1 + e - e*E^(c + b*x))))/((-1 + a)*d) ...


2

gradient[g_, vars_] := Table[D[g@@vars, vars[[j]]], {j, 1, Length[vars]}] system1[lstConst_, vars_] := Join[ Join@@ Table[gradient[lstConst[[j]], vars], {j, 1, Length[lstConst]}], Table[lstConst[[j]]@@vars,{j,1,Length[lstConst]}]]; system2[f_, lstConst_, vars_, lambda_] := Join[ gradient[f, vars] - Sum[ lambda[[j]]*gradient[lstConst[[j]], vars], ...


0

Figured the problem. I was using the slope from y=4x as just 4 when it actually should be m=-1/4. Thanks for all the help though.


4

For an exact solution: f[k_, x_] = -k^x + x^2; soln = Reduce[{f[k, x] == 0, D[f[k, x], x] == 0, x > 0}, {k, x}, Reals] // ToRules {k -> E^(2/E), x -> E} f[k, x] /. soln 0 k /. soln // N[#, 17] & 2.0870652286345330 Plot[f[k /. soln, x], {x, 2, 3}]


3

Alternatively, use FindRoot FindRoot[Integrate[ SquareWave[{0.2, 0}, ((x - 2.5)/10)], {x, 0 + a, 10 - a}] == 0.95, {a, .5}] {a -> 0.125}


3

Solve[{Integrate[ SquareWave[{2/10, 0}, ((x - 25/10)/10)], {x, a, 10 - a}, Assumptions -> 0 < a < 1] == 95/100, 0 <= a <= 1}, a, Reals] (* {{a -> 1/8}} *)


3

Having just one root requires eq1 = -k^x + x^2 == 0; eq2 = D[-k^x + x^2, x] == 0 (* 2*x - k^x*Log[k] *) FindRoot can solve for x and k simultaneously. FindRoot[{eq1, eq2}, {{x, 2.5}, {k, 2}}] (* {x -> 2.71828, k -> 2.08707} *) Plot[(-k^x + x^2) /. %[[2]], {x, 2, 3}]


0

First, you use a wrong syntax for Solve. It should be something like eq = acc == whatever the right hand side is; Solve[eq, d] Second, as m_goldberg has pointed out, your equation just can't be solved in terms of d! You must have done something wrong in your hand calculation.


2

First off: you have a lot of unnecessary bracket pairs. Your equation should be written acc == (d + d (-1 + 1/fpr) (-1 + 1/precision))/ (d + d (-1 + 1/precision) + d (-1 + 1/fpr) (-1 + 1/precision) + d (-1 + 1/tpr)) Second, since d can be eliminated from your equation, you can't get a solution in terms of d. Eliminate[ acc == (d + d ...


2

Restricting the domain to Reals will speed up the solution. NSolve[{ rp t1 - r (t1p - t2p) t3p + rp t4 - r (2 t1p + t2p) t4p == 0, t1p (r + t3) - rp t1 t3p - 2 t1p t4 - 2 rp t1 t4p == 0, -t2p t3 + rp t2 t3p - t2p t4 - rp t2 t4p == 0, -rp (t1p - t2p) t3 + (t1 - t2) t3p == 0, -rp (2 t1p + t2p) t4 + (r - 2 t1 - t2) t4p == 0, r^2 + rp^2 == 1, t1^2 ...


4

In Mathematica 10: ==Hello I would like to solve the quadratic equation please


6

try with: Solve[a*x^2 + b*x + c == 0, x]


0

I found another combination of option that doesn't suffer the NDSolve::eerr warning and produces almost the same result as that in Michael E2 but only takes about 0.6 s on my old laptop to finish. The key point here is to use a high enough "DifferenceOrder" and choose a odd number of grid points: (* Define a auxiliary function *) mol[n_, o_: ...


3

You can't solve that monster algebraically. One could create a function that takes all the parameters and numerically finds the velocity. u0is a starting point solveU[u0_, {deltaP_, L_, rho_, d_, eps_, mu_}] := u /. FindRoot[deltaP == (1.52648*10^21 L u^2 rho)/( d ((3.53972*10^19 u^2 eps^2 rho^2)/mu^2 - ( 5.7107*10^20 u ...


1

Just use Solve : Solve[ -11 x1 - 20 x2 - 9 x3 + 8 x4 - 9 x5 - 14 x6 - 9 x7 - 11 x8 + 3 x9 == 19 x1 + 19 x2 + 20 x3 - 12 x4 + 2 x5 - 13 x6 - 17 x7 + 10 x8 + 17 x9 == -14 15 x1 + 2 x2 + 17 x3 + 15 x4 - 20 x5 - 10 x6 - x7 + 9 x8 + 8 x9 == -6 13 x1 + 13 x2 - 8 x3 + 5 x4 - 8 x5 - 12 x6 + 11 x7 - 19 x8 + 11 x9 == -17 - 18 x1 - 5 x2 - 18 x3 - 7 ...


1

Use FindRoot: FindRoot[Sqrt[(2*m x b^2)/h^2]*Tan[Sqrt[(2*m x b^2)/h^2]] == Sqrt[(2*m*(V - x)*b^2)/h^2], {x, 5*10^-20}] (*Output*) {x -> 4.86164*10^-20}


4

OK, I see these, but I'm still at loss as why would this certain expression prove this difficult. I really don't know how Mathematica is solving equations with fractional powers like this, but think about how you would solve them. Take a simple example: $$ \sqrt{x+1} + \sqrt{x+2} = 5 $$ We have two square roots, i.e. two fractional power terms. ...


2

Interpreting your right hand side as cz (rather than cx)) the solution z0 can be computed as a function of c (where 0 < c < 3/2) with the help of FindRoot thus: z0[c_] := z /. FindRoot[c == (1/z) (((z - 2)^(14/5) + (z + 3)^(7/10))/(z - 1)^(7/2)), {z, 2}][[1]] Plot[z0[c], {c, 0, 1.5}, PlotRange -> {0, 5}, PlotLabel -> "Solution z0 of an ...


1

Your posted code cleaned up: equ1 = {Derivative[4][v1][t] == (12 L^3 (q - ((2 - 2 a)^2 b h1^3 (a (L - 2 t) + 2 t) Young Derivative[2][v1][t])/(2 L^3) - ((2 - 2 a) b h1^3 (a (L - 2 t) + 2 t)^2 Young Derivative[3][v1][t])/(2 L^3)))/(b h1^3 (a (L - 2 t) + 2 t)^3 Young), Derivative[4][v2][t] == (12 q)/(b h1^3 Young), v1[0] == 0, ...


10

The slowness is due to the fact that several steps in your code were not compilable because they invoked MainEvaluate. I localized all the variables by adding Module. Then, several variables were mis-recognized as integer when they should be reals. To fix this I added decimal points to some numbers like 1. The externally defined functions at the beginning ...


1

Here is one approach. I have not tested it so there might be unforseen hitches. I'll refer to your matrices as matrixA, matrixB1, and matrixB2 respectively. Define minEig[mat1:{{_Real..}..},mat2:{{_Real..}..}] := Min[Eigenvalues[mat1-mat2]] newB = Array[b, Dimensions[a]]; obj = Trace[matrixA.newB]; FindMinimum[{obj, minEig[newB,matrixB1]>=0, ...


1

f[x_] := x^2 - 1; df = D[f[x], x]; lastX = .7;(*guess*) k = 1;(*counter,just in case*) err = Infinity; SetOptions[$FrontEnd, PrintPrecision -> 16] r = First@Last@Reap@While[err > 0.000001 && k < 10, Sow[{k, err, lastX}]; currentX = lastX - f[lastX]/(df /. x -> lastX); err = Abs[f[currentX] - f[lastX]]; lastX = ...


2

After replacing "=" by "==" and Solve by NSolve everything is fine. Have a look: eq1 = -161.2035 + 2.7 s - 2.7 a + 0.0039123 s^4 - 0.000567 a^4 == 0; eq2 = -78.021525 + 0.01134 a^4 - 2.7 s - 2.7 a - 0.0035721 s^4 == 0; NSolve[{eq1, eq2}, {a, s}] (* {{a -> 12.7656, s -> -15.9596}, {a -> -0.781212 + 12.0381 I, s -> 1.55315 - 14.6168 I}, {a ...


1

There was a really silly mistake. I'm embarrassed for even asking now... z = r cos[theta] was missing from the integral. It's all good now. Thanks for the help anyways! Love you guys :]


1

Just another approach: mat = { {0, 0, 1, 0, 0, 1}, {1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 1, 0}, {0, 0, 1, 0, 0, 0}, {-1, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 0} }; in = {1, 0.5, 1, 0.25, 2, 1.5}; abc[0] := in[[{2, 4, 6}]]; abc[n_] := Nest[mat.# &, in, n - 1][[{1, 3, 5}]]; a[n_] := abc[n][[1]]; b[n_] := abc[n][[2]]; c[n_] := abc[n][[3]]; ...


1

The solution provided by bill s is analogous to NDSolve. A solution analogous to DSolve is First@RSolve[{a[n] == b[n - 1] + c[n - 2], b[n] == a[n - 2] + c[n - 1], c[n] == b[n - 2] - a[n - 1], a[1] == 1, a[0] == 0.5, b[1] == 1, b[0] == 0.25, c[1] == 2, c[0] == 1.5}, {a[n], b[n], c[n]}, n]; s = Chop[FullSimplify[%, n ∈ Integers] (* ...


2

You can just write the equations directly: a[n_] := a[n] = b[n - 1] + c[n - 2]; b[n_] := b[n] = a[n - 2] + c[n - 1]; c[n_] := c[n] = b[n - 2] - a[n - 1]; a[1] = 1; a[0] = 0.5; b[1] = 1; b[0] = 0.25; c[1] = 2; c[0] = 1.5; I've shifted the time indices, and arbitrarily assigned some initial conditions. To see individual values you can just type: a[20] To ...


1

The equation you appear to be trying to solve is eq = D[r[x], x] == r[x]/x*(2/(k*a^-2*g*x^4*r[x]^(g + 1) - 1)) It is necessary to indicate that r is a function of x. Then, sol = DSolve[eq, r[x], x] gives an implicit equation for r[x]. (* Solve[(2*Log[r[x] - g*r[x]])/(1 - g) + (-4*Log[x] + Log[a^2*(-1 + g) + 2*g*k*x^4*r[x]^(1 + g)])/(-1 + g) == ...


2

I would direct you to the tutorial, specifically Input No. 10. To quote There is no explicit "closed form" solution for a transcendental equation like this. You can find an approximate numerical solution using FindRoot, and giving a starting value for x. Like so: FindRoot[Sin[x] - x^2, {x, 1}] {x -> 0.876726}


2

h[x_] = Sin[x] - x^2; Plot[h[x], {x, -.5, 1.25}] Tell Solve or NSolve the domain to search Solve[{h[x] == 0, -1/2 <= x <= 5/4}, x] // N {{x -> 0.}, {x -> 0.876726}} NSolve[{h[x] == 0, -1/2 <= x <= 5/4}, x] {{x -> 0.}, {x -> 0.876726}} The domain can just be Reals Solve[h[x] == 0, x, Reals] // N {{x -> 0.}, {x -> ...


0

Since this is a rather simple function, you should approximately know about the distribution of its roots. One of them should be zero. If you don't you can use Plot to observe. For example, Plot[-x^2 + Sin[x], {x, -0.5, 1}] Then you can use FindRoot[-x^2 + Sin[x] == 0, {x, 1}] (*{x -> 0.876726}*) to find out the other root.You can also obtain more ...


0

NDSolve[{D[u[t, x], t] == D[(u[t, x]*(u[t, x]^2 - u0^2) - D[u[t, x], x, x]), x, x], u[0, x] == 0, u[t, 0] == u[t, 5]}, u, {t, 0, 10}, {x, 0, 5}] You'd need to specify u0 which was not given in the question.


3

data = {{0, 0.837}, {50, 0.763}, {100, 0.699}, {150, 0.647}, {200, 0.602}, {250, 0.563}, {300, 0.532}, {350, 0.505}}; With[{Ao = 0.837}, p = NonlinearModelFit[data, (Ao - Ax) Exp[-k t] + Ax, {Ax, {k, 1/200}}, t] ] Show[ ListPlot[data], Plot[p["BestFit"], {t, 0, 350}] ] Note that I provided a starting value for the value of k (1/200) that ...


7

Clear[a, b, c, x, d, r] eq1 = a (-(1/(1 + b c + a x)) - Log[b c + a x] + Log[1 + b c + a x]) - d == 0 To simplify, make common sub-expression substitution eq2 = eq1 /. (b c + a x) -> z Write it as eq2 = (-(1/(1 + z)) - Log[z] + Log[1 + z]) == d/a eq3 = eq2 /. (d/a) -> r Now take the exponential eq4 = Exp[#] & /@ eq3 eq5 = eq4 ...


2

You can use Solve, if you specify constraint on b eq = (15 Sqrt[\[Pi]] (Erf[11 Sqrt[b]] + Erf[17 Sqrt[b]]))/(14 Sqrt[b]) == 21; Solve[eq && 0 < b < 100, b] N[%]


0

You can use FindInstance to find one solution: N@FindInstance[(15 Sqrt[Pi] (Erf[11 Sqrt[b]] + Erf[17 Sqrt[b]]))/(14 Sqrt[b]) == 21, {b}] {{b -> 0.0325472}}


1

First there is a typo in your equation, it should be Sqrt[Pi] and not Sqrt[[Pi]]. This equation can not solved via NSolve, but you get a result (approx 0.0325) via FindRoot: FindRoot[(15 Sqrt[Pi] (Erf[11 Sqrt[b]] + Erf[17 Sqrt[b]]))/(14 Sqrt[ b]) - 21, {b, 1.}]


2

Given that ParametricNDSolve does not handle this case, one can revert to the old way. Uncomment the memoization if desired; it will speed things up if sol is called multiple times with the same parameters. Clear[sol]; sol[t0_, x0_, y0_, ϵ_] := (*sol[t0, x0, y0, ϵ] =*) NDSolve[{x'[t] == y[t], y'[t] == x[t] - 1 - ϵ Cos[5 t], x[t0] == x0, y[t0] == ...



Top 50 recent answers are included