Implicit multiplication in maple from terminal - maple

I have a project, where I create a maple script in another language, that solves polynomial equations, and put it in .mpl file. But in this script multiplication is implicit, i.e. 3 * x represented as "3x".
When I run maple script from terminal (using maple filename) maple provides me with "syntax error: missing operator". I googled and found out that it happens with "1-D Math" mode in Maple, because of implicit multiplication (in 1-D Math you must do it explicitly).
Is there a way to change maple to 2-D Math in terminal? Or maybe there is another way to allow implicit multiplication?
Thanks

Related

Does Octave have a ScaleProblem equivalent for fmincon?

I'm in the process of porting a large set of MATLAB scripts to Octave. Some of the scripts use the MATLAB Optimization toolbox, specifically the fmincon function. In the optim package in Octave, the fmincon function exists but has different parameters. Is there a way to replicate the ScaleProblem parameter in Octave's fmincon?
In my Octave script, I use optimset:
options = optimset('fmincon','Algorithm','sqp','ScaleProblem','obj-and-constr', ...);
Which causes the following warning:
warning: optimset: unrecognized option: ScaleProblem
Is there a workaround for this?
Apart from the trivial advise to write a wrapper that looks for this parameter-value pair, scales the matrices & calls fmincon without the ScaleProblem option, I can only emphasize to use the NLopt-toolbox from the MIT: https://nlopt.readthedocs.io/en/latest/ it got far more optimization algorithms with a neat matlab/octave interface, all open-source, and -- to my experience -- often more accurate and faster indeed =)

Matlab cannot compute an infinite integral?

I am studying Stochastic calculus, and occasionally we need to compute an integral (from -infinity to +infinity) for some complex distribution. In this case, it was
with the answer on the right. This is the code I put into Matlab (and I have the symbolic math toolbox), which Matlab simply cannot process:
>> syms x t
>> f = exp(1+2*x)*(1/((2*pi*t)^0.5))*exp(-(x^2)/(2*t))
>> int(f,-inf,inf)
ans =
-((2^(1/2)*pi^(1/2)*exp(2*t + 1)*limit(erf((2^(1/2)*((x*1i)/t - 2i))/(2*(-1/t)^(1/2))), x, -Inf)*1i)/(2*(-1/t)^(1/2)) - (2^(1/2)*pi^(1/2)*exp(2*t + 1)*limit(erf((2^(1/2)*((x*1i)/t - 2i))/(2*(-1/t)^(1/2))), x, Inf)*1i)/(2*(-1/t)^(1/2)))/(2*pi*t)^(1/2)
This answer at the end looks like nonsense, while Wolfram (via their free tool), gives me the answer that the picture above has. Am I missing something fundamental about doing such integrations in Matlab that the basic Mathworks pages don't cover? Where am I proceeding incorrectly?
In order to explain what is happening, we need some theory:
Symbolic systems such as Matlab or Mathematica calculate integrals symbolically by the Risch algorithm (yes, there is a method to mechanically calculate integrals, just like derivatives).
However, the Risch algorithms works differently than using derivation rules. Strictly spoken, it is not an algorithm but a semi-algorithm. This is, it is not deterministic one (as algorithms are).
This (semi) algorithm makes a series of transformations on the input expression (the one to be integrated), and in a specific point, it requires to ask if the transformed expression is equals to zero, because if it were zero, it cannot continue (the input is not integrable using a finite set of terms).
The problem (and the reason of the "semi-algoritmicity") is that, the (apparently simple) equation:
E = 0
Is indecidable (it is also called the constant problem). It means that there cannot exist a formal method to solve the constant problem, for any expression E. Of course, we know to solve the constant problem for specific forms of the expression E (i.e. polynomials), but it is impossible to solve the problem for the general case.
It also means that the Risch algorithm cannot be perfect (being able to solve any integral -integrable in finite terms-). In other words, the Risch algorithm will be as powerful as our ability to solve the constant problem for as many forms of the expression E as we can, but losing any hope of solving for the general case.
Different symbolic systems have similar, but different methods to try to solve equations (and therefore the constant problem), it explains why some of them can "solve" different sets of integrals than others.
And generalizing, because no symbolic system will never be able to solve the constant problem for the general case, it will neither be able to solve any integral (integrable in finite terms).
The second parameter of int() needs to be the variable you're integrating over (which looks like t in this case):
syms x t
f = exp(1+2*x)*(1/((2*pi*t)^0.5))*exp(-(x^2)/(2*t))
int(f,'t',-inf,inf) % <- integrate over t

