dharr

Dr. David Harrington

8205 Reputation

22 Badges

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

Altering the last two ranges gives a solution in which the theta3 and theta4 values are still in the ranges you want 

fsolve({f[1], f[2], f[3], f[4]}, {theta1 = 0 .. infinity, theta2 = 0 .. infinity, theta3 = 0 .. infinity, theta4 = 0 .. infinity});

Pointplot doesn't require the two lists to be interleaved:

F:=[1,4,6,7];
H:=[1,5,9,14];
plots:-pointplot(F,H,symbolsize=20);

 

While @acer's error messages are relatively comprehensible, @Carl Love's, covering the more complicated case, are hard to interpret for an average Maple user. (I know that @Rouben Rostamian  asked specifically for a single type check.) If the error message is only going to be seen by Rouben, then there isn't a problem, but if others will see it then several checks with their own error messages may be preferable. (In my case, the "others" can be me six months down the road when I've forgotten why I did that.) So I'd probably go for:

restart;

f:=proc(Z::[symbol,symbol]) local S:={a,b,c,d};
     if {Z[]} minus S <> {} then error "list elements can only be: %0",S[] end if;
     if nops({Z[]})=1 then error "list elements cannot be the same" end if;
     print("OK");
   end proc:
   

f([a,b,c]);

Error, invalid input: f expects its 1st argument, Z, to be of type [symbol, symbol], but received [a, b, c]

f([a,h]);

Error, (in f) list elements can only be: a, b, c, d

f([a,a]);

Error, (in f) list elements cannot be the same

f([a,b]);

"OK"

 


 

Download typecheck.mw

[Edit: as @Preben Alsholm  points out, the following explanation is wrong.] The k in your definition of B[1] and B[2] is different from the summation k, which is local to Sum. The easiest fix is:

NULL

restart

lambda := .3; mu := .7; xi := .2; u := 1

omega := lambda+mu+xi

alpha := 2*sqrt(lambda*mu)

.9165151390

F := evalf(Int(sum((BesselI(k-1, alpha*(u-y))-BesselI(k+1, alpha*(u-y)))*exp(-omega*(u-y)), k = 1 .. infinity), y = 0 .. u))

.7246342704

 

NULL


 

Download int.mw

Maple generally assumes variables are complex. evalc assumes they are real or you can explicitly make assumptions.


 

a:=conjugate(1-I*x*lambda)+1-I*x*lambda;

2+I*conjugate(x*lambda)-I*x*lambda

evalc(a);

2

a assuming real;

2

 


 

Download conjugate.mw


 

test:=proc(a) local b;
  b:=a^2;
end proc;

proc (a) local b; b := a^2 end proc

Output of test is the  result of the last statement in the procedure - this is the usual way to output a value from a procedure

c:=test(5);

25

test2:=proc(a) local b;
  b:=a^2;
  print(b);
end proc;

proc (a) local b; b := a^2; print(b) end proc

Output of test2 is the  result of the last statement in the procedure, but the print statement results in NULL (nothing) 

d:=test2(5);

25

"d := "

op(d);

Error, invalid input: op expects 1 or 2 arguments, but received 0

 


 

Download print.mw

That's debatable. In quantity calculus the number is considered multiplied by the unit, and so zero multiplied by any unit is zero. Just as a heading for a table or label for a plot axis in the form m / kg results in the number only, say 6, so m = 6*kg.

The problem is with the line 

return Reverse(revmons(n,d)):

You loaded both the ListTools and ArrayTools packages, both of which have a Reverse routine, and the error message shows that the ArrayTools one was used, but you want the ListTools one, so you should specify that:

return ListTools:-Reverse(revmons(n,d)):

 

Just extracting the expression I think you are worried about, collect( ,cos) collects the cosine parts, but there are two distinct ones. [Edit: simplify does the same thing.]

z:=4*conjugate(lambda)^2*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2-4*conjugate(lambda)^2*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2+8*abs(lambda)^2*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2+8*abs(lambda)^2*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2+4*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2*lambda^2-4*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2*lambda^2-16*abs(lambda)^2;

4*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2*conjugate(lambda)^2+8*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2*abs(lambda)^2+4*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2*lambda^2-4*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2*conjugate(lambda)^2+8*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2*abs(lambda)^2-4*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2*lambda^2-16*abs(lambda)^2

collect(z,cos);

(-4*lambda^2+8*abs(lambda)^2-4*conjugate(lambda)^2)*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2+(4*lambda^2+8*abs(lambda)^2+4*conjugate(lambda)^2)*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2-16*abs(lambda)^2

 


 

Download collect.mw

solve(f > 0, useassumptions)

 


Need consistent use of lists.

restart

A2 := 1.10744*nops4364; A4 := 1.124502164; ad := .5; ed := 0.1e-1; pd := 21; ld := .3

f := unapply(3*x^2-2*x^3-1.238616691*x^2*(x-1)^2-.7382714588*x^2*(x-1)^3+.1921034396*x^2*(x-1)^4+.5253305667*x^2*(x-1)^5+.7364291997*x^2*(x-1)^6+1.032724351*x^2*(x-1)^7+.8058204155*x^2*(x-1)^8+.3290860035*x^2*(x-1)^9, x)

t := unapply(.339997432+1.547096375*x^2-2.488736512*x^3+8.154594212*x^4-15.63643668*x^5+15.85832377*x^6-8.734300202*x^7+1.959461605*x^8, x)

b1 := f(x)

