dharr

Dr. David Harrington

8507 Reputation

22 Badges

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

Your first problem is that you have not consistently used "*" for multiplication (these look like centered dots, in the middle of the line); many of them are "." (look the way they are typed, at the bottom of the line), which is Matrix multiplication. I converted them all to "*", but there is still the same error message. 

The error message arises because Maple cannot rearrange all the equations into standard form - I'm guessing the squared term (diff(Theta(eta), eta))^2 is the problem. Sometimes rearranging by solving explicitly for these quantities before dsolve can succeed where Maple cannot. I recall some discussion of this on this forum, but I do not have time to work further on this now.

New.mw

expr:=1+5*I+sin(x)-sqrt(8)*I-a;
map(x->if type(x,complex) then Re(x),Im(x)*I else x end if, [op(expr)]);

gives

[1, 5*I, sin(x), 0, -(2*I)*sqrt(2), -a]

assuming expr is a sum of terms, i.e. has type `+`.  (5+I on its own is not a sum of terms.)

Edit: to cover the case of a single complex constant such as 5+I

terms:=proc(expr)
       if type(expr,`+`) then
          map(x->if type(x,'complex') then Re(x),Im(x)*I else x end if, [op(expr)])
       elif type(expr,'complex') then
          [Re(x),Im(x)*I]
       else error "not a sum"
       end if;
end proc:

There are other things that look like sums but aren't of type `+`  (series and perhaps others) that could be included.

To add to @Kitonum's answer, for item in expr iterates over the operands of expr, and op(I) is 1. As it states on the help page for I, I is implemented as Complex(1), so op(I) = op(1,I) = 1 and op(0,I) = Complex. As always when dealing with operands, things are not always as they seem, so care needs to be taken. Note that op(0,5+I) = Complex, so this might be helpful in screening terms.

Edit: you can also test for the type complex or complexcons or realcons.

Note that type(a+I, `+`) returns true (a and I are different numbers) but type(9+I, `+`) returns false (a single complex number). Recognizing this leads the the solution I've given in a separate answer to your update. (Someone promoted that from a reply to an answer.)

simplify([0.*I-3, 5, 7, -2],zero);

 

restart;

spirals:=proc(p::posint,q::posint)
    local A,B,C,r,s,t,eq1,eq2,eq3,ans,Bi,i,j,z,
                circles,j__min,j__max,min_d,max_d;
    # circles A,B,C have centres in the complex plane at
    A:=s*exp(I*t);
    B:=s^(p/q)*exp(I*(p*t+2*Pi)/q);
    C:=1;
    # radii are |A|*r, |B|*r, |C|*r=r, so for mutual touching
    eq1:=simplify(abs(A-C)-(abs(A)+abs(C))*r) assuming positive;
    eq2:=simplify(abs(B-C)-(abs(B)+abs(C))*r) assuming positive;
    eq3:=simplify(abs(B-A)-(abs(B)+abs(A))*r) assuming positive;
    ans:=fsolve({eq1,eq2,eq3},{s=0..infinity,t=0..2*Pi,r=0..infinity});
    A,B,r:=eval([A,B,r],ans)[]; #A,B,r now floating point
    min_d:=0.7; # smallest circle cutoff
    max_d:=100; # half frame size
    for i from 0 to q-1 do              #spirals
       Bi:=B^i;
       j__min:=floor(ln(min_d/abs(Bi))/ln(abs(A)));
       j__max:=ceil(ln(max_d*sqrt(2.)/abs(Bi))/ln(abs(A)));
       for j from j__min to j__max do #circles within spirals
         z:=Bi*A^j;
         circles[i,j]:=plottools:-circle([Re(z),Im(z)],abs(z)*r);
       end do;
    end do;
    plots:-display(plottools:-rectangle([-max_d,max_d],[max_d,-max_d],color=white),
                   entries(circles,'nolist'),
                   scaling=constrained,axes=none,
                   view=[-max_d..max_d,-max_d..max_d]);
end proc:

spirals(2,12);

 

Download DoyleSpirals.mw

Here's one way.

restart

with(plottools):

Basis vectors

u := [1, 0]:

Grid limits

i__min := -3:

ulines := seq(line(i__min*u+j*v, i__max*u+j*v, linestyle = dash), j = j__min .. j__max):

ulabel := plots:-textplot([u[], "u"], 'align' = {'below', 'right'}, font = [times, bolditalic, 25]):

plots:-display(ulines, vlines, arrow([0, 0], u, .1, .4, .4), arrow([0, 0], v, .1, .4, .4), ulabel, vlabel, axes = none);

``

 

Download grid.mw

No entirely sure I understand what you want to do, but perhaps this?

ChgtVariables_VERS_INT:=
seq([diff(theta[i](t),t$2)=cat(ddq,i),
     diff(theta[i](t),t)=cat(dq,i),
     theta[i](t)=cat(q,i)][],i=1..3);

diff(diff(theta[1](t), t), t) = ddq1, diff(theta[1](t), t) = dq1, theta[1](t) = q1, diff(diff(theta[2](t), t), t) = ddq2, diff(theta[2](t), t) = dq2, theta[2](t) = q2, diff(diff(theta[3](t), t), t) = ddq3, diff(theta[3](t), t) = dq3, theta[3](t) = q3

 

 

Download cat.mw

Your use of subs(x=L,nw(x,t)) leads to subs(x=L,diff(p(x,t),x)) which leads for L=0.003 to diff(0.003,t),0.003), which doesn't make sense. This can be solved by converting to D notation, which you need anyway for ICs and BCs. This and other changes indicated in red. But at the end of the day you get (at least in my Maple 2015), the error

