Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi,

Is there a way to change the font type and size when printing a table of data using DocumentTools:-Tabulate? Also can I change the column width?

DocTabFont.mw

I have calculated z=f(x,y) for x from 0 to 5 and y from 0 to 5 by taking step size 0.5  and stored it in a matrix M. Now I am trying to plot the resultant matrix having order 11x11. Where x and y values are ranging from 0 to 5. But If I use this command
matrixplot(M, heights = histogram, colorscheme = ["Blue", "Green", "Yellow", "Red"])
It is taking 0 to 11 on both x and y axis. It must be 0,0.5,0.1,0.15...5.
How to change the values of x and y axis manually?

hi! how can I write it correct?

this is the parametric curve in cartesian coordinates:

spacecurve([2*t^3 - 2*t, 4*t^2, t^3 + t], t = -1 .. 1, color = black, numpoints = 1000, orientation = [90, 90, 90]);

and this should be the same curve but in spherical coordinates:

spacecurve([sqrt(5)*(t^3 + t), arccos(1/sqrt(5)), arccot((t^2 - 1)/(2*t))], t = -1 .. 1, coords = spherical, color = black);

I rewrite that parametrization using formula from this page 

https://en.wikipedia.org/wiki/Spherical_coordinate_system

why doesn't it work?

help on structured type says

| identical(expr) an expression identical to expr

and

The type identical(expr) matches the expression expr identically. If there is more than one expr (i.e. identical(expr1,expr2,...)), then this type matches any one of the exprN identically.
 

Then why does the following produce the same output?

restart;
expr:=x*A[2]+A[1];
select(type,expr,'`*`'({anything, identical(x^2)}));
select(type,expr,'`*`'({anything, identical(x)}))

x*A[2]

x*A[2]


I would have expected only the second select to find x*A[2].

What do I need to only select anything*x^2 without selecting anything*x ?

Actually anything in identical gives same result

select(type,expr,'`*`'({anything, identical(zzzzz)}));

x*A[2]

So I must be misunderstanding something about identical and how it works.  I want to match only anything*x^2 and nothing else. How to do that?

all these things are trivial to do use pattern matching. But in Maple, one is supposed to use structured types.

 

I can't figure this one out.

I need to pick out the subexpression   anything*sin(3*x) from an expression.

it works, when the expression is   anything*sin(3*x)+something else. But when the expression is exactly  anything*sin(3*x) then select returns and not anything*sin(3*x) as I was expecting.

So I must be doing something silly, but do not see it.

restart;
TypeTools:-AddType('type_1', '`*`'({anything,identical(exp(3*x))}));
expr:=25*A[1]*exp(3*x);
type(expr,type_1);

returns true. good. Now I test it on 

select(type,expr+sin(x),type_1) ;

and this returns what is expected. 25*A[1]*exp(3*x) but when I type

select(type,expr,type_1) ;

it return

reading select help page did not help.  Tried flatten, inplace.

I can do this using patmatch

patmatch(expr,a::anything*exp(3*x),'la');la

But why is select not working in the above? What is the correct way to do this so it works for a*expr+anything and also for a*expr only? This is done inside a function and not interactive. So I need it to work for both cases, since the input can be anything, but I only need the term anything*exp(3*x) pulled out.

 

Hi,

As I am continuing to use Maple, I find I use multiple customized worksheets and documents as well as a maple student guide or AEM guide.......How can I save the workspace with these other documents so that I don't have to rebuild them everytime I use that customized Maple system?

Thanks for your help!

Frank

My first day attempting Maple so probably something simple about environment variables.

I'm trying to use Digits in an expression to set and use the preceision. It seems to set the value if used in a procedure but seems to update the variable after the execution of multiple commands executed together - also setting a variable from Digits, updating it, then using that in evalf doesn't help.

Digits := 1

Digits := Digits + 1; Digets; 1.0/3;

Gives 1 digit, Setting of Digits takes affect after the evaluation.