b2 := diff(f(x), x)

b3 := diff(f(x), x, x)

b4 := t(x)

b5 := diff(t(x), x)

An := A4*(1+(4/3)*ad)*(b5^2+b4^2/ld^2)+4*ed*pd*(b2^2/x^2+b1^2/x^4-b1*b2/x^3)/ld

As := [seq(An, x = 0.1e-2 .. 1, 0.5e-1)]

xx := [seq(x, x = 0.1e-2 .. 1, 0.5e-1)]

with(plots)

plots:-display(plot(xx, As, style = point), plot(An, x = 0.1e-2 .. 1), color = blue, linestyle = solid, labels = ["&eta;", "f'"], thickness = 1, labeldirections = [horizontal, vertical], labelfont = ['TIMES', 'BOLDOBLIQUE', 16], size = [450, 450], axes = box)

NULL


 

Download mp.mw

I made some changes (in red). But note that the loop variable i has a value after the loop is over, so you can't use it as a generic variable unless you unassign it: i:='i' or use uneval quotes. In the final solve you will need to generate (in)equations for all the i and j values you are interested in.

chinasa1.mw


 

restart

with(LinearAlgebra); with(VectorCalculus); _local(gamma)

eqx := x*(1-x)-x*y; eqy := y*(delta-beta*y/x)-alpha*y/(gamma+y)

x*(1-x)-x*y

y*(delta-beta*y/x)-alpha*y/(gamma+y)

E__2, E__3 := solve({eqx, eqy}, {x, y}, explicit)[2 .. 3]

{x = 1-(1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta), y = (1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta)}, {x = 1+(1/2)*(beta*gamma+delta*gamma+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2)-alpha-delta)/(beta+delta), y = -(1/2)*(beta*gamma+delta*gamma+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2)-alpha-delta)/(beta+delta)}

The following is different from what you typed in for x__2: beta*gamma+2*beta+delta*gamma+delta-alpha-sqrt(alpha^2-2*alpha*(beta*gamma+delta*gamma+2*beta+delta)+(beta*gamma+delta*gamma+delta)^2)/(2*(beta+delta))

eval(x, E__2); simplify(%)

(beta*gamma+delta*gamma+2*beta-alpha+delta-((beta+delta)^2*gamma^2-2*(alpha-delta)*(beta+delta)*gamma+alpha^2+(-4*beta-2*delta)*alpha+delta^2)^(1/2))/(2*beta+2*delta)

J := Jacobian([eqx, eqy], [x, y])

J := Matrix(2, 2, {(1, 1) = 1-2*x-y, (1, 2) = -x, (2, 1) = y^2*beta/x^2, (2, 2) = delta-2*beta*y/x-alpha/(gamma+y)+alpha*y/(gamma+y)^2})

TrJ := Trace(J)

1-2*x-y+delta-2*beta*y/x-alpha/(gamma+y)+alpha*y/(gamma+y)^2

diff(eval(TrJ, E__2), alpha)

(1/2)*(1+(1/2)*(-2*beta*gamma-2*delta*gamma+2*alpha-4*beta-2*delta)/(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta)-beta*(1+(1/2)*(-2*beta*gamma-2*delta*gamma+2*alpha-4*beta-2*delta)/(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/((beta+delta)*(1-(1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta)))-(1/2)*beta*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))*(1+(1/2)*(-2*beta*gamma-2*delta*gamma+2*alpha-4*beta-2*delta)/(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/((beta+delta)^2*(1-(1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta))^2)-1/(gamma+(1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta))+alpha*(1+(1/2)*(-2*beta*gamma-2*delta*gamma+2*alpha-4*beta-2*delta)/(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/((gamma+(1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta))^2*(beta+delta))+(1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/((beta+delta)*(gamma+(1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta))^2)-(1/2)*alpha*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))*(1+(1/2)*(-2*beta*gamma-2*delta*gamma+2*alpha-4*beta-2*delta)/(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/((beta+delta)^2*(gamma+(1/2)*(-beta*gamma-delta*gamma+alpha+delta+(beta^2*gamma^2+2*beta*delta*gamma^2+delta^2*gamma^2-2*alpha*beta*gamma-2*alpha*delta*gamma+2*beta*delta*gamma+2*delta^2*gamma+alpha^2-4*alpha*beta-2*alpha*delta+delta^2)^(1/2))/(beta+delta))^3)

``


 

Download 1111.mw

plot([Th-273,subs(Tc=400,n*alpha*dT/2),Th=300..700]);

 

As @acer pointed out, it doesn't currently make much sense, but if you wanted the running integral:

restart

integ := 2*sqrt((a^2+1)/(x^2+1))/sqrt((x^2+1)*exp(4*m*(arctan(a)-arctan(x)))-a^2-1)

2*((a^2+1)/(x^2+1))^(1/2)/((x^2+1)*exp(4*m*(arctan(a)-arctan(x)))-a^2-1)^(1/2)

params:={m=1,a=3};

{a = 3, m = 1}

plot(eval(integ,params),x=eval(a,params)..10);

intt:=Int(integ,x=a..xx);

Int(2*((a^2+1)/(x^2+1))^(1/2)/((x^2+1)*exp(4*m*(arctan(a)-arctan(x)))-a^2-1)^(1/2), x = a .. xx)

plot(eval(intt,params),xx=eval(a,params)..10);

 


 

Download running_integral.mw

First 57 58 59 60 61 62 63 Last Page 59 of 81