Error, (in pdsolve/numeric/match_PDEs_BCs) cannot handle systems with multiple PDE describing the time dependence of the same dependent variable, or having no time dependence.

My interpretation of this is that coupled systems such as yours are not handled in Maple.

system.mw

I see you have now moved to Laplace on the other thread, which is how I would have done it. But the answer to your question about BC2 is to use D rather than diff.

bc_2 := K_1*D[1](c)(a,t) = K_2*D[1](e)(a,t);

Here [1] means differentiate with respect to the first variable, and (a,t) is the point to avaluate at. For example 

c:=(r,t)->r^2*sin(t);
D[1](c)(a,t);

gives 2*a*sin(t).

ShapiroWilkWTest is in the Statistics package, which needs to be loaded by with(Statistics) or just use Statistics:-ShapiroWilkWTest. Perhaps there is some other problem that can be diagnosed if you upload your worksheet with your code, using the green up-arrow. Note that the output (vals) is an expression sequence and not a list.
 

Mat1:=Vector([$1..5]):

p:=Statistics:-ShapiroWilkWTest(Mat1,level=0.05,output='pvalue')

HFloat(0.9548265643483067)

vals:=Statistics:-ShapiroWilkWTest(Mat1,level=0.05)

hypothesis = true, pvalue = HFloat(0.9548265643483067), statistic = HFloat(0.986713744)

p:=eval(pvalue,[vals]);

HFloat(0.9548265643483067)

The following also works, but you need to know that pvalue is second in the sequence, so it is better to use the above methods.

p:=rhs(vals[2]);

HFloat(0.9548265643483067)

``

 

Download ShapiroWilkWTest.mw

Don't know much about this, but seems DEtools:-reduce_order will do what you want.
 

restart

with(PDEtools):

eq := (diff(U(z), z))^3*(diff(U(z), z, z))+(diff(U(z), z))*(diff(U(z), z, z, z, z))-(diff(U(z), z, z))*(diff(U(z), z, z, z));

(diff(U(z), z))^3*(diff(diff(U(z), z), z))+(diff(U(z), z))*(diff(diff(diff(diff(U(z), z), z), z), z))-(diff(diff(U(z), z), z))*(diff(diff(diff(U(z), z), z), z))

Symmetries

syms := symgen(eq);

[_xi = 0, _eta = 1], [_xi = 1, _eta = 0], [_xi = 1, _eta = 1], [_xi = z, _eta = 0]

Use the symmetries to find a first order ode

reduce_order(eq, syms, output = reduced_ode);

diff(_j(_h), _h) = -_j(_h)*(3+(_h^4+4*_h^2)*_j(_h)^2-6*_j(_h)*_h)/_h

This form shows meaning of _h etc

reduce_order(eq, syms);

U(z) = ODESolStruc(Int(_h*exp(-2*(Int(_j(_h), _h))-2*_C3)*(exp(Int(_j(_h), _h)+_C3))^2*_j(_h), _h)+_C1, [{diff(_j(_h), _h) = -_j(_h)*(3+(_h^4+4*_h^2)*_j(_h)^2-6*_j(_h)*_h)/_h}, {_h = (diff(U(z), z))^2/(diff(diff(U(z), z), z)), _j(_h) = -(diff(diff(U(z), z), z))^3/((diff(U(z), z))^2*((diff(U(z), z))*(diff(diff(diff(U(z), z), z), z))-2*(diff(diff(U(z), z), z))^2))}, {z = Int(_h*exp(-2*(Int(_j(_h), _h))-2*_C3)*_j(_h)*exp(Int(_j(_h), _h)+_C3), _h)+_C2, U(z) = Int(_h*exp(-2*(Int(_j(_h), _h))-2*_C3)*(exp(Int(_j(_h), _h)+_C3))^2*_j(_h), _h)+_C1}])

``

NULL

 

Download integration.mw

You can replace the assumption by another assumption (including "anything", which is no assumption), but I don't think there is an unassume feature, which I think is what you are asking about. Edit: Not correct - see @Preben Alsholm's correct answer.

restart

A := Omega:

true

The following removes the tilde but not the assumption

B := 'Omega';

Omega

true

Replace the assumption by something else

assume(Omega::anything);

is(B > 0);

false

B;

Omega

``

 

Download assumetest.mw

If you set Digits:=20, then the last values in the sequence will be 4. In approximate arithmetic, at some point x and x+1 have the same approximation, and then the difference in the logs will be zero.

[1$5] gives [1,1,1,1,1]

In general, one does not find the inverse of a matrix if it is only required as an internediate step. If the vector you are going to premultiply with is x^t, and the result is y^t, then (treating x as a column vector so x^t is a row vector):

y^t = x^t.M^(-1)

y^t.M = x^t

M^t.y = x

M.y = x (symmetric)

So LinearSolve(M,x) gives y.

It is better to do the LinearSolve with simple symbolic entries, then substitute in the complicated ones. You will need to add your required x[1], x[2], x[3] to vals:

mat.mw

Edit: in your extended document the vector x is S2 or S3, and you have some further calculations. I updated your document to complete the calculations in document mode here. The results are very long; remove the colons to see them. Simplifying is slow but reduces the size by a factor of 3.

matrix_inverse_3.mw

or as a worksheet:

matrix_inverse_3w.mw

First 40 41 42 43 44 45 46 Last Page 42 of 83