dharr

Dr. David Harrington

8205 Reputation

22 Badges

20 years, 337 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

Changes in red.
 

 RK2skritt:=proc(FR::procedure,xo,yo,vxo,vyo,h)
 local x, y, vx, vy, r, kx1, kx2, kx3, kx4, ky1, ky2, ky3, ky4, lx1, lx2, lx3, lx4, ly1, ly2, ly3, ly4, tmp;
 r:=sqrt(xo*xo+yo*yo);
 tmp:=-(h*FR(r))/(r);
 lx1:=h*vxo;
 ly1:=h*vyo;
 kx1:=tmp*xo;
 ky1:=tmp*yo;
 lx2:=h*(vxo+0.5*kx1);
 ly2:=h*(vyo+0.5*ky1);
 r:=sqrt((xo+0.5*lx1)^(2)+(yo+0.5*ly1)^(2));
 tmp:=-(h*FR(r))/(r);
 kx2:=tmp*(xo+0.5*lx1);
 ky2:=tmp*(yo+0.5*ly1);
 lx3:=h*(vxo+0.5*kx2);
 ly3:=h*(vyo+0.5*ky2);
 r:=sqrt((xo+0.5*lx2)^(2)+(yo+0.5*ly2)^(2));
 tmp:=-(h*FR(r))/(r);
 kx3:=tmp*(xo+0.5*lx2);
 ky3:=tmp*(yo+0.5*ly2);
 lx4:=h*(vxo+kx3);
 ly4:=h*(vyo+ky3);
 r:=sqrt((xo+lx3)^(2)+(yo+ly3)^(2));
 tmp:=-(h*FR(r))/(r);
 kx4:=tmp*(xo+lx3);
 ky4:=tmp*(yo+ly3);  #edit - one more here
 x:=xo+(lx1+2*lx2+2*lx3+lx4)/(6);
 y:=yo+(ly1+2*ly2+2*ly3+ly4)/(6);
 vx:=vxo+(kx1+2*kx2+2*kx3+kx4)/(6);
 vy:=vyo+(ky1+2*ky2+2*ky3+ky4)/(6);
 [x,y,vx,vy]; end proc:

 

 

Download proc.mw

There is a missing *. The differentiation works in Maple 2017.
 

Download Diff.mw

 

 

restart

Case 1

de1:=diff(U(x),x,x)=0;
bc1:=U(0)=10,U(L)=20;
ans1:=dsolve({de1,bc1},U(x));

diff(diff(U(x), x), x) = 0

U(0) = 10, U(L) = 20

U(x) = 10*x/L+10

Case 2

de2:=diff(U(x),x,x)=-x^2;
bc2:=U(0)=T,D(U)(L)=0;
ans2:=dsolve({de2,bc2},U(x));

diff(diff(U(x), x), x) = -x^2

U(0) = T, (D(U))(L) = 0

U(x) = -(1/12)*x^4+(1/3)*L^3*x+T

 

 


 

Download rod.mw

Like this?

NULL

restart

n := 4; C := proc (K) options operator, arrow; Vector([seq(cos(2*Pi*K*l/n), l = 0 .. n-1)]) end proc; S := proc (K) options operator, arrow; Vector([seq(sin(2*Pi*K*l/n), l = 0 .. n-1)]) end proc

4

proc (K) options operator, arrow; Vector([seq(cos(2*Pi*K*l/n), l = 0 .. n-1)]) end proc

proc (K) options operator, arrow; Vector([seq(sin(2*Pi*K*l/n), l = 0 .. n-1)]) end proc

C(2); S(3)

Vector[column]([[1], [-1], [1], [-1]])

Vector[column]([[0], [-1], [0], [1]])

These two are orthogonal

C(2).S(3)

0

C(2).C(2)

4

 

NULL


 

Download orthogonal.mw

I did G11; the others are similar

Transfer_function.mw

In the File Menu under Document Properties, you should have an attribute named Active which is false for a regular help page and true for an active worksheet.

in 1D input:

ode:=diff(y(x),x,x)=2*y(x)+1;
dsolve(ode);
 

does work, so this is probably incorrect entry of the derivative in 2-D math. [Edit: actually the error message confirms this.] Use the right-click menu 2-D math/convert to 1D math input and see if it looks like the above. If not, use 1-D input (ctrl-M) before the input, or use the expression palette for the derivative and use "^" to raise the powers of 2.

I don't understand exactly what you mean - if you want real-only frequency domain, you need the time domain array to have the real part  symmetric about the centre and the imaginary part antisymmetric about the centre.

Edit: And here is a complex example that works pretty much as I would expect:

restart;

with(DiscreteTransforms):

N:=2^10;df:=.2;dt:=1/df;T1:=500.;

1024

.2

5.000000000

500.

tvec:=Vector(N,i->i*dt):
fvec:=Vector(N,i->i*df):

fidr:=Vector(N,i->cos(2*Pi*df*i)*exp(-dt*i/T1)):
fidi:=Vector(N,i->sin(2*Pi*df*i)*exp(-dt*i/T1)):
fid:=fidr+I*fidi:

plot(tvec,fidr);

spec:=FourierTransform(fid):

