dharr

Dr. David Harrington

2203 Reputation

15 Badges

17 years, 94 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

A 3d plot is a good way to get an overall picture. 

plot3d(z,x=-1..1,y=-1..1,style=surfacecontour);

If you want specific z values for your contours, you can use the contours option:

plot3d(z,x=-1..1,y=-1..1,style=surfacecontour,contours=[-30,-20,-10,0,10,20,30,40]);

 

I think you wanted print(p) in B. But I agree there are no output plot files generated. (I'm using Maple 2015.) I usually use the interface command to do these plot outputs rather than plotsetup, e.g., interface(plotdevice=ps, etc), and maybe that is a clue. I'm guessing that since it is running headless, that means that none of those interface features work, and so plots cannot be output in this way.

You have 3 equations but have specified only one unknown. You should specify which three variables to solve for; then you will get these three in terms of the other variables. For example you get a solution with

solve({eq1, eq2, eq3}, {xk,xk1,xk2});

 

I would use implicitplot for this. I'm assuming z is a complex variable.

restart; with(plottools); with(plots)

 

In John Stillwell's book "The Four Pillars of Geometry" he declares the following to be the equations of non-Euclidean "lines" where A,B and C are all non-zero


What Maple code will plot this equation for given values of A, B and C?

Equation := A*z*conjugate(z)+B*(z+conjugate(z))+C = 0:

plots:-implicitplot(eval(Equation, {A = 1.5, B = 2, C = -1, z = x+I*y}), x = -3 .. 1, y = -2 .. 2, labels = [Re(z), Im(z)], scaling = constrained);
``

``

 

Download NonEuclideanLines.mw

To get RK4, use dsolve({IC, ODE}, numeric, method=classical[rk4], stepsize=h). See the help page ?dsolve,numeric.

Not sure exactly what you want to do, but you may find the singular command useful, which finds the singularities. You can add the option 'CauchyPrincipalValue' to an integral, e.g., int(1/x^3, x = -1 .. 2, 'CauchyPrincipalValue'). See the ?int,details help page. But as @vv points out, numerical integrals done like evalf(Int(...)) do not work with this option.

The problem is that Maple sees the " as the start of a string, but doesn't find the matching " at the end of the string, so thinks you aren't finished entering your command. You can enter `Trees_aren"t_pink`!; to solve this - this is the factorial of `Trees_aren"t_pink`; or if you wanted the ! to be part of the name then `Trees_aren"t_pink!`;
 

Your last line has add*rhs. Not sure what you want to do, but perhaps:
 

restart;

A := Matrix([[1, 2, 1, 3], [1, 1, 2, 1], [1, -2, 5, -11]]);

cs := LinearAlgebra:-ColumnSpace(A);

cnames := [seq(c || j, j = 1 .. numelems(cs))];

cvals := seq(solve([entries(A[() .. (), k] -~ add(`*`~(cnames, cs)), 'nolist')], cnames)[], k = 1 .. op([1, 2], A));

seq(add(rhs~(cvals[k]) *~ cs), k = 1 .. op([1, 2], A));

 

A := Matrix(3, 4, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 1, (1, 4) = 3, (2, 1) = 1, (2, 2) = 1, (2, 3) = 2, (2, 4) = 1, (3, 1) = 1, (3, 2) = -2, (3, 3) = 5, (3, 4) = -11})

cs := [Vector(3, {(1) = 1, (2) = 0, (3) = 0}), Vector(3, {(1) = 0, (2) = 1, (3) = 0}), Vector(3, {(1) = 0, (2) = 0, (3) = 1})]

cnames := [c1, c2, c3]

cvals := [c1 = 1, c2 = 1, c3 = 1], [c1 = 2, c2 = 1, c3 = -2], [c1 = 1, c2 = 2, c3 = 5], [c1 = 3, c2 = 1, c3 = -11]

Vector(3, {(1) = 1, (2) = 1, (3) = 1}), Vector(3, {(1) = 2, (2) = 1, (3) = -2}), Vector(3, {(1) = 1, (2) = 2, (3) = 5}), Vector(3, {(1) = 3, (2) = 1, (3) = -11})

``


 

Download add.mw

