dharr

Dr. David Harrington

7513 Reputation

21 Badges

20 years, 208 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are answers submitted by dharr

The easiest way to extract the plot is

p := MathematicalFunctions:-Get(plot, Zeta)

Then plottools:-getdata(p[2][1]) extracts data from the plot, or use lprint(p[2][1]) to see the plot structure. As usual right-clicking on this plot can let you see various options, but I'm not aware of anything that can reconstruct the plot command. (Perhaps you were thinking about a plot component for that.)

In this case the plot can be generated by 

plots:-complexplot3d(Zeta(z), z = -4 - 10*I .. 4 + 40*I,
      view = [default, default, 0 .. 3], orientation = [-32, 68]);

though I didn't try to get all options exactly right.

(When I right-clicked on the plot from FunctionAdvisor, Maple disappeared completely, though not reproducibly!)

I found that with one of that OPs worksheets (one I loaded in that thread) with a few second delays each keystroke (not 20 s, and not always), but it did have one large plot and multiple large expressions. In the past I have attributed those delays to working from a remote disk, but that wasn't the case today.

The bottleneck seems to be the evaluation of the large number of exponentials. If I reformulate this as an (almost) polynomial in three variables, then many of the calculations run much faster. For example one of the fsolve's that took 84 minutes now takes 14 s. For the plots I made a procedure but only tested it at low resulution and didn't compare the timing. Unfortunately, in the fsolve calls where T is an output, this method does not work, and I think this is the case you are most interested in.

Campo_Médio_spin_7_2_-_Forum_new.mw

Rouben's answer is fine if you are looking only for real roots, but you seem to think there are complex roots.  Are you sure there are? You have a numerically very difficult function to solve, with your constants varying over many orders of magnitude. Working in symbolic form allowed significant simplification of your expression. I could get Analytic to finish, but it did not find any solutions despite knowing there is a root in the region.

question128.mw

See the comments on the worksheet.

restart;

with(Typesetting):
Settings(typesetdot = true):

eq1 := (r1 + r2)^2 = r1^2 + x(t)^2 - 2*r1*x(t)*cos(theta(t));
eq2 := diff(eq1, t);
eq3 := subs(diff(x(t), t) = v, diff(theta(t), t) = omega, eq2);
assume(0 < x(t));
assume(0 < t);
assume(0 < theta(t) and theta(t) < 2*Pi);

(r1+r2)^2 = r1^2+x(t)^2-2*r1*x(t)*cos(theta(t))

0 = 2*x(t)*(diff(x(t), t))-2*r1*(diff(x(t), t))*cos(theta(t))+2*r1*x(t)*(diff(theta(t), t))*sin(theta(t))

0 = 2*x(t)*v-2*r1*v*cos(theta(t))+2*r1*x(t)*omega*sin(theta(t))

The ~ after t means that there is an assumption on it. You can change or suppress this with interface(showassumed) or from the menu tools->options->display->assumed variables

xx := solve(eq3, v);

-r1*x(t)*omega*sin(theta(t))/(-cos(theta(t))*r1+x(t))

You need to tell solve to use the assumptions; it is lazy.

eqx := solve(eq1, x(t),useassumptions)[1];

cos(theta(t))*r1+(cos(theta(t))^2*r1^2+2*r1*r2+r2^2)^(1/2)

v := subs(x(t) = eqx, xx);
 

-r1*(cos(theta(t))*r1+(cos(theta(t))^2*r1^2+2*r1*r2+r2^2)^(1/2))*omega*sin(theta(t))/(cos(theta(t))^2*r1^2+2*r1*r2+r2^2)^(1/2)

Is this the simplification you want?

simplify(expand(v));

omega*sin(theta(t))*(-r1^2*cos(theta(t))/(cos(theta(t))^2*r1^2+2*r1*r2+r2^2)^(1/2)-r1)

NULL

Download solve.mw

Internally 1.23/n^1.65 is represented as 1.23*n^(-1.65), from which the results follow. On the other hand 1.23/n^2 is similarly represented, but numer and denom seem to "try harder" and give the results you expect. That is probably because normal, numer, denom are usually used for ratios of polynomials. On the last hand, 1.23/n^(1/2) works as you expect, so I guess Maple just doesn't want to deal with the floating point exponent. 

This sort of unexpected behaviour is what discourages new Maple users (and me too), so in that sense I would describe it as a bug. I submitted an SCR.

