dharr

Dr. David Harrington

8440 Reputation

22 Badges

21 years, 28 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

You are confused about the worksheet (*.mw) in which Maple runs, and the external text file of Maple commands that are read in to the worksheet (*.txt). Download the following two files to the same directory. Open the EKHAD.mw file by double-clicking (NOT the one you made) and follow the instructions (it has a bit more explanation). Hope this is clear.

EKHAD.mw

EKHAD.txt

(normally I would call the last one EKHAD.mpl, but the Mapleprimes site won't let me upload that, so EKHAD.txt will do.)

 

If you are willing to center the cube, then you can use scaling to do this. I used geom3d to easily get the vertices, but you could use cuboid. You can reorder lbls to get the order you need.

restart

with(geom3d); _local(D)

cube(poly, point(cen, [0, 0, 0]), side = 2); vs := vertices(poly); lbls := [A, B, C, D, A[1], B[1], C[1], D[1]]

poly

[[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]]

[A, B, C, D, A[1], B[1], C[1], D[1]]

Scale coords by 110% and combine with labels.

tplot := zip(proc (coords, lbl) options operator, arrow; [(1.1*coords)[], lbl] end proc, vs, lbls)

[[1.1, 1.1, 1.1, A], [1.1, 1.1, -1.1, B], [1.1, -1.1, 1.1, C], [1.1, -1.1, -1.1, D], [-1.1, 1.1, 1.1, A[1]], [-1.1, 1.1, -1.1, B[1]], [-1.1, -1.1, 1.1, C[1]], [-1.1, -1.1, -1.1, D[1]]]

pcube := draw(poly); ptxt := plots:-textplot3d(tplot, 'font' = ["times", "bold", 20]); plots:-display(pcube, ptxt)

NULL

Download cube.mw

The standard way of numerically solving second or higher order diiferential equations or systems is to convert them to an equivalent system of first order equations. For example

{diff(y(x), x, x) = -y(x), y(0) = 1, D(y)(0) = 0};

becomes

{diff(w(x), x) = -y(x), w(x) = diff(y(x), x), y(0) = 1, w(0) = 0};

They both have the solution y(x) = cos(x), and the second also has the "intermediate" solution w(x) = -sin(x). This way, the numerical solvers only need to be able to solve first order odes. In fact convertsys is mainly intended as an internal routine used by dsolve; normally you would just pass the higher order odes to dsolve

Your E2 is too complicated, so I'm not sure exactly what is going on. But in principle, I think you want to do something like this:

restart;

eq:=add(a[i]/r^i,i=1..4)=add(rand(1..10)()*x^i/r^i,i=1..4)

a[1]/r+a[2]/r^2+a[3]/r^3+a[4]/r^4 = 7*x/r+10*x^2/r^2+6*x^3/r^3+2*x^4/r^4

solve(identity(eq,r),{seq(a[i],i=1..4)});

{a[1] = 7*x, a[2] = 10*x^2, a[3] = 6*x^3, a[4] = 2*x^4}

NULL

Download solve.mw

There must be at least one typo in the notes. Probably you need to follow the derivation up to there closely to see how to resolve this.

restart

with(LinearAlgebra)

Assume a general form for the matrix. a is all terms that have opposite signs in B[1,1[ and B[2,2]; b is all terms that are the same sign in these entries.

B := Matrix(2, 2, [a+b-Omega, c, c, -a+b+Omega])

Matrix(%id = 36893490796494478140)

solve(Determinant(B), Omega)

a+(b^2-c^2)^(1/2), a-(b^2-c^2)^(1/2)

So it is clear which terms have to have opposite signs -the sign of 4*alpha^2*Delta in A[2,2] is incorrect and is changed (in red). The signs of 4*alpha^2*beta*Delta/Lambdamust the same so one of them must be changed (two possibilities - change in magenta).

A := Matrix([[-2*alpha^2*gamma+beta^2*Delta-4*alpha^2*Delta-4*alpha^2*beta*Delta/Lambda+2*beta*gamma*Lambda+2*beta*Delta*Lambda+gamma*Delta^2+Delta*Lambda^2-Omega, -2*alpha^2*gamma-4*alpha^2*beta*Delta/Lambda], [-2*alpha^2*gamma-4*alpha^2*beta*Delta/Lambda, -2*alpha^2*gamma-beta^2*Delta+4*alpha^2*Delta-4*alpha^2*beta*Delta/Lambda-2*beta*gamma*Lambda+2*beta*Delta*Lambda+gamma*Delta^2-Delta*Lambda^2+Omega]])

Matrix(%id = 36893490796494480436)

s1, s2 := solve(Determinant(A), Omega)

We have the required terms before the sqrt

s1 := expand(s1)

Delta*Lambda^2-4*alpha^2*Delta+beta^2*Delta+2*beta*gamma*Lambda+(Delta^4*Lambda^2*gamma^2+4*Delta^3*Lambda^3*beta*gamma-8*Delta^3*Lambda*alpha^2*beta*gamma+4*Delta^2*Lambda^4*beta^2-16*Delta^2*Lambda^2*alpha^2*beta^2-4*Delta^2*Lambda^2*alpha^2*gamma^2-8*Delta*Lambda^3*alpha^2*beta*gamma)^(1/2)/Lambda

However, the term with the sqrt is not correct. Squaring it must be b^2-c^2 = (b+c)*(b-c). Not clear how to get this result.

simplify(((s1-s2)*(1/2))^2)

Delta*(Delta^2*Lambda*gamma+2*Delta*Lambda^2*beta-8*Delta*alpha^2*beta-4*Lambda*alpha^2*gamma)*(Delta*gamma+2*Lambda*beta)/Lambda

NULL

Download DR_1.mw

 

Here's one way. (alignment = center is actually the default). There are other options you can play with. For me on Windows the export as .pdf renders everything as you see it. (The actual Table is not rendered on Mapleprimes.)

See ?DocumentTools,Tabulate

restart

p1 := plot(x^2, x = -1 .. 1); p2 := plot(x^3, x = -1 .. 1)

DocumentTools:-Tabulate([[p1], [p2]], alignment = center, width = 50)

NULL

Download plots.mw

Maple can find the condtion for 3 real roots but it has the inequality the wrong way round. SCR submitted. But then additional conditions for them to be positive seem difficult.

restart

with(SolveTools)

f := p*x^2+x^3+q*x+r

p*x^2+x^3+q*x+r

Returns a piecewise function

sols := Polynomial(f, x, domain = real); nops(%)

4

For the first condition there are 3 real roots, so this condition is what we want.

cond1 := op(1, sols); sol1 := op(2, sols); nops(%)

0 <= (1/27)*q^3-(1/108)*q^2*p^2-(1/6)*q*p*r+(1/4)*r^2+(1/27)*r*p^3

3

simplify(`~`[`*`](cond1, 108))

0 <= 27*r^2+(4*p^3-18*p*q)*r-q^2*p^2+4*q^3

Condition appears to be incorrect - following parameters satisfy the condition but don't give 3 real roots

params := {p = 1, q = 1, r = 1}; eval(cond1, params); solve(eval(f, params))

{p = 1, q = 1, r = 1}

0 <= 4/27

-1, I, -I

(For the second condition, there is only 1 real root, so this is not what we want.)

cond2 := op(3, sols); sol2 := op(4, sols); nops(%)

(1/27)*q^3-(1/108)*q^2*p^2-(1/6)*q*p*r+(1/4)*r^2+(1/27)*r*p^3 < 0

1

Assuming the condition was really that the expression was less than zero, we now we want additional conditions that make the roots positive...

sol1[1]

(1/6)*(36*q*p-108*r-8*p^3+12*(12*p^3*r-3*p^2*q^2-54*p*q*r+12*q^3+81*r^2)^(1/2))^(1/3)-6*((1/3)*q-(1/9)*p^2)/(36*q*p-108*r-8*p^3+12*(12*p^3*r-3*p^2*q^2-54*p*q*r+12*q^3+81*r^2)^(1/2))^(1/3)-(1/3)*p

NULL

Download cubic.mw

I am getting email notifications. As for whether it is only you, I can't say :-)

I'm not sure if I have interpreted the questions correctly; if not please let me know. I don't have answers to 3 and 4; maybe others can answer these. I don't understand how p and sinnx can be truly identical since the second is bounded but the first is not. On the other hand simplify(p-sinnx) gives zero :-(

poly.mw

Edit: added an additional numerical comparison in light of @Carl Love's clarification.

Indexed subscripts to the power of a superscript are aligned vertically:

[f(x)][a]^b;

[f(x)][a]^b

Download align.mw

With for loops

n := 5;
A := Matrix(n, n);
for i to n do
    for j to n do
        A[i, j] := i*(1 + j);
    end do;
end do;
A;

Equivalent method

B := Matrix(n, n, (i, j) -> i*(1 + j));

Matrix.mw

(You should use a Matrix rather than an Array if you are going to be doing Matrix multiplication and other Matrix operations.)

Some of your multiplications are actually "." (Matrix multiplication, appears at bottom of line) instead of "*" (appears as centered dot).

The error message mentions Statistics:-Remove, which is the currently active Remove command after you loaded the Statistics package. To refer to the regular Remove command, you need to use the syntax

:-Remove(data, red)

 

Use the save command to save d_remset to an .mpl file, which can be opened with a text editor, e.g.

save d_remset, cat(currentdir(),"/d_remset.mpl");
First 14 15 16 17 18 19 20 Last Page 16 of 83