f := proc() Digits + 1; 1.0/3; end proc

f();

2 digits - so the setting of Digits takes effect before the evaluation. Looks like the procedure is executed as separate commands.

So repeated executes of 

f(); Digits++;

Will increment the precision as will

f := proc() Digits++; print(evalf[Digits](1.0/3)); return Digits; end proc; Digits := f();

Also

a := 1; a := a + 1; evalf[a](1.0/3);

Gives 2 digits

a := Digits + 1; evalf[a](1.0/3);

Gives 1 digit.

a := eval(Digits + 1); evalf[a](1.0/3);

Gives 1 digit.

A := [1, -2, 3]:u := `<,>`(0, -2, 2):v := `<,>`(5, 8, -3):
PL := proc (A, u, v) local d, Det, AP, t, U, V;
AP := `<,>`(x-A[1], y-A[2], z-A[3]);
Matrix(`<|>`(`<,>`(AP), `<,>`(u), `<,>`(v)));
Det := LinearAlgebra:-Determinant(%); d := igcd(coeff(Det, x), coeff(Det, y), coeff(Det, z), tcoeff(Det));
print(`Une équation cartésienne du plan est :`);
t := Det/d; print([t = 0]);
print('Une*représentation*paramétrique*du*plan*est; -1');
U := convert(u, list); V := convert(v, list);
[x = lambda*U[1]+mu*V[1]+A[1], y = lambda*U[2]+mu*V[2]+A[2], z = lambda*U[3]+mu*V[3]+A[3]] end proc;
PL(A, u, v);

plan3p := proc (A::list, B::list, C::list)
local d, M, N, P, Mat, Det, t, U, V;
M := `<,>`(x-A[1], B[1]-C[1], C[1]-A[1]); N := `<,>`(y-A[2], B[2]-C[2], C[2]-A[2]); P := `<,>`(z-A[3], B[3]-C[3], C[3]-A[3]);
Mat := Matrix([M, N, P]);
Det := LinearAlgebra:-Determinant(%);
d := igcd(coeff(Det, x), coeff(Det, y), coeff(Det, z), tcoeff(Det));
print(`Une équation cartésienne du plan est :`);
t := Det/d; print([t = 0]); print('Une*représentation*paramétrique*du*plan*est; -1');
U := A-B; V := B-C;
[x = lambda*U[1]+mu*V[1]+A[1], y = lambda*U[2]+mu*V[2]+A[2], z = lambda*U[3]+mu*V[3]+A[3]] end proc;
A := [-6, 3, -2]; B := [5, 2, 1]; C := [2, 5, 2];plan3p(A, B, C);
How to know if these procedures are correct or not. Thank you.

I want to have a proc, which returns an expression using an indexed symbol. The proc needs to basically generate constansts to use to build an expression, similar to how dsolve uses _Cn.  But I do not want to use _Cn for this so not to confuse the expression with another one that was generated using _Cn already.

So I thought to use a local symbol say A.  (I could have used _Zn also, but I think _Z is also used by Maple).

The symbol A is first declared local to the proc, and then the proc returns the expression using A[n]. For example  A[0]*x+A[1]*x^2 etc... The number of A[n]'s is not known before hand, but should not be more than 10. 

I want to make sure that A[n] returned is really part of the local symbol and not different symbol to avoid clash with any global A[n] 

When I do the following check

restart;
foo:=proc()
 local A;
 return A[99]
end proc;

expr:=foo()

type(expr,`global`)

gives

good. So Maple says that A[99] is not global. But when I do

type(expr,`local`)

it also says false!

My question is: When making local A , will A[1] and A[2] also be local, or are they different symbols? Maplemint says nothing about it, so I assume A[n] is local also?

maplemint(foo)
Procedure foo() 
  These local variables were used but never assigned a value:  A

It did not say that A[99] was never declared local. This tells me that A[99] is local, because A is local. But then why did type(expr,`local`)  say false?