I don't know about a limit, but it's certainly more than two lines. But it can be frustrating copying parts of 2d output in terms of what gets selected. In those cases I just use lprint (that's lowercase L), which provides 1-D output, which can then be pasted into 1-D input (e.g., ctrl-m before you paste.)

For the equations, PolynomialSystem with engine = triade returns quickly. Then you can use allvalues to find numerically all real solutions in the cases with RootOf. I would then check when the inequalities are satisfied using the numerical solutions. I didn't work up all the cases, just one of them.

restart

equations_1162 := {-(y+x-1)*k*t+x = 0, (y+x-1)*(p-s)*k-p*(x-1) = 0, -n*y^2+((1-x)*n-m+t+x)*y+m-1 = 0, (x^2-x)*n+y*(p-1)-s+1 = 0, -x*(y+x-1)*m+(p-s)*k+s*y-p = 0, -(y-1)*(y+x-1)*m+(t-1)*y-k*t+1 = 0, (-n+1)*x^2+((-y+2)*n-m-1)*x+(y-1)*n+1+(s-1)*y = 0, n*x*y-t = 0}; nops(equations_1162); indets(equations_1162); inequalities := {0 < k, 0 < m, 0 < n, 0 < p, 0 < x, 0 < y, 0 < (-m*x+p)*t+(s-p)*(m*y-m+1), 0 < (n*x-n-p+1)*t+n*y*(p-s), 0 < (m*x-n*x+n-1)*t+(m*y-n*y-m+1)*s+(n*x-n+1)*(m*y-m+1)-n*y*m*x, 1 < y+x, k < 1, m < 1, n < 1, p < 1}
NULL

8

{k, m, n, p, s, t, x, y}

sol := [SolveTools:-PolynomialSystem(equations_1162, indets(equations_1162), engine = triade)]; nops(sol)

5

For the solutions involving RootOf, you can use allvalues

allvals := [allvalues(sol[2])]

Convert to numerical values and remove complex values.

numallvals := remove(has, evalf(allvals), I); nops(%)

[{k = .17776185, m = 1.29154933, n = 1.406529, p = 1.084001834, s = .666694, t = -2.329993119, x = .8582043168, y = -1.930258}, {k = .62518515, m = .63968933, n = 9.695826, p = -.336487166, s = -.486299, t = 4.007364881, x = .9000101077, y = .459228}, {k = 1.32831735, m = -.49052067, n = .616, p = -134.9239762, s = -28.289, t = -.973106419, x = 4.894773384, y = -.354}, {k = -3.00242757, m = -.60014058, n = -0.86570138e-1, p = .8692193937, s = .642445747, t = 0.34135941e-1, x = -.1505394021, y = 2.619349949}]

4

Check if the inequalities are satisfied. For sol[2] in all cases some are true and some are false

for numsol in numallvals do `~`[is](eval(inequalities, numsol)) end do

{false, true}

{false, true}

{false, true}

{false, true}

NULL

Download solve_system_of_polynomials_with_inequalities.mw

restart;

x:=(4*sigma__d^4 + 4*sigma__d^2*sigma__dc^2 + sigma__dc^4)*n^4 + (-4*sigma__d^4 - 2*sigma__d^2*sigma__dc^2)*n^3 + (sigma__d^4 - 4*sigma__d^2*sigma__dc^2 - sigma__dc^4)*n^2 + (-4*sigma__d^4 + 2*sigma__d^2*sigma__dc^2)*n + 3*sigma__d^4;

(4*sigma__d^4+4*sigma__d^2*sigma__dc^2+sigma__dc^4)*n^4+(-4*sigma__d^4-2*sigma__d^2*sigma__dc^2)*n^3+(sigma__d^4-4*sigma__d^2*sigma__dc^2-sigma__dc^4)*n^2+(-4*sigma__d^4+2*sigma__d^2*sigma__dc^2)*n+3*sigma__d^4

n = 1 is a solution, so divide it out

simplify(x);
x2:=simplify(x/(n-1));

(4*n^3*sigma__d^4+4*n^3*sigma__d^2*sigma__dc^2+n^3*sigma__dc^4+2*n^2*sigma__d^2*sigma__dc^2+n^2*sigma__dc^4+n*sigma__d^4-2*n*sigma__d^2*sigma__dc^2-3*sigma__d^4)*(n-1)

4*(sigma__d^2+(1/2)*sigma__dc^2)^2*n^3+(2*sigma__d^2*sigma__dc^2+sigma__dc^4)*n^2+(sigma__d^4-2*sigma__d^2*sigma__dc^2)*n-3*sigma__d^4

Let y = 2*sigma__d^2+sigma__dc^2, which is explicitly positive. Then we can write x2 as a  quadratic in y

simplify(algsubs(2*sigma__d^2+sigma__dc^2 = y, 4*x2)):
x3:=map(factor,%);

(4*n^3+n-3)*y^2+2*sigma__dc^2*(2*n^2-3*n+3)*y+(5*n-3)*sigma__dc^4

All coefficients of y are positive for n>=2, and since y>0, x3 is always positive, i.e., has no real roots.

 

NULL

Download quartic_equation_in_n_2.mw

Unfortunately solve{identity(...),..) doesn't work with two identity variables. dcoeffs isn't useful here since you don't have derivatives. You can use coeffs. I'm assuming you want separate equations for each t^i*x^j combination.

params.mw

Just put the cursor before "b" and hit "backspace". Or just type "a:=10;b:=20;" then move the cursor to just after the first ";" and then hit "shift-enter".

Unfortunately solve{identity(...),..) doesn't work with two identity variables. dcoeffs isn't useful here since you don't have derivatives. You can use coeffs. I'm assuming you want separate equations for each t^i*x^j combination.

params.mw

 

@C_R has pointed out many of the things I might have mentioned. Here a few more comments along the same lines.

Q1. To me, your formulation uses matrices, but is not very matrixy. That's hard to define and probably largely intuitive on my part. Your matrices are almost all involved in dot products or quadratic forms (a^T.M.x), which produce scalars that you then involve in non-matrix equations. The power of matrices is in setting up matrix equations (I suppose a few vectors are allowed) and solving the matrix equations - often just a linear equation solving of Ax = b, but perhaps AX + XB = C, AXB = C or some nonlinear ones.

Specifically (but vaguely), the entries of r don't look like they have a simple matrix origin - we have square roots of entries, and while the denominators themselves might be matrixy, division is not a matrix thing so the denominators might better be in scalars outside the matrix. For the numerators, there are only diagonal elements of S, so where did the off-diagonals go?

The key point was given by @C_R: "but for that we have to see the structure of the equations in the first place".

Q2. I would say no here. Try to set things up without components, even if later you need to be explicit about them. For example to take a small part of your equations. q[1] = w^T.S.e[1], q[2] = w^T.S.e[2], q[3] = w^T.S.e[3] . So q[1], q[2], q[3] are the first, second and third components of w^T.S, so this is just q^T = w^T.S or q = S^T.w. The w[i]^2 seem to make this type of analysis harder (not matrixy?).

According to the help page, rsolve requires A(n), not A[n]. (But see @acer's answer.)

restart

sol := rsolve({A(n+1)*(5*A(n)+2) = A(n), A(1) = 1}, A)

1/(3*2^n-5)

eval(sol, n = 3)

1/19

seq(sol, n = 1 .. 10)

1, 1/7, 1/19, 1/43, 1/91, 1/187, 1/379, 1/763, 1/1531, 1/3067

``

NULL

Download ask_recrusive_sequence_of_A[n].mw

It seems to me that case (I) covers all sign combinations of lambda and mu. Case (II) looks incorrect to me - just putting the negative in doesn't work unless lambda and mu are redefined.

restart

de1 := diff(F(eta), eta) = lambda*G(eta); de2 := diff(G(eta), eta) = mu*F(eta)

diff(F(eta), eta) = lambda*G(eta)

diff(G(eta), eta) = mu*F(eta)

ans := dsolve({de1, de2}, {F(eta), G(eta)})

{F(eta) = c__1*exp(lambda^(1/2)*mu^(1/2)*eta)+c__2*exp(-lambda^(1/2)*mu^(1/2)*eta), G(eta) = mu^(1/2)*(c__1*exp(lambda^(1/2)*mu^(1/2)*eta)-c__2*exp(-lambda^(1/2)*mu^(1/2)*eta))/lambda^(1/2)}

ans2 := convert(ans, trigh)

{F(eta) = (c__1+c__2)*cosh(lambda^(1/2)*mu^(1/2)*eta)+(c__1-c__2)*sinh(lambda^(1/2)*mu^(1/2)*eta), G(eta) = mu^(1/2)*(c__1-c__2)*cosh(lambda^(1/2)*mu^(1/2)*eta)/lambda^(1/2)+mu^(1/2)*(c__1+c__2)*sinh(lambda^(1/2)*mu^(1/2)*eta)/lambda^(1/2)}

odetest(ans2, [de1, de2])

[0, 0]

ans3 := subs(lambda = -lambda, mu = -mu, ans2)

{F(eta) = (c__1+c__2)*cosh((-lambda)^(1/2)*(-mu)^(1/2)*eta)+(c__1-c__2)*sinh((-lambda)^(1/2)*(-mu)^(1/2)*eta), G(eta) = (-mu)^(1/2)*(c__1-c__2)*cosh((-lambda)^(1/2)*(-mu)^(1/2)*eta)/(-lambda)^(1/2)+(-mu)^(1/2)*(c__1+c__2)*sinh((-lambda)^(1/2)*(-mu)^(1/2)*eta)/(-lambda)^(1/2)}

simplify(odetest(ans3, [de1, de2]))

[2*(-lambda)^(1/2)*((c__1-c__2)*cosh((-lambda)^(1/2)*(-mu)^(1/2)*eta)+sinh((-lambda)^(1/2)*(-mu)^(1/2)*eta)*(c__1+c__2))*(-mu)^(1/2), -2*mu*((c__1+c__2)*cosh((-lambda)^(1/2)*(-mu)^(1/2)*eta)+(c__1-c__2)*sinh((-lambda)^(1/2)*(-mu)^(1/2)*eta))]

Take a specific numerical example

params := {c__1 = 1, c__2 = 1, lambda = -1, mu = -1}

{c__1 = 1, c__2 = 1, lambda = -1, mu = -1}

ans3num := eval(ans3, params); desnum := eval({de1, de2}, params)

{F(eta) = 2*cosh(eta), G(eta) = 2*sinh(eta)}

{diff(F(eta), eta) = -G(eta), diff(G(eta), eta) = -F(eta)}

simplify(eval(desnum, ans3num))

{2*cosh(eta) = -2*cosh(eta), 2*sinh(eta) = -2*sinh(eta)}

NULL

Download dsolve.mw

4 5 6 7 8 9 10 Last Page 6 of 76