Less for your stacking example, but generally useful is copy(vec) or LinearAlgebra:-Copy(vec), which makes a new copy of the vector (or rtable in general).

e has no special meaning, use exp(), and pi is Pi. (And that integral is definite, since it goes between specific values; I think you mean improper). Now it is fixed, hitting enter on that line executes it.

Download Integral.mw

You can use ListTools:-MakeUnique to remove the duplicates from a list.


 

restart

with(ListTools):

a := [Vector(2, [1, 0]), Vector(2, [2, 0]), Vector(2, [1, 0])]

a := [Vector(2, {(1) = 1, (2) = 0}), Vector(2, {(1) = 2, (2) = 0}), Vector(2, {(1) = 1, (2) = 0})]

MakeUnique(a)

[Vector(2, {(1) = 1, (2) = 0}), Vector(2, {(1) = 2, (2) = 0}), Vector(2, {(1) = 1, (2) = 0})]

MakeUnique(a, 1, LinearAlgebra:-Equal)

[Vector(2, {(1) = 1, (2) = 0}), Vector(2, {(1) = 2, (2) = 0})]

``


 

Download Unique.mw

As @Sauberschrauber says, you probaby want exp rather than  "e", which is a symbol without special meaning. But you also have used "." for multiply rather than "*". There is unlikely to be an analytical solution.

restart

fn1 := int((a-x)*lambda*exp(-lambda*x), x = 0 .. a);

(lambda*a+exp(-lambda*a)-1)/lambda

fn2 := `assuming`([int((a-x)*lambda*exp(-lambda*x), x = a .. infinity)], [positive]);

-exp(-lambda*a)/lambda

f2 := sum((b1*fn1+b2*fn2)/lambda, lambda = 1 .. c);

b1*a*Psi(c+1)+b1*a*gamma-(exp(a)*LerchPhi(exp(-a), 2, c)*exp(-(c+1)*a)*c^2-polylog(2, exp(-a))*c^2-exp(-(c+1)*a)*exp(a))*b1/c^2+b1*Psi(1, c+1)-(1/6)*b1*Pi^2+(exp(a)*LerchPhi(exp(-a), 2, c)*exp(-(c+1)*a)*c^2-polylog(2, exp(-a))*c^2-exp(-(c+1)*a)*exp(a))*b2/c^2

df2 := diff(f2, a);

b1*Psi(c+1)+b1*gamma-(exp(a)*LerchPhi(exp(-a), 2, c)*exp(-(c+1)*a)*c^2-exp(a)*exp(-a)*(LerchPhi(exp(-a), 1, c)/exp(-a)-c*LerchPhi(exp(-a), 2, c)/exp(-a))*exp(-(c+1)*a)*c^2+exp(a)*LerchPhi(exp(-a), 2, c)*(-1-c)*exp(-(c+1)*a)*c^2-ln(1-exp(-a))*c^2-(-1-c)*exp(-(c+1)*a)*exp(a)-exp(-(c+1)*a)*exp(a))*b1/c^2+(exp(a)*LerchPhi(exp(-a), 2, c)*exp(-(c+1)*a)*c^2-exp(a)*exp(-a)*(LerchPhi(exp(-a), 1, c)/exp(-a)-c*LerchPhi(exp(-a), 2, c)/exp(-a))*exp(-(c+1)*a)*c^2+exp(a)*LerchPhi(exp(-a), 2, c)*(-1-c)*exp(-(c+1)*a)*c^2-ln(1-exp(-a))*c^2-(-1-c)*exp(-(c+1)*a)*exp(a)-exp(-(c+1)*a)*exp(a))*b2/c^2

ans := solve(df2, a);

RootOf(_Z*c-ln(-(LerchPhi(1/exp(_Z), 1, c)*b1*c-LerchPhi(1/exp(_Z), 1, c)*b2*c-b1+b2)/(c*(b1*ln(exp(_Z)-1)-b2*ln(exp(_Z)-1)+b1*gamma+b1*Psi(c+1)-b1*_Z+b2*_Z))))

evalf(eval(ans, {b1 = .9, b2 = .1, c = 3}));

-0.7104876251e-1

If value of c is known, say 3, then

f3 := add((b1*fn1+b2*fn2)/lambda, lambda = 1 .. 3);