Hi,

I was wondering why each time solve is executed, I get a different of number of solutions and can I specify the number of solutions?

 

Thanks so much for taking time to answering this question.

 



Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/number_of_solutions.mw .
 

I don't way the above error happened. But here is my worksheet below.

Download number_of_solutions.mw

Given an expression, how to best find the constants _C1, _C2, etc.... in this expression?  Currently I do the following, but I think there should be a better way.

restart;
sol:=dsolve(diff(y(x),x$2)+y(x)=1);
indets(sol);
select(x->`if`(type(x,symbol) and convert(x,string)[1..2]="_C",true,false),indets(sol))

The above works, at least on the few examples I tried it on, but is there a better way to do it?  All constants will have the form _Cn where n is integer. 

 

 

Hi,

This question is related to the answer I gave to this question 232564-I-Need-To-Learn-What-Type-Of-Calculation

In a few words the OP (planetmknzm) wanted to know how a Maple's procedure (PlanePlot) was doing some calculus.
I proposed him to redirect the output of print('PlanePlot') to a mpl file, to open this latter, to insert a DEBUG() command and follow step by step what was going on.

If I execute the whole procedure (whose name is MyPlanePlot) I get this strange error
Error, (in MyPlanePlot) Colours is not a command in the Student package
Indeed PlanePlot contains instructions like this one

pl_Basis := plots['arrow']([[p, B[1]], [p, B[2]]], 'width' = pl_scale, 
      'colour' = Student:-Colours[2], op(basisoptions))

Searching for Colours in the help pages confirms what the error message says, but browsing the library with the assistant reveals that Student:-Colours does exist.

PlanePlot.mw

Do packages contain commands that are not accessible to users?
Why does PlanePlot work but its "clone" MyPlanePlot doesn't?
Last but not least, is there a way to fix this ?


Thanks in advance


PS : I discovered this issue as I was about to propose to planetmknzm another way to asked his previous question  232518-How-Can-We-Assign-The-Values-Of-Basis (just insert return B[1], B[2]: before the end of MyPlanePlot to get the vector basis)

restart;
Digits:=30:

f:=proc(n)
	x[n]-y[n];
	
end proc:


