dharr

Dr. David Harrington

8455 Reputation

22 Badges

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

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

Differentiation can find the powers easily.
 

restart

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);

or

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.

HP-Numeric_-Komathi.mw

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

file://localhost/c:/Users/dharr/Desktop/Test.txt

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

I don't really understand your notation or exactly what you want. Perhaps you could clarify for this simple example, for which the entropy (as I understand it) is easily calculated.
 

Arranging i atoms on n sites, zero or one per site. Number of ways is

W := binomial(n, i);

binomial(n, i)

pmf?

pmf := W/2^n;

binomial(n, i)/2^n

For a large n, the fraction of sites occupied is theta"=i/(n) "and the configurational entropy is ln(W)

S := `assuming`([limit(ln(binomial(n, theta*n))/n, n = infinity)], [theta > 0, theta < 1]);

-theta*ln(theta)+theta*ln(-theta+1)-ln(-theta+1)

``

 

 

Download entropy.mw

Not sure what is going on, but this gets the right form from rsolve.
 

restart

Sum. Sum of zero things is zero

eqs := s(n+1) = s(n)+x[n+1];

s(n+1) = s(n)+x[n+1]

s(0) = 0

Desired form

rsolve({eqs, eqs0}, s(n));

Sum(x[n0], n0 = 1 .. n)

Mean is sum/n, but if n=0 we will define it as zero

equ := u(n+1) = s(n+1)/(n+1);

u(n+1) = s(n+1)/(n+1)

u(0) = 0

rsolve({eqs, eqs0, equ, equ0}, {s(n), u(n)});

{s(n) = Sum(x[n0], n0 = 1 .. n), u(0) = 0, u(n) = (Sum(x[n0], n0 = 1 .. n))/n}

``

 

Download rsolve.mw

Within a procedure, _npassed tells how many arguments were passed to it, and _passed gives the sequence of arguments. For example to make a procedure that takes the mean of some numbers you can use

f:=()->add(_passed)/_npassed;

Then f(1,3,5) returns 3.

In Maple 18, these were probably nargs and args, so perhaps

f:=()->add(i,i in args)/nargs;

 

You probably want the VIEW part, which you can extract as follows:
 

p := plot(sin(x), x = -1 .. 10):

v := op(select(type, p, specfunc(VIEW)));

VIEW(-1. .. 10., DEFAULT, _ATTRIBUTE("source" = "mathdefault"))

``

 

Download view.mw

Not very clear what you want. I think you want to find where the zero entries are and then replace them. Here is one way to do that; you will need to convert your older array to Array with convert(dumX,Array) first.

Or perhaps you want the sum of the numeric values.

[worksheet not displaying properly right now]

Array.mw

You can use sprintf to format a number into a string, with control over the number of decimal places etc. Here are some examples:

d := 0.75e-4:
sprintf("d = %g",d);
sprintf("d = %8.3e",d);

"d = 7.5e-05"

"d = 7.500e-05"

d:=0.75:
sprintf("d = %g",d);
sprintf("d = %.3f",d);

"d = 0.75"

"d = 0.750"

``

Download sprintf.mw

It would help if there are some initial/boundary conditions, and perhaps h(t). Maple 2015 gives:
 

restart;NULL

Arbitrary h(t) and lambda

  odeSys:= diff(x(t),t)=y(t),
           diff( y(t), t) =z(t),
           diff(z(t),t)=-lambda*y(t)-h(t);
  dsolve({odeSys},{x(t),y(t),z(t)}) assuming lambda>0;

diff(x(t), t) = y(t), diff(y(t), t) = z(t), diff(z(t), t) = -lambda*y(t)-h(t)

{x(t) = Int(-(-sin(lambda^(1/2)*t)*_C3*lambda^(1/2)-cos(lambda^(1/2)*t)*_C2*lambda^(1/2)+(Int(cos(lambda^(1/2)*t)*h(t), t))*sin(lambda^(1/2)*t)-(Int(sin(lambda^(1/2)*t)*h(t), t))*cos(lambda^(1/2)*t))/lambda^(1/2), t)+_C1, y(t) = -(-sin(lambda^(1/2)*t)*_C3*lambda^(1/2)-cos(lambda^(1/2)*t)*_C2*lambda^(1/2)+(Int(cos(lambda^(1/2)*t)*h(t), t))*sin(lambda^(1/2)*t)-(Int(sin(lambda^(1/2)*t)*h(t), t))*cos(lambda^(1/2)*t))/lambda^(1/2), z(t) = -lambda^(1/2)*sin(lambda^(1/2)*t)*_C2+lambda^(1/2)*cos(lambda^(1/2)*t)*_C3-cos(lambda^(1/2)*t)*(Int(cos(lambda^(1/2)*t)*h(t), t))-sin(lambda^(1/2)*t)*(Int(sin(lambda^(1/2)*t)*h(t), t))}

Find lambda as well

dsolve({odeSys},{x(t),y(t),z(t),lambda}) assuming lambda>0;

{lambda = (cos(t/_C1)^2*h(t)*_C1^2+sin(t/_C1)^2*h(t)*_C1^2-h(t)*_C1^2+cos(t/_C1)*(Int(sin(t/_C1)*h(t), t))*_C1-sin(t/_C1)*(Int(cos(t/_C1)*h(t), t))*_C1+cos(t/_C1)*_C2+sin(t/_C1)*_C3)/(_C1^2*(-sin(t/_C1)*(Int(cos(t/_C1)*h(t), t))*_C1+cos(t/_C1)*(Int(sin(t/_C1)*h(t), t))*_C1+sin(t/_C1)*_C3+cos(t/_C1)*_C2)), x(t) = Int(-sin(t/_C1)*(Int(cos(t/_C1)*h(t), t))*_C1+cos(t/_C1)*(Int(sin(t/_C1)*h(t), t))*_C1+sin(t/_C1)*_C3+cos(t/_C1)*_C2, t)+_C4, y(t) = sin(t/_C1)*_C3+cos(t/_C1)*_C2+(-(Int(cos(t/_C1)*h(t), t))*sin(t/_C1)+(Int(sin(t/_C1)*h(t), t))*cos(t/_C1))*_C1, z(t) = (-sin(t/_C1)*(Int(sin(t/_C1)*h(t), t))*_C1-cos(t/_C1)*(Int(cos(t/_C1)*h(t), t))*_C1-sin(t/_C1)*_C2+cos(t/_C1)*_C3)/_C1}

``

 

Download system.mw

Your Excel file now has data at each grid point, so perhaps surfdata gives what you want?
 

restart;

dat:=ExcelTools:-Import(cat(currentdir(),"/PlotTest.xlsx"),1,"B2:J10"):

plots:-surfdata(dat,0.1..0.9,0.1..0.9);

``


 

Download Yasi.mw

Here is the nearest I can think of.

F:=proc(v::string,k)
   local F1,F2;
   uses DocumentTools:-Layout;
   F1:=Font(cat(v,"]"),color=blue):
   F2:=Font(sprintf(" is %g",k),color=red):
   DocumentTools:-InsertContent(Worksheet(Group(Input(Textfield(F1,F2))))):
end proc:
F("1:1",4) 

produces  "1:1] is 4" in a new input group.

Download Colortext.mw

You ask for op(1,eq5), which is the left-hand side of:

You did not indicate phi(x), just phi, so (the inner) differentiaton wrt xi gives zero (phi does not depend on xi). The same thing happens with the outer differentiation. So value on this gives zero. 

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