b1*(a+exp(-a)-1)-b2*exp(-a)+(1/2)*b1*(a+(1/2)*exp(-2*a)-1/2)-(1/4)*b2*exp(-2*a)+(1/3)*b1*(a+(1/3)*exp(-3*a)-1/3)-(1/9)*b2*exp(-3*a)

df3 := simplify(diff(f3, a));

-b1*exp(-a)+(11/6)*b1+b2*exp(-a)-(1/2)*exp(-2*a)*b1+(1/2)*b2*exp(-2*a)-(1/3)*exp(-3*a)*b1+(1/3)*b2*exp(-3*a)

This is a polynomial in exp(-a)=y

solve(y = exp(-a), a);

-ln(y)

-b1*y+(11/6)*b1+b2*y-(1/2)*y^2*b1+(1/2)*b2*y^2-(1/3)*y^3*b1+(1/3)*b2*y^3

(1/2)*((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)/(b1-b2)-(3/2)*(b1-b2)/((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)-1/2, -(1/4)*((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)/(b1-b2)+(3/4)*(b1-b2)/((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)-1/2+((1/2)*I)*3^(1/2)*((1/2)*((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)/(b1-b2)+(3/2)*(b1-b2)/((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)), -(1/4)*((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)/(b1-b2)+(3/4)*(b1-b2)/((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)-1/2-((1/2)*I)*3^(1/2)*((1/2)*((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3)/(b1-b2)+(3/2)*(b1-b2)/((27*b1-5*b2+2*(189*b1^2-81*b1*b2+13*b2^2)^(1/2))*(b1-b2)^2)^(1/3))

But for c larger than 5, there won't be a symbolic solution, as you wanted.

``

Download solve.mw

I don't know why this would be - after all, 0.12 as an expression outputs as 0.12. If you care about exactly how the number is formatted, you can write it to a string using a format: sprintf("%f",0.12); gives "0.120000" and you can have fine control over number of digits etc by adjusting the format - see the help page ?sprintf.

I'm having the same issue (in Maple 2015). It seems you have to browse to a worksheet even if it is the open one with the bookmark in that you are editing. (I selected type worksheet and absolute path.) The help says you can leave it blank if it is the current worksheet, but this seems not to be the case.

A closer look with symbolic solutions finds more solutions but they all have x_2 = 20. But the equations already have some square roots which I assume need to lead to real solutions - perhaps this is not a valid assumption, or in leading up to these equations you have manipulated them in some way that precludes the solution you want. In particular is the other x_2 you want negative?
 

restart;

To see what is happening, try to solve symbolically, i.e., without floating point approximations. Leave off the x_2<>20 to start with. Replace int with Int, then convert to rationals and then use value to force the integrations.

sys:=value(convert({0 = a_2*cos(7.5*b_2) + a_2, 250 = Pi*Int((a_2*cos(b_2*x) + a_2)^2, x = 0 .. 7.5), 750 = Pi*Int((a_1*x^2 + b_1*x + sqrt(d_1*x) + 7.5)^2 - (a_2*cos(b_2*x) + a_2)^2, x = 0 .. x_2), 2.5 = a_1*20^2 + 20*b_1 + sqrt(20*d_1) + 7.5, 2*a_1*x_2 + b_1 + sqrt(d_1)/(2*sqrt(x_2)) = 0, (2*a_1)*20 + b_1 + sqrt(d_1)/(2*sqrt(20)) = 0},rational));

{0 = a_2*cos((15/2)*b_2)+a_2, 250 = (1/4)*Pi*a_2^2*(2*cos((15/2)*b_2)*sin((15/2)*b_2)+8*sin((15/2)*b_2)+45*b_2)/b_2, 750 = (1/420)*Pi*(84*a_1^2*x_2^5*d_1^3*b_2+210*b_1*a_1*x_2^4*d_1^3*b_2+240*(d_1*x_2)^(7/2)*a_1*b_2+140*b_1^2*b_2*d_1^3*x_2^3+336*(d_1*x_2)^(5/2)*b_1*b_2*d_1+2100*a_1*b_2*d_1^3*x_2^3-210*cos(b_2*x_2)*sin(b_2*x_2)*a_2^2*d_1^3-630*a_2^2*b_2*d_1^3*x_2+3150*b_1*x_2^2*d_1^3*b_2+210*d_1^4*x_2^2*b_2+4200*(d_1*x_2)^(3/2)*b_2*d_1^2-840*sin(b_2*x_2)*a_2^2*d_1^3+23625*x_2*d_1^3*b_2)/(d_1^3*b_2), 5/2 = 400*a_1+20*b_1+2*5^(1/2)*d_1^(1/2)+15/2, 40*a_1+b_1+(1/20)*5^(1/2)*d_1^(1/2) = 0, 2*a_1*x_2+b_1+(1/2)*d_1^(1/2)/x_2^(1/2) = 0}

The following finds 2 solutions but Maple is not sure it has found them all.

ans1:=[solve(sys, {a_1, a_2, b_1, b_2, d_1, x_2})];
nops(ans1);

Warning, solutions may have been lost

[{a_1 = (1/2400)*(5^(1/2)*(-288*Pi^2*5^(1/2)*RootOf(-288*5^(1/2)*Pi^2*_Z-36*Pi^2*_Z^2-3290*Pi^2+1225*3^(1/2)+11900*Pi)-3290*Pi^2+1225*3^(1/2)+11900*Pi)^(1/2)+30*Pi)/Pi, a_2 = 10*RootOf(9*Pi*_Z^2-2), b_1 = -(1/40)*(5^(1/2)*(-288*Pi^2*5^(1/2)*RootOf(-288*5^(1/2)*Pi^2*_Z-36*Pi^2*_Z^2-3290*Pi^2+1225*3^(1/2)+11900*Pi)-3290*Pi^2+1225*3^(1/2)+11900*Pi)^(1/2)+20*Pi)/Pi, b_2 = (2/15)*Pi, d_1 = (1/36)*(-288*Pi^2*5^(1/2)*RootOf(-288*5^(1/2)*Pi^2*_Z-36*Pi^2*_Z^2-3290*Pi^2+1225*3^(1/2)+11900*Pi)-3290*Pi^2+1225*3^(1/2)+11900*Pi)/Pi^2, x_2 = 20}, {a_1 = (1/1236000)*(5^(1/2)*1545^(1/2)*(2976*Pi^2*5^(1/2)*RootOf(-2976*5^(1/2)*Pi^2*_Z+6180*Pi^2*_Z^2+3290*Pi^2-1225*3^(1/2)-11900*Pi)-3290*Pi^2+1225*3^(1/2)+11900*Pi)^(1/2)+15450*Pi)/Pi, a_2 = 10*RootOf(9*Pi*_Z^2-2), b_1 = -(1/20600)*(5^(1/2)*1545^(1/2)*(2976*Pi^2*5^(1/2)*RootOf(-2976*5^(1/2)*Pi^2*_Z+6180*Pi^2*_Z^2+3290*Pi^2-1225*3^(1/2)-11900*Pi)-3290*Pi^2+1225*3^(1/2)+11900*Pi)^(1/2)+10300*Pi)/Pi, b_2 = (2/15)*Pi, d_1 = (1/6180)*(2976*Pi^2*5^(1/2)*RootOf(-2976*5^(1/2)*Pi^2*_Z+6180*Pi^2*_Z^2+3290*Pi^2-1225*3^(1/2)-11900*Pi)-3290*Pi^2+1225*3^(1/2)+11900*Pi)/Pi^2, x_2 = 20}]

2

This may be because it doesn't explore the different possibilities for sqrt(d_1) and sqrt(x_2), or the polynomials under the RootOfs have several solutions that Maple hasn't explored. If d_1,x_2 are positive and nonnegative respectively to prevent complex/infinite solutions, we can proceed further, and find 8 solutions. Now there is are no RootOfs and no error message.

ans2:=[solve(sys, {a_1, a_2, b_1, b_2, d_1, x_2},useassumptions)] assuming x_2::positive,d_1::nonnegative:
nops(ans2);
ans2[1];

8

{a_1 = (1/2400)*(5^(1/2)*(48*5^(1/2)*(24*Pi^2*5^(1/2)-(-410*Pi^4+1225*3^(1/2)*Pi^2+11900*Pi^3)^(1/2))-3290*Pi^2+1225*3^(1/2)+11900*Pi)^(1/2)+30*Pi)/Pi, a_2 = -(10/3)*2^(1/2)/Pi^(1/2), b_1 = -(1/40)*(5^(1/2)*(48*5^(1/2)*(24*Pi^2*5^(1/2)-(-410*Pi^4+1225*3^(1/2)*Pi^2+11900*Pi^3)^(1/2))-3290*Pi^2+1225*3^(1/2)+11900*Pi)^(1/2)+20*Pi)/Pi, b_2 = (2/15)*Pi, d_1 = (1/36)*(48*5^(1/2)*(24*Pi^2*5^(1/2)-(-410*Pi^4+1225*3^(1/2)*Pi^2+11900*Pi^3)^(1/2))-3290*Pi^2+1225*3^(1/2)+11900*Pi)/Pi^2, x_2 = 20}

Unfortunately they all have x_2=20

map(x->eval(x_2,x),ans2);

[20, 20, 20, 20, 20, 20, 20, 20]

But by default Maple has not allowed for the fact that inverse cosine has many solutions. Using allsolutions=true allows this. Now the solutions have the variable _Z3 which can be any integer

ans3:=[solve(sys, {a_1, a_2, b_1, b_2, d_1, x_2},useassumptions,allsolutions=true)] assuming x_2::positive,d_1::nonnegative:
nops(ans3);
ans3[1];

8

{a_1 = (1/2400)*(5^(1/2)*2^(1/2)*((2470*Pi^2*_Z3+1235*Pi^2+11900*Pi*_Z3+24*(-1640*Pi^4*_Z3^2-1640*Pi^4*_Z3-410*Pi^4+47600*Pi^3*_Z3^2-1400*Pi^2*cos((16/3)*Pi*_Z3+(1/6)*Pi)*sin((16/3)*Pi*_Z3+(1/6)*Pi)*_Z3+47600*Pi^3*_Z3-700*Pi^2*cos((16/3)*Pi*_Z3+(1/6)*Pi)*sin((16/3)*Pi*_Z3+(1/6)*Pi)+5600*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i*_Z3+(1/6)*Pi)+5600*Pi^2*cos((16/3)*Pi*_Z3+(1/6)*Pi)*_Z3+11900*Pi^3+2800*Pi^2*cos((16/3)*Pi*_Z3+(1/6)*Pi))^(1/2))*_Z3/(2*_Z3+1)+24*5^(1/2)*(48*Pi^2*5^(1/2)*_Z3+24*Pi^2*5^(1/2)+(-1640*Pi^4*_Z3^2-1640*Pi^4*_Z3-410*Pi^4+47600*Pi^3*_Z3^2-1400*Pi^2*cos((16/3)*Pi*_Z3+(1/6)*Pi)*sin((16/3)*Pi*_Z3+(1/6)*Pi)*_Z3+47600*Pi^3*_Z3-700*Pi^2*cos((16/3)*Pi*_Z3+(1/6)*Pi)*sin((16/3)*Pi*_Z3+(1/6)*Pi)+5600*Pi^2*cos((16/3)*Pi*_Z3+(1/6)*Pi)*_Z3+11900*Pi^3+2800*Pi^2*cos((16/3)*Pi*_Z3+(1/6)*Pi))^(1/2))/(2*_Z3+1)-3290*Pi^2*_Z3-1645*Pi^2+11900*Pi*_Z3-350*cos((16/3)*Pi*_Z3+(1/6)*Pi)*sin((16/3)*Pi*_Z3+(1/6)*Pi)+5950*Pi+1400*cos((16/3)*Pi*_Z3+(1/6)*Pi))/(Pi^2*(2*_Z3+1)), x_2 = 20}

But they still all have x_2=20.

map(x->eval(x_2,x),ans3);

[20, 20, 20, 20, 20, 20, 20, 20]

ans4:=[solve(sys, {a_1, a_2, b_1, b_2, d_1, x_2},allsolutions=true)]:
nops(ans4);

Warning, solutions may have been lost

2

map(x->eval(x_2,x),ans4);

[20, 20]

 


 

Download eqns.mw

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