Symbolic notation for functions in Matlab

Is there a way to use actual symbols (like the square root symbol instead of writing "sqrt()" and integral and sum/product signs instead of "integrate", "sum", etc.) as in Mathematica?
Partially, but not within the main part of Matlab.
If you use MuPAD (type mupad in your Command Window), the engine behind much of the Symbolic Math toolbox, you can display/print results from calculations in your notebook with various levels of formatting. However, it does not appear that one can display what one enters with such formatting. Like Mathematica, MuPAD does have a graphical toolbar interface for selecting various commonly used types of mathematical operations.
Matlab was originally developed as a programming environment for numerical calculations and programs, whereas Mathematica was developed primarily as a tool for mathematicians to perform symbolic math and typeset their equations in a virtual notebook.
Aside: Though the MuPAD environment is distinct, one can access all of it's fuctionallity from within Matlab. See here for how to call MuPAD functions. Some examples: 1, 2, and 3.
Nope - it's how MATLAB was written. As far as I am aware, Mathematica is the only tool that uses symbolic notation for actual code.
I think a problem with having symbols instead of code is that you now need a way of writing those symbols (a menu bar, a tablet input, etc.) that would make it extremely cumbersome for a user.
Matlab is based on its diversity of toolbox, one of the toolbox support the symbolic notions you mention is the Symbolic Math Toolbox.
The Math Toolbox includes the MuPAD language. MuPAD is similar to Mathematica language, and here is a basic tutorial of MuPAD tutorial
In addition to Matlab, if you want Symbolic notation, IPython Notebook also use the actual Symbols. And it is faster, newer and easy to use.
Hope this will help you.

Workaround for Maple in MATLAB

I am trying to get the MATLAB toolbox SOSTOOLS to work inside a MATLAB R2010b (7.11.0.584) but get the following error:
??? Error using ==> maple at 54 The MAPLE command is not available.
Googling it I found out that MATLAB stopped using Maple at some stage and switched to MuPad.
Short of switching to an older version of MATLAB, is there a known workaround for this situation?
A solution in the form of installing Maple as the symbolic toolbox engine is not possible with your version of Matlab.
This outlines an alternative possible solution, I did not find a concrete workaround that will spare you work. I recommend you contact the authors, or check for octave versions with the same functionality.
The change to MuPad is a problem that's been posted numerous times, and there is a useful discussion of differences between Maple and MuPad here:
http://www.walkingrandomly.com/?p=178
For some commands it looks like a simple translator might work. Most of the implementation would apparently be in parsing the output from MuPad and turning it into what Maple would generate. The input to MuPad and Maple is apparently equal most of the time, but read the doc above.
To write a translator, you redirect calls to maple by placing in your path the following function maple that calls mupad:
function output=maple(input);
%prepare input here (if necessary) ...
output=mupad(input);
% parse the output (if necessary) ...
More likely than not, a naive call to this re-director will not solve the problem without some input/output parsing.

Lapack SPPTRF available?

do you know if MATLAB supports the LAPACK spptrf function.
This function is quite a bargain when you gotta compute Cholesky factorization of a huge positive definite symmetric matrix.
It allows for the factorization by only giving the upper triangular matrix, stored as uni-dimensional matrix, as input.
Or, else, is chol built-in function already using spptrf internally?
EDIT
I have been able to find the lapack library on the File Exchange http://www.mathworks.com/matlabcentral/fileexchange/16777-lapack, with the desired implementation of the spptrf function.
EDIT 2
MATLAB running on my machine is fatally crashing each time I call spptrf.
Is there any alternative way to directly handle this function?