|
[Date Index]
[Thread Index]
[Author Index]
Mathematica Symbolic Toolbox for MATLAB--Version 2.0
- To: mathgroup at smc.vnet.net
- Subject: [mg51329] Mathematica Symbolic Toolbox for MATLAB--Version 2.0
- From: Ben Barrowes <barrowes at alum.mit.edu>
- Date: Thu, 14 Oct 2004 06:37:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
This is an announcement that the
Mathematica Symbolic Toolbox for MATLAB
has been upgraded to Version 2.0. Maintenance for this toolbox has been
transferred to Ben Barrowes. The toolbox can be downloaded from the
mathsource:
http://library.wolfram.com/infocenter/MathSource/
and MATLAB's file exchange:
http://www.mathworks.com/matlabcentral/fileexchange/
This version was developed on an x86 Linux system, but is believed to be
mex'able on other platforms. Reports of success would be appreciated.
Here is the text of the email from Doug Stein transferring maintenance:
Ben,
I did in fact author the toolbox (back in 1994, I think). Since then, as
we both know, MATLAB and Mathematica have gone through many versions!
I'm not surprised that the need is still there and I'm glad you want to
take over the maintenance. I haven't been an employee of Wolfram since
spring 1994 and while I do remain fluent in Mathematica (and MATLAB from
working from 1997-2003 in quantitative finance) I am not in a position
to devote any time to maintenance.
I'd also like to introduce you to a former colleague of mine at Wolfram
Research (Todd Gayley). He is responsible for leading the MathLink
technology and its derivatives (e.g. J/Link, .NET/Link, etc.) and would
be interested to know that this code will be maintained. (Hi, Todd!)
At any rate, you have my wholehearted encouragement and thanks. Please
feel free to contact me if you have any questions.
Cordially,
Doug Stein
VP Development and Technology
Learning.com
dstein at learning.com
Also, here is the text of the README included with this toolbox:
Mathematica Symbolic Toolbox for MATLAB - Version 2.0 (12 October 2004)
------------------------------------------------------------------------
Using the MathLink communication standard supplied with Mathematica and
the MEX
facility of MATLAB we write a toolbox that provides MATLAB users with
all of the
symbolic and high-precision numeric capabilities of Mathematica. In
addition,
since MathLink can pass native MATLAB matrices (and not just strings)
between
Mathematica and MATLAB it is quick and easy to construct matrices in either
system and pass them to the other. You can freely mix Mathematica code and
MATLAB code without the bother of writing M-files to convert matrices into
strings and back. The Mathematica Symbolic Toolbox for MATLAB is
implemented as
a single MEX-file and we have included the source code.
Two important points:
1) The Mathematica Symbolic Toolbox for MATLAB works with newer
(MLVERSION in
mathlink.h >= 3) versions of Mathematica (I have not tested the new
version
on the Macintosh). This version has been tested to work with
Mathematica 4.2
and Matlab 7.0. Instuctions for mex'ing this file are given below.
2) Since MathLink connects programs on different computers just as
easily as it
connects programs on the same computer, you can harness the power of
more
than one computer. Simply run MATLAB on one computer, Mathematica on
another;
the Mathematica Symbolic Toolbox for MATLAB transparently connects the
two. This capability is also especially helpful in schools and
industrial
sites where MATLAB and Mathematica might be licensed for different
machines.
Functions provided in the Mathematica Symbolic Toolbox for MATLAB
-----------------------------------------------------------------
math('string') : 'string' is sent to Mathematica and evaluated; the
: result is returned as a string.
:
: <Optional for Macintosh users>
: Mathematica will automatically be started if you
: make an alias of the "Mathematica Kernel"
icon, call
: the alias "MathKernel", and place the alias
in the
: same folder as MATLAB itself. If you don't
make the
: alias, the MathLink library will pose a
dialog box
: and ask you to find a Mathematica Kernel.
math('matlab2math', 'mname', mat) : The MATLAB matrix mat is assigned
: to the Mathematica symbol denoted
: by the string 'mname'. The result
: returned to MATLAB is 'mname'.
math('math2matlab', 'expr') : The matrix resulting from the evaluation
: of 'expr' by Mathematica is returned. If
: 'expr' doesn't yield a matrix, this
function
: returns a MATLAB string containing
'$Failed'
math('quit') or math('exit') : These close the link and shut down
Mathematica.
All of the above automatically open a MathLink connection with default
arguments
if one hasn't already been opened. If the user wishes to open the connection
with particular arguments, the full form of the linkopen command is:
math('linkopen', 'linkname', 'linkmode', 'linkprotocol', 'swapEOL')
: The first argument must be the string 'linkopen'.
: The second argument must be the name of the link
: defined as usual for Mathematica's LinkOpen or the MathLink
: library's MLOpen(). Again, for simplicity,
math('linkopen') uses
: the default arguments. LinkOpen and MLOpen() are described
: in the MathLink Reference Guide that ships with Mathematica.
: The third argument is either 'Launch', 'Connect', or 'Listen'.
: The fourth argument is either 'PPC' or 'TCP' on Macintosh,
: 'Local' or 'TCP' on Windows, and 'Pipes' or 'TCP' on Unix.
: If the fifth argument is 'swapEOL' then carriage-return and
: linefeed will be swapped; this is useful when connecting
: MATLAB and Mathematica processes residing on computers with
: different notions of end-of-line (for example, MATLAB on a Mac
: with Mathematica on a Sun SPARC). If the fifth argument is
: anything else, line termination will be unchanged.
In addition to the behavior above, any Mathematica warning or error messages
as well as the output from Mathematica's Print[] function will appear in the
MATLAB command window.
Here's an example of a session with MATLAB and Mathematica.
-----------------MATLAB Transcript Begins--------------
>> math('$Version')
Mathematica Kernel loading...
ans =
4.2 for Linux (August 23, 2002)
>> math('N[EulerGamma,40]')
ans =
0.5772156649015328606065120900824024310422
>> math('Integrate[Log[x]^(3/2),x]')
ans =
3 Sqrt[Pi] Erfi[Sqrt[Log[x]]] -3 x
----------------------------- + Sqrt[Log[x]] (---- + x Log[x])
4 2
>> math('InputForm[Integrate[Log[x]^(3/2),x]]')
ans =
(3*Sqrt[Pi]*Erfi[Sqrt[Log[x]]])/4 + Sqrt[Log[x]]*((-3*x)/2 + x*Log[x])
>> math(['Integrate[',ans,',x]'])
ans =
3 Sqrt[Pi] x Erfi[Sqrt[Log[x]]]
------------------------------- -
4
Pi
3 Sqrt[--] Erfi[Sqrt[2] Sqrt[Log[x]]]
2
> ------------------------------------- +
16
2 2
-9 x x Log[x]
> Sqrt[Log[x]] (----- + ---------)
8 2
>> math('matlab2math', 'hilbert',hilb(20))
ans =
hilbert
>> math('{Dimensions[hilbert],Det[hilbert]}')
ans =
-196
{{20, 20}, 5.76706 10 }
>> math('exactHilbert = Table[1/(i+j-1),{i,20},{j,20}];')
ans =
Null
>> math('Det[exactHilbert]')
ans =
1 / 23774547167685345090916442434276164401754198377534864930331853312\
> 3441975931064458518758576681657377344056575986726555897176563841\
> 9710793303386582324149811241023554489166154717809635257797836800\
> 000000000000000000000000000000000
>> math('N[Det[exactHilbert], 40]')
ans =
-226
4.206178956624722655882045573396941339798 10
>> math('invHilbert = Inverse[hilbert];')
Inverse::luc: Warning: Result for Inverse of badly conditioned matrix
{<<20>> }
may contain significant numerical errors.
ans =
Null
>> math('math2matlab', 'invHilbert')
ans =
Columns 1 through 3
113.178979337215 -5919.74491450191
88499.6060995985
-5629.19259643555 325661.692155659
-3310610.4742403
65006.8583984375 -1379341.32904625
-103113004.666097
118827.09765625 -79580628.7093658
3960703542.87468
-6565667.125 1190624660.87695
-45191708684.4323
46772334 -7091389994.79395
243317770201.644
-145560961 20192244670.1055
-637766577741.674
169011227 -20094863396.0078
483223248366.23
157581726.375 -30107722916.5508
1395746315716.95
-546314566 84022049827.8926
-3190940224029.26
80248995 -11721686137.6553
450511619653.419
833248230 -122474248390.773
4379013519678.3
-674342533 104770453206.729
-4031562266231.86
500368351.25 -89613291085.4766
3920435126867.95
-1801550550 275002011616.359
-10261097652172.7
1527154928 -217344388348.539
7466476394136.89
1967461622 -297514562257.922
10968437168811
-4087459016 598118479308.156
-21248040416754.2
2536304908 -367436527858.172
12900351189283.5
-556537420 80183462241.6113
-2796768045312.38
Columns 4 through 6
-510445.978184683 1625336.99449522
-13839361.0719537
-9658895.9244982 154136706.044553
1179106970.13898
2489819979.39821 -15829389980.4342
-22534638103.2292
-61985228341.3854 352708793931.11
208838077525.952
626372659122.163 -3303972916153.63
-2361562991155.11
-3117508119218.49 14577360685521.7
27656719467887.7
7263188344560.42 -22452456771233.5
-196769542511847
-1882343817286.72 -55027672976967.9
799011448910185
-27691532280774.3 293318008894301
-1.84730158415938e+15
51889758217630.2 -443863883411908
2.17875625601591e+15
-7896861578382.06 76597384647696.5
-436258295972536
-65586615447360.4 499265995940208
-2.05686232422449e+15
66931544708134.1 -593960900048081
3.13308913938148e+15
-73524919098267.8 735312012156663
-4.3614722023589e+15
161767546721285 -1.31433910593269e+15
5.90584653456277e+15
-105483962086627 721680799531158
-2.25711546888483e+15
-170230255738406 1.35368201226982e+15
-5.88829318181532e+15
314698551295346 -2.33671275736643e+15
8.95426658136452e+15
-188140325001210 1.36415981861825e+15
-4.97813317427672e+15
40436869193657.2 -289269694936324
1.02575324251412e+15
Columns 7 through 9
128463960.845981 -601044166.649502
1429838357.0824
-19128247290.709 94462427341.4881
-224406297982.711
720199029095.715 -3661148980429.49
8648986818221.74
-11955479624388.5 60917045341235.7
-142305837330720
108543400858323 -537572089649284
1.23174088330313e+15
-599432326737334 2.77719960420449e+15
-6.15954631982161e+15
2.12400714758352e+15 -8.74075476518521e+15
1.83057787280303e+16
-4.91321335401271e+15 1.66251137580989e+16
-3.1049432231791e+16
7.26270179623264e+15 -1.77797337843886e+16
2.4451092374039e+16
-6.17851681929922e+15 8.74126540763949e+15
730681432392497
1.36751936984959e+15 -1.17653480550358e+15
-8.11354131313642e+15
4.38070034687638e+15 -3.77446405631302e+15
3.24465172631833e+15
-1.04209857079999e+16 2.28651032241006e+16
-3.59245590361003e+16
1.61341389380097e+16 -3.75709087333385e+16
5.30886713313908e+16
-1.40749937684324e+16 1.14322562731591e+16
2.13683192447793e+16
238183180090668 2.1111586005894e+16
-6.64449524106293e+16
1.32081802571475e+16 -8.31943633136647e+15
-2.38039088159902e+16
-1.36906588054635e+16 -1.86581479894883e+16
1.06576273114568e+17
6.15301300424444e+15 1.73828465470931e+16
-7.45576848238949e+16
-1.08793241125756e+15 -4.4351683548491e+15
1.71902970120607e+16
Columns 10 through 12
-1433092579.96435 -661797089.535329
2934344030.9709
221454748157.325 107797999574.982
-459259272483.272
-8404437399828.31 -4295430604576.11
17669950431082.8
135914908153839 73077539261115.5
-290584835202507
-1.15093263821656e+15 -657559222051283
2.51890192345663e+15
5.57298124524197e+15 3.47155302832127e+15
-1.26678561078404e+16
-1.56350424279102e+16 -1.13410269963666e+16
3.82834657298677e+16
2.30132413690387e+16 2.3761995414146e+16
-6.85599721886391e+16
-7.83635329774751e+15 -3.48126031051241e+16
6.89123335940669e+16
-2.55178056593037e+16 4.7041638070212e+16
-4.68141026355175e+16
3.68666814103448e+16 -7.34103689965472e+16
7.34844032586819e+16
-2.97460533862245e+16 9.48302586560573e+16
-1.24259060820449e+17
4.8898705429703e+16 -6.77693799706299e+16
8.16174916900524e+16
-4.1086351632482e+16 1.91239346335733e+16
-3.27421696167911e+16
-4.85258771625178e+16 -1.10443996059956e+16
1.12428901554771e+17
7.8934684133657e+16 6.1139213054271e+15
-9.90785867183554e+16
3.74089092063926e+16 4.39989770064524e+16
-1.4710926958948e+17
-1.27012120837591e+17 -7.53618734019761e+16
2.98650647805885e+17
8.47650219942711e+16 4.6161751111216e+16
-1.84897165303488e+17
-1.90774193124695e+16 -1.01757078288663e+16
4.05054108939442e+16
Columns 13 through 15
-2446423712.23972 1865172235.03629
-4662791179.38423
383898150102.123 -296945159399.429
722520215463.328
-14849500279794.7 11633931246808
-27450047604165.1
246318773641883 -195130939326616
443586541791183
-2.16281687789633e+15 1.72807706095922e+15
-3.743895936715e+15
1.10797429167903e+16 -8.88275139656445e+15
1.79899796320497e+16
-3.43508417547259e+16 2.727271573706e+16
-4.96525696025277e+16
6.34191690372566e+16 -4.78145207757838e+16
7.04002023047312e+16
-6.33664382381491e+16 3.69311889061952e+16
-2.06979713970156e+16
2.72184774288887e+16 1.17452222595548e+16
-5.99655987685971e+16
-1.92657727484354e+16 -2.72199659872601e+16
8.93280128386663e+15
6.07511811235594e+16 -2.9344466445376e+16
1.30407738989029e+17
-7.21783088243212e+16 6.64099680322212e+16
-9.08546431463167e+16
6.28849035674626e+16 -4.00789665685201e+16
-1.77020620269233e+16
-9.93635441334253e+16 3.34478869224447e+16
-1.12656435360884e+17
6.21374409941305e+16 -2.86056329229755e+16
1.82301423013235e+17
1.14544740784714e+17 -4.85749131605373e+16
1.27395404094863e+17
-2.12572779157258e+17 1.0853124878165e+17
-3.79252855436206e+17
1.29108219274511e+17 -7.19148791095348e+16
2.54604320218465e+17
-2.81152257017536e+16 1.65535819944235e+16
-5.79226957175225e+16
Columns 16 through 18
6010764228.37905 -1752433341.0017
-2483833528.68668
-918433335055.881 262715788389.949
380607729139.388
34388014740620.7 -9645612276272
-14291854739214.4
-546796936786676 150091955166348
228056752126632
4.52698023761335e+15 -1.21079355314895e+15
-1.89774606064267e+15
-2.12105133647067e+16 5.47808266608817e+15
8.96721778243928e+15
5.63450659354091e+16 -1.37529710883796e+16
-2.42201880178417e+16
-7.39341305381217e+16 1.57927824556192e+16
3.3217847929549e+16
1.07541166738604e+16 2.20651795808375e+15
-8.48693306129385e+15
6.62250695751404e+16 -1.51363632169552e+16
-2.71121550747623e+16
2.89282935888942e+16 -2.44211627004609e+16
-772089829157155
-1.8808272895544e+17 6.84602247828256e+16
5.83867643987357e+16
9.0428541201657e+16 -2.82145286639271e+16
-2.64787776673404e+16
2.89012222373552e+16 2.67537543949077e+15
-1.72731584619987e+16
2.13033838663796e+17 -1.12607908075586e+17
-4.50849362143225e+16
-3.10672585960735e+17 1.77537758521734e+17
1.84834696167326e+16
-1.55278840876447e+17 -4.1792814378581e+16
1.98738415416993e+17
5.21004049186954e+17 -9.7057669178095e+16
-3.06781915060056e+17
-3.4935062130957e+17 8.15343716795949e+16
1.77923392942204e+17
7.88955692681663e+16 -1.96316109147183e+16
-3.78233534425734e+16
Columns 19 through 20
2232569196.11812 -547094668.842378
-339530344027.39 82925009059.4386
12652542703558.7 -3079614638026.62
-200256676099775 48563748889473.9
1.65083453286884e+15 -398678512680276
-7.70793561936204e+15 1.85192551569666e+15
2.04527032242424e+16 -4.87776556492204e+15
-2.70605754407013e+16 6.35892780164074e+15
5.0459094190706e+15 -1.00351846398172e+15
2.26425730663842e+16 -5.40406006382957e+15
7.42919517083055e+15 -2.26233899190568e+15
-5.8055446316467e+16 1.44196263198346e+16
2.52497196324359e+16 -6.23047888321419e+15
8.66447599589122e+15 -1.3232510045469e+15
6.45762181080283e+16 -1.76726149387426e+16
-5.66707840051854e+16 1.62477441275126e+16
-1.3688660905156e+17 3.11653357291696e+16
2.47524149697134e+17 -5.88099500057462e+16
-1.48686172057182e+17 3.55631656797113e+16
3.20196864941092e+16 -7.66963557697005e+15
>> math('quit')
Mathematica Kernel quitting per your request...
>>
-----------------MATLAB Transcript Ends--------------
Where to get the Mathematica Symbolic Toolbox for MATLAB
--------------------------------------------------------
(1) http://library.wolfram.com/infocenter/MathSource/
What's included in this archive
-------------------------------
README - this file
math.c - source code suitable for MATLAB 7.0 MEX facility
math.mexglx - precompiled binary of math.c for x86 Linux.
testscript.m - MATLAB test script which runs the examples above
math.tar.gz - tar'ed, gzip'ed file containing the files above
How to build the Mathematica Symbolic Toolbox for MATLAB
--------------------------------------------------------
First of all, you need access to a licensed copy of Mathematica. The
standard Mathematica distribution includes the MathLink header and library
files.
NOTE 1: You need the MathLink header and library files for the machine on
which you are running MATLAB (since you are building a MEX-file to work
with that version of MATLAB). If you don't have the appropriate MathLink
files,
send email to support at wri.com with your Mathematica license number and the
machine for which you want them.
NOTE: As of version 1.2, math.c properly compiles with non-ANSI compilers,
particularly the default Sun C compiler. My apologies for previously
forgetting
users stuck with such old-style C compilers. Version 2.0 has not been
tested with
non-ANSI compilers.
Macintosh:
-----------
1) Unknown. If you succeed in building this on a Mac, send me the
directions.
*NIX:
-----------
0) Make a directory to hold the toolbox. In this directory, untar the file:
tar zxvf math.tar.gz
You might want to put this directory on MATLAB's path using addpath
in your
startup.m
1) Find out where libML.a and mathlink.h are installed on your system.
2) Properly install the MEX tools for MATLAB.
The default settings in mexopts.sh should be sufficient.
then type:
mex -Iinclude_path -Llibrary_path -lML math.c
(where include_path is the path to mathlink.h and library_path
is the path to libML.a)
Windows:
--------
1) Again, unknown, but assumed to be usable. Mail me if you find a working
combination.
Questions ?
-----------
1) If you have suggestions about how to make this
free Mathematica Symbolic Toolbox for MATLAB better, send email to:
barrowes at alum.mit.edu
HTH,
---- Benjamin E. Barrowes ----
Prev by Date:
Re: Re: Re: normal distribution random number generation
Next by Date:
Gaussian Noise
Previous by thread:
Starting Mathematica 5 - List of RHS illegal values
Next by thread:
Re: Mathematica Symbolic Toolbox for MATLAB--Version 2.0
|