Dr. David Harrington

3252 Reputation

17 Badges

18 years, 39 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 professor of chemistry at the University of Victoria, BC, Canada, where 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 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.


A := Omega:


The following removes the tilde but not the assumption

B := 'Omega';



Replace the assumption by something else


is(B > 0);






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:


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.


or as a worksheet:


indets(expr,name) will do this. There are various refinements depending on whether you want to include Pi and other named constants or just variables or what you want to do with subscripted symbols.

s := a*exp(x[1])*Pi;



{a, x[1], exp(x[1])}

indets(s, name);

{Pi, a, x[1]}

indets(s, assignable(name));

{a, x[1]}

indets(s, symbol);

{Pi, a}



Download indets.mw

odeplot can plot expressions involving the numerical answer. Assuming a,b, and c are numbers and sol is the output from dsolve, then

plots:-odeplot(sol, [x,a*u1(x)+b*u2(x)+c*u3(x)],0..5)

where 0..0.5 is the range of x to solve and plot over.

ans1[12..14,3] is an Array with three plots. So you can get the 200x2 Matrix contents for each; combine them into a 200x6 Matrix, and then select the columns that you want, which I assume are 1 (x values?), 2, 4, 6 (three sets of y values?). So the following gives what I think you want:


Complexplot can draw points for the phasors, or vectors if you draw a line from the origin to the point.



f := 3*cos(2*t-(1/4)*Pi);



Write as a*cos(2*t)+b*sin(2*t), then the phasor is a-b*I (using the phase convention in the book, which is that cos(n*t) has phase zero).




Once we have the complex number (phasor), the angle (argument) and magnitude are




polar(3, -(1/4)*Pi)

The polar form can be written as an exponential, but Maple converts it to the real and imaginary form.



Routine to convert to a phasor for n*t component.

phasor := proc (s, nt) options operator, arrow; coeff(combine(expand(s)), cos(nt))-I*coeff(combine(expand(s)), sin(nt)) end proc:

phasor_f := phasor(f, 2*t);



phasor_s := phasor(f+g, 2*t);



convert(phasor_s, polar);

polar((((3/2)*2^(1/2)+2*3^(1/2))^2+(-(3/2)*2^(1/2)+2)^2)^(1/2), arctan((-(3/2)*2^(1/2)+2)/((3/2)*2^(1/2)+2*3^(1/2))))

polar(5.586739397, -0.2171747628e-1)

The three points in the complex plane

complexplot([phasor_f, phasor_g, phasor_s], style = point, symbol = solidcircle, symbolsize = 20, color = [red, blue, black]);

Draw them as vectors from the origin. Red vector plus blue vector gives magenta vector.

pltf := plots:-complexplot([0, phasor_f], colour = red):



Download complex.mw

You can use subsindets, using the transformer to increment a counter as a side effect. The sin(sin(x)) case then gives 2.

Edit: updated to two-argument procedure.


C:=proc(expr,t::type) local count;
         proc(f) count:=count+1; f end proc);
end proc:









Download subsindets.mw

You can just use the phi(t)=phi_end. Despite the numerical concerns, I regularly use this without problems.

Edit: the help page notes: "When a root-finding trigger fires, the value of the expression in the root finder is only an approximate zero due to numerical round-off. What this means is that f(t,y(t)) may evaluate, with respect to the current solution, to a value slightly above or slightly below zero. "

So I think that it looks for phi_end between the values of phi at each step.

(worksheet not displaying right now)

Download Events.mw


'R[1]":= should just be R[1]:=. The ' on the left does not match the " on the right.

Differentiation can find the powers easily.


r := proc (x) options operator, arrow; a[0]+a[1]*x-a[2]*x^2+a[8]*x^(8/5)-a[h]*x^h+k*x^(-b/a) end proc

proc (x) options operator, arrow; a[0]+a[1]*x-a[2]*x^2+a[8]*x^(8/5)-a[h]*x^h+k*x^(-b/a) end proc

mnmls := [op(r(x))];

[a[0], a[1]*x, -a[2]*x^2, a[8]*x^(8/5), -a[h]*x^h, k*x^(-b/a)]

powers := map(proc (z) options operator, arrow; x*(diff(z, x))/z end proc, mnmls);

[0, 1, 2, 8/5, h, -b/a]

cofs := zip(proc (mn, pw) options operator, arrow; mn/x^pw end proc, mnmls, powers);

[a[0], a[1], -a[2], a[8], -a[h], k]

A := LinearAlgebra:-Transpose(`<|>`(`<,>`(powers[]), `<,>`(cofs[])))

A := Matrix(2, 6, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 2, (1, 4) = 8/5, (1, 5) = h, (1, 6) = -b/a, (2, 1) = a[0], (2, 2) = a[1], (2, 3) = -a[2], (2, 4) = a[8], (2, 5) = -a[h], (2, 6) = k})



Download diff.mw

plot3d(f(x, y), x = -3 .. 3, y = -3 .. 3, view = [default, default, -8 .. 8], style = surfacecontour);


plot3d(f,  -3 .. 3,  -3 .. 3, labels = [x,y], view = [default, default, -8 .. 8], style = surfacecontour);

It goes to infinity, but I don't see any discontinuities.

(There is more to see if you play around with the ranges.)

Download plot.mw

You had a number of issues. I fixed them except for your last dsolve. Most were 2D math issues. Your first ode was missing a multiplication (or space) after M. Your rho[f] was actually rho[f(x)] but the "declare" hid that fact. (Better to use rho__f to avoid these types of issues.)

You were missing a value for eta, which I arbitrarily set to 1.

Since it is a boundary value problem, it won't use Runge-Kutta 4th-5th, which is a method for initial value problems.

For your last one you have an ode in theta, but it has f(x) in, which needs to be specified, or you need to have another ode (and conditions) as well.


On windows the following works as a URL to open Text.txt with the default application (notepad)


Edit: I see file:///c:/Users/dharr/Desktop/Test.txt gives the same result, which is @acer's method.

1 2 3 4 5 6 7 Last Page 1 of 41