How to use the symbol which has been seen as constant in Maple? - maple

For example, I would like to use symbol 'gamma', but 'gamma' is a maple constant(approximately 0.57722). If you use it persistantly, it will report an error
solve({2*gamma > 4}, {gamma});
Error, (in solve) a constant is invalid as a variable, gamma
Do I have some way to use gamma like a normal variable? Thank you in advance.

In recent Maple versions you can declare local instances of protected names or constants, at the top-level.
restart;
kernelopts(version);
Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750
local gamma:
solve({2*gamma > 4}, {gamma});
{2 < gamma}

In older versions of Maple you can use:
unprotect(gamma); gamma := convert(gamma, `local`);
acer's solution is better in versions where it is supported.

Related

Why Maple generates unknown constant in the solution of PDE when all initial and boundary conditions are specified

I do not understand why Maple 2017.3, generates a solution
to this wave PDE with unknown constant in it called _C6.
As all boundary conditions and initial conditions are given.
Actually the solution is wrong on another account,
it gives divide by zero when n=2. But my question is on
the presence of this constant.
This is the solution for wave PDE u_tt = 4* u_xx. String. With
both ends fixed. Initial position is u(x,0)= sin(x)^2
and zero initial velocity i.e. u_t(x,0) = 0
Maple:
restart;
pde:=diff(u(x,t),t$2)= 4*diff(u(x,t),x$2);
bc:=u(0,t)=0,u(Pi,t)=0;
ic:=u(x,0)=sin(x)^2,D[2](u)(x,0)=0;
sol:=pdsolve([pde,bc,ic],u(x,t));
Maple 2017.3 on windows gives
There should not be _C constants in the solution. For reference, here is Mathematica solution
ClearAll[u,t,x,n];
pde=D[u[x,t],{t,2}]==4D[u[x,t],{x,2}];
ic={Derivative[0,1][u][x,0]==0,u[x,0]==Sin[x]^2}
bc={u[0,t]==0,u[Pi,t]==0};
sol=DSolve[{pde,bc,ic},u[x,t],{x,t}];
sol=sol/.K[1]->n (*n looks better than K[1] for index*)
Notice there is no constant in the solution (but Mathematica solution has
the same problem for n=2 as Maple's. Divide by zero. So its solution is also wrong.
But my question here is not on the n=2 issue, but on the constant _C6 that Maple generates, and why is it there?
Maple 2017.3 on windows.
Update
Just to confirm that latest physics package (thanks to the answer ) did fix this issue
If I download and install the latest revision for Maple 2017 of the Physics,DEs,MathFuncs Library then I get the following using Maple 2017.2 for 64bit Linux.
restart;
Physics:-Version();
"/usr/local/maple/maple2017.2/lib/Physics2017.mla", 2018, March 9, 23:54 hours
pde:=diff(u(x,t),t$2)= 4*diff(u(x,t),x$2):
bc:=u(0,t)=0,u(Pi,t)=0:
ic:=u(x,0)=sin(x)^2,D[2](u)(x,0)=0:
sol:=pdsolve([pde,bc,ic],u(x,t)):
lprint(sol);
u(x, t) = Sum(4*((-1)^n-1)*sin(x*n)*cos(2*t*n)/(Pi*n*(n^2-4)), n = 1 .. infinity)

Unknown flag error diffset 'stable'

I am trying to use diffset, with the set being stable, but i get a Unknown flag. error. I also tried it with sorted, but the same error applies. Is there a different syntax?
My code:
C = setdiff([4 1 3 2],[2 1],'sorted')
I am using Matlab 7.10.0 r2010a
As mentioned, this is probably a MATLAB version issue. The behavior of setdiff has changed in the last versions, and the online documentation covers only MATLAB's latest 2013a release, so this may be a possible reason for your confusion.
That said, the documentation for previous MATLAB releases is also available online (note that it requires a MathWorks account, though). In any case, your MATLAB seems to have the older implementation of the setdiff command, and you can verify that by:
help setdiff
Anyway, the behavior of the older implementation of setdiff is similar to the behavior of the newer implementation when the flag setOrder is set to 'sorted'. If you want to mimic the behavior when the flag setOrder is set to 'stable', you can use ismember instead, for example:
A = [4 1 3 2];
B = [2 1];
C = A(~ismember(A, B))
which yields:
C =
4 3
This post offers an implementation:
function [res]=setdiff_stable(a,b)
if(size(a,1)>size(a,2))
a=a';
end
if(size(b,1)>size(b,2))
b=b';
end
res=a(sum(repmat(a,length(b),1)-repmat(b',1,length(a))==0,1)==0);
end

How to force Matlab/Octave cov function to use optional parameter

I'm using the cov (covariance) function of Matlab and Octave. Actually I'm using Octave, but in the end it has to work for both. This function has an optional second or third parameters to indicate whether normalization should be done with N or N-1.
If I do this: cov(points,1) (where points is 4x2 matrix) I get following error:
error: cov: x and y must have the same number of observations
On a general note I would like to know how is Matlab/Octave able to distinguish if the second parameter is another matrix or an optional parameter (because it can have 2 or 3 parameters).
More specifically I would like to know how can I solve my problem?
Matlab cov() documentation: http://www.mathworks.de/help/techdoc/ref/cov.html
Octave cov() documentation: http://www.gnu.org/software/octave/doc/interpreter/Correlation-and-Regression-Analysis.html
EDIT: I'm using Octave 3.2.4 on Ubuntu 12.04
EDIT2: The solution is to install a newer version of Octave. This features was implemented after 3.2.
This looks like an Octave bug (at least with version 3.0.5); it works fine in Matlab (at least with version 7.10).
Of course, to work around, you could just compute:
cov(a) * (N-1) / N
type help cov, and note that opt has been removed doesn't exist.
better yet, do
gedit /usr/share/octave/3.2.4/m/statistics/base/cov.m
and compare it to the old new code
Opt is gone recent. Use Oli's trick in the meantime
Edit: I take that back, this is a new feature. Not sure which version of Octave is using it, but you need an upgrade. Either, you do an unstable synaptic upgrade if you can find a repository, or you build it from source.
Edit 2: feature added Jan 2011 (3.4.1). 3.2.4 released Jan 2010. current version is 3.6.1

bi2de error in MatLab

In MatLab, "> help bi2de" provides the following example:
B = [0 0 1 1; 1 0 1 0];
D = bi2de(B)
But when I try this on my own, I get the following error:
??? Undefined function or method 'bi2de' for input arguments of type 'double'.
Is there something wrong with this function in MatLab?
I am pretty sure that the reason why this problem happened is because of the license of the toolbox, Communications system toolbook, in which this function belongs in. Write which bi2de and see what will be the result. If it returns path of the function and the comment Has no license available, then the problem is related to the license. That means, license of the toolbox is not set correctly. Mostly it happens if the toolbox is added later, i.e., after installation of the original matlab. Please check and solve the license issue, then it will work fine.
bi2de is a function in the Communications toolbox. You need to have that toolbox to use it. If you do have that toolbox, then the problem is that your B matrix is being treated as double instead of binary (I don't have the toolbox so I can't test this).
Consider using bin2dec, which turns a string representation ('1011001', eg) into a decimal number. This function is not part of a toolbox; it's available as part of the basic MATLAB package.

Maple 13 variable assignment does not work

Please refer to the screenshot.
I assigned Qswap to a matrix and when I try to view Qswap, it has nothing assigned to it!
Help will be appreciated =)
The swapcol command is from the linalg package, which works with a matrix and/or a vector. Note the lack of capitalization in matrix and vector.
A matrix in Maple is an object which has so-called last_name_eval rules for its evaluation. See the last_name_eval help-page. So when you enter just the name, then all you get back is that name. You can view the underlying array which is assigned to the name using the evalm, eval, or print commands. For example,
restart:
with(linalg):
m:=matrix(2,2,[1,2,3,4]);
qswap:=swapcol(m,1,2);
qswap;
evalm(qswap);
Now, the linalg package is officially deprecated in Maple 13. It's recommended replacement is the LinearAlgebra package (introduced in Maple 6, ten years ago). The LinearAlgebra package is for a Matrix or a Vector (not capitalization). The Matrix and Vector objects do not have last_name_eval, in contrast to matrix and vector. For example,
restart:
with(LinearAlgebra):
m:=Matrix(2,2,[[1,2],[3,4]]);
qswap:=ColumnOperation(m,[1,2]);
qswap;
One last thing. By default only Matrices and Vectors of size <11 get their contents explicitly displayed. You can adjust that with a new cutoff at size 50, say, like this,
interface(rtablesize=50);