plot(fvec,map(abs,spec)); #magnitude

plot(fvec,map(Im,spec));  #imaginary part

plot(fvec,map(Re,spec));  #real part

 


 

Download fid.mw


 

restart;
with(ThermophysicalData);
with(ThermophysicalData[CoolProp]);
fluid := "R717"; T__in := 310; p__in := 11*10^5; v__in := 10;  A := 0.005;
h__in := Property(massspecificenthalpy, T = T__in, P = p__in, fluid);
rho__in := Property(density, T = T__in, P = p__in, fluid);
m := A*v__in*rho__in;
p__out := 2*10^5;
eq1 := h__out = Property("massspecificenthalpy", "temperature" = T__out, "P" = p__out, fluid);
eq2 := rho__out = Property("D", "temperature" = T__out, "P" = p__out, fluid);
eq3 := h__in + v__in^2/2 = h__out + v__out^2/2;
eq4 := m = A*v__out*rho__out;

res := fsolve({eq1, eq2, eq3, eq4});

[CoolProp, PHTChart, Property, PsychrometricChart, TemperatureEntropyChart]

[HAPropsSI, PhaseSI, Props1SI, PropsSI]

"R717"

310

1100000

10

0.5e-2

1655590.94731116970

8.15132757401520891

.4075663787

200000

h__out = ThermophysicalData:-Property("massspecificenthalpy", "temperature" = T__out, "P" = 200000, "R717")

rho__out = ThermophysicalData:-Property("D", "temperature" = T__out, "P" = 200000, "R717")

1655640.947 = h__out+(1/2)*v__out^2

.4075663787 = 0.5e-2*v__out*rho__out

{T__out = 285.0179004, h__out = 1654113.289, v__out = 55.27490598, rho__out = 1.474688637}

 


 

Download CoolProp.mw

Under the file/open menu, you can open a Mathematica notebook. I haven't tried this, but presumably it automates what can be done by the commands that @tomleslie pointed out.

See the help for the GraphTheory package, ?GraphTheory. This is a hard problem (see the Wikipedia page), and as far as I can see, Maple has no direct commands for this. Some of the commands there may help you, but if you want an efficient routine you would probably need to write something for the class of graphs you are interested in.


 

f := (a,b,c)->a*b*c;

proc (a, b, c) options operator, arrow; a*b*c end proc

F:=proc(f,val) local fargs;
fargs:=op(1,eval(f)); #parameter sequence
f(val,fargs[2..]);
end proc;

proc (f, val) local fargs; fargs := op(1, eval(f)); f(val, fargs[2 .. ()]) end proc

F(f,3);

3*b*c

 


 

Download fargs.mw

If you don't have tau = 0, then Maple will carry out operations that are generally valid, but may not be for tau=0. So if you then set tau=0, you may get an invalid result. For example here, the 2,2 entry has a denominator that becomes zero if tau=0, and so a division by zero problem arises, which would not have done if Maple had manipulated knowing tau=0.

To assume everything is positive works here
 

f := (Pi*x+2*c+2*m)/(`μ__c`*S)+2*`ε`/(`μ__a`*S)+(Pi*x+2*c)/(`μ__s`*S)

(Pi*x+2*c+2*m)/(mu__c*S)+2*epsilon/(mu__a*S)+(Pi*x+2*c)/(mu__s*S)

g := simplify(f, symbolic)

(((Pi*x+2*c+2*m)*mu__s+2*mu__c*((1/2)*Pi*x+c))*mu__a+2*epsilon*mu__c*mu__s)/(mu__c*S*mu__a*mu__s)

`assuming`([int(1/g, x = 0 .. w, AllSolutions)], [positive]) =
S*mu__c*mu__s*(ln(Pi*mu__a*mu__c*w+Pi*mu__a*mu__s*w+2*c*mu__a*mu__c+2*c*mu__a*mu__s+2*epsilon*mu__c*mu__s+2*m*mu__a*mu__s)-ln(2)-ln(c*mu__a*mu__c+c*mu__a*mu__s+epsilon*mu__c*mu__s+m*mu__a*mu__s))/(Pi*(mu__c+mu__s))
NULL

``


 

Download IntAssPositive.mw

 

Download Dirac2.mw
 

restart;

with(IntegrationTools):

int(Dirac(x),x=-infinity..infinity);

1

q:=Int(Dirac(x)^2,x=-infinity..infinity);
value(q);

Int(Dirac(x)^2, x = -infinity .. infinity)

int(Dirac(x)^2, x = -infinity .. infinity)

Now generally,

int(f(x)*Dirac(x-a),x=-infinity..infinity);

f(a)

So we may expect if a=0 and f(x)=Dirac(x), then the integral is Dirac(0). But we can't get it directly

int(Dirac(x)*Dirac(x),x=-infinity..infinity);

int(Dirac(x)^2, x = -infinity .. infinity)

Though integration by parts will do it.

Parts(q,Dirac(x));
value(%);

-(Int(Heaviside(x)*Dirac(1, x), x = -infinity .. infinity))

Dirac(0)

But it doesn't really help becasue Dirac(0) is not defined...


 

Download Dirac2.mw

 

First 60 61 62 63 64 65 66 Last Page 62 of 81