e1:=y[n] = (15592/1575)*h*f(n+5)+(35618816/99225)*h*f(n+9/2)-(4391496/15925)*h*f(n+13/3)-(2035368/13475)*h*f(n+14/3)-(212552/121275)*h*f(n+1)+(10016/11025)*h*f(n+2)-(31672/4725)*h*f(n+3)+(19454/315)*h*f(n+4)-(351518/1289925)*h*f(n)+y[n+4]:
e2:=y[n+1] = -(34107/22400)*h*f(n+5)-(212224/3675)*h*f(n+9/2)+(92569149/2038400)*h*f(n+13/3)+(82333989/3449600)*h*f(n+14/3)-(568893/1724800)*h*f(n+1)-(459807/313600)*h*f(n+2)+(1189/22400)*h*f(n+3)-(50499/4480)*h*f(n+4)+(32951/6115200)*h*f(n)+y[n+4]:
e3:=y[n+2] = (69/175)*h*f(n+5)+(1466368/99225)*h*f(n+9/2)-(13851/1225)*h*f(n+13/3)-(60507/9800)*h*f(n+14/3)+(43/3675)*h*f(n+1)-(3509/9800)*h*f(n+2)-(6701/4725)*h*f(n+3)+(871/420)*h*f(n+4)-(247/396900)*h*f(n)+y[n+4]:
e4:=y[n+3] = -(31411/201600)*h*f(n+5)-(745216/99225)*h*f(n+9/2)+(13557213/2038400)*h*f(n+13/3)+(9737253/3449600)*h*f(n+14/3)-(20869/15523200)*h*f(n+1)+(36329/2822400)*h*f(n+2)-(202169/604800)*h*f(n+3)-(100187/40320)*h*f(n+4)+(14669/165110400)*h*f(n)+y[n+4]:
e5:=y[n+13/3] = -(3364243/1322697600)*h*f(n+5)-(134364928/651015225)*h*f(n+9/2)+(19955023/55036800)*h*f(n+13/3)+(5577703/93139200)*h*f(n+14/3)-(910757/101847715200)*h*f(n+1)+(1336457/18517766400)*h*f(n+2)-(2512217/3968092800)*h*f(n+3)+(31844549/264539520)*h*f(n+4)+(690797/1083289334400)*h*f(n)+y[n+4]:
e6:=y[n+14/3] = -(29107/10333575)*h*f(n+5)+(7757824/651015225)*h*f(n+9/2)+(180667/429975)*h*f(n+13/3)+(342733/2910600)*h*f(n+14/3)-(7253/795685275)*h*f(n+1)+(42467/578680200)*h*f(n+2)-(19853/31000725)*h*f(n+3)+(993749/8266860)*h*f(n+4)+(22037/33852791700)*h*f(n)+y[n+4]:
e7:=y[n+9/2] = -(115447/51609600)*h*f(n+5)-(21389/198450)*h*f(n+9/2)+(231041241/521830400)*h*f(n+13/3)+(43797591/883097600)*h*f(n+14/3)-(32833/3973939200)*h*f(n+1)+(48323/722534400)*h*f(n+2)-(91493/154828800)*h*f(n+3)+(1220071/10321920)*h*f(n+4)+(24863/42268262400)*h*f(n)+y[n+4]:
e8:=y[n+5] = (1989/22400)*h*f(n+5)-(61184/99225)*h*f(n+9/2)+(1496637/2038400)*h*f(n+13/3)+(2458917/3449600)*h*f(n+14/3)+(73/5174400)*h*f(n+1)-(31/313600)*h*f(n+2)+(359/604800)*h*f(n+3)+(1079/13440)*h*f(n+4)-(179/165110400)*h*f(n)+y[n+4]:



h:=0.01:
N:=solve(h*p = 8/8, p):
#N := 10:
#n:=0:
#exy:= [seq](eval(i+exp(-i)-1), i=h..N,h):
c:=1:
inx:=0:
iny:=0:

mx := proc(t,n):
   t + 0.01*n:
end proc:

exy := (x - 1.0 + exp(-x)):

vars := y[n+1],y[n+2],y[n+3],y[n+4],y[n+13/3],y[n+14/3],y[n+9/2],y[n+5]:

printf("%6s%20s%20s%20s\n", "h","numy1","Exact", "Error");
#for k from 1 to N/8 do
for c from 1 to N do

	par1:=x[n]=map(mx,(inx,0)),x[n+1]=map(mx,(inx,1)),
		x[n+2]=map(mx,(inx,2)),x[n+3]=map(mx,(inx,3)),
		x[n+4]=map(mx,(inx,4)),x[n+5]=map(mx,(inx,5)),
		x[n+13/3]=map(mx,(inx,13/3)),x[n+14/3]=map(mx,(inx,14/3)),
		x[n+9/2]=map(mx,(inx,9/2)):
	par2:=y[n]=iny:
	res:=eval(<vars>, fsolve(eval({e||(1..8)},[par1,par2]), {vars}));
	
	printf("%7.3f%22.10f%20.10f%17.3g\n", 
		h*c,res[8],(exy,[x=c*h]),abs(res[8]-eval(exy,[x=c*h]))):
		#c:=c+1:
	
	iny:=res[8]:
	inx:=map(mx,(inx,5)):
end do:

Dear all,

Please Kindly help to correct or modify the code above

Thank you and best regards
 

 

 

how to plot call and put of classical Black Scholes with initial stock price 30, strike price 30 r=0.1, sigma=0.2 in  both Maple and MATLAB codes? how can we interpret the results?

First 10 11 12 13 14 15 16 Last Page 12 of 1847