## 45 Reputation

10 years, 311 days

## How to obtain a symbolic set of solution...

Maple 17

Hello Maple-Primers!

I am trying to evaluate a system at many different points.  I would like to include an interpolation function in this system, but have thusfar been unsuccessful.

Usually, I solve a system symbolically by using eliminate and unapply:

eq := A = M^3;
eq := C = A*2;
eq := D = N+3;
eq := B = piecewise(A = 0, 0,C);
eq := E = B*D;
elimsol:=eliminate(convert(eq,list),[A,B,C,D,E]);

unappsol:=unapply(elimsol,[N,M]);

unappsol(1,2);
{A = 8, B = 16, C = 16, D = 4, E = 64} <--- great!

Now, I want to include an interpolation function in the system of equations.  They look like this (see worksheet for actual interpolation function):

B_interp := (W,T) -> CurveFitting:-ArrayInterpolation([FC_Map_W,FC_Map_T],FC_Map,Array(1 .. 1, 1 .. 1, 1 .. 2, [[[W, T]]]),method=linear);

eq := E = B_interp(N,M);

Error, (in CurveFitting:-ArrayInterpolation) invalid input: coordinates of xvalues must be of type numeric <-- bad!

Anyone have any ideas?  I've tried to use polynomials, but I can't seem to get a fit close enough for my purposes.

Maple_2D_Interpolate_FC.mw

## Maple 18 Toolbox: Restart...

Maple 18

Hi Everybody,

I installed the Maple Toolbox for matlab and tried to run my old code.  For some reason, maple('restart') will cause Matlab to lock up.  Any ideas?

Windows 7 64-bit.  Matlab 2012b 32-bit, Maple 18 32-bit

## CodeGeneration. Outputting Multiple Ent...

Maple

Hi Mapleprimers,

I'm using CodeGeneration to convert a procedure I obtained with unapply() into a Matlab function.  I'm having problems getting the outputting function to run correctly in Matlab.  I'm going to dynamically generating equations, so directly editing the Matlab code won't work here.  I'm having problems getting any output in Matlab.  Here is the code I'm working on:  Series_addGear_codegen.mw

Ideally I would like output in a matrix.  I've tried putting the unapplied procedure in another procedure, but the CodeGeneration doesn't work.

This is the maple output from the function:

unapp(1,2,3,4,5);
{BAT_A = -2.267032891, BAT_V = 271, EM2_A = .4615464218, EM2_P = 125.0790803, EM2_T = -1, EM2_V = 271, EM2_W = 2, GBa_T = 12, GBa_W = 5/3, GBb_T = -4, GBb_W = 5, GEN_A = 1.805486469, GEN_P = 489.2868330, GEN_T = -12, GEN_V = 271, GEN_W = 5/3, ICE_mdot_g = 20}

Since I'll know the order of variables, I want the Matlab function to output:

[-2.267032891,  271,  .4615464218,  125.0790803,  -1, ...]

This is the output after putting the Matlab function in Matlab:

>> unapp(1, 1, 1, 1, 1)
Undefined function or variable 'BAT_A'.

Error in unapp (line 39)
unappreturn = unique([BAT_A == -t35 / 0.271e3 - t73 / 0.271e3 BAT_V == 271 EM2_A == t35 /
0.271e3 EM2_P == t35 EM2_T == -FD_T EM2_V == 271 EM2_W == FD_W GBa_T == t44 GBa_W == t41 GBb_T
== -ICE_T GB

This is the Matlab code that is generated by Maple 18:

MCode:=CodeGeneration[Matlab](unapp, declare = [FD_T::float, FD_W::float, GB_R::float, ICE_T::float, ICE_W::float],defaulttype=float,optimize,defaulttype = numeric);
Warning, could not preprocess. Found `abs` or similar in the 'While'/'For' conditions.
Warning, procedure/module options ignored
function unappreturn = unapp(FD_T, FD_W, GB_R, ICE_T, ICE_W)
t2 = 0.1e1 * FD_T * FD_W;
t5 = abs(FD_W);
t7 = abs(FD_T);
t9 = t5 ^ 2;
t13 = t7 ^ 2;
t15 = t9 * t5;
t21 = t13 * t7;
t23 = t9 ^ 2;
t31 = t13 ^ 2;
t33 = 0.1483000000e3 - 0.4267000000e1 * t5 - 0.1277000000e2 * t7 + 0.3640000000e-1 * t9 - 0.1160000000e1 * t5 * t7 + 0.2580000000e0 * t13 - 0.1181000000e-3 * t15 + 0.5994000000e-3 * t9 * t7 - 0.1171000000e-3 * t5 * t13 - 0.1739000000e-2 * t21 + 0.1245000000e-6 * t23 - 0.1200000000e-5 * t15 * t7 + 0.1584000000e-5 * t9 * t13 - 0.4383000000e-6 * t5 * t21 + 0.2947000000e-5 * t31;
if (-t2 == 0.0e0)
t35 = 0.0e0;
elseif (-t2 < 0.0e0)
t35 = t33;
else
t35 = -t33;
end
t36 = ICE_T * ICE_W;
t37 = 0.1e1 * t36;
t41 = ICE_W / GB_R;
t42 = abs(t41);
t44 = ICE_T * GB_R;
t45 = abs(t44);
t47 = t42 ^ 2;
t51 = t45 ^ 2;
t53 = t47 * t42;
t59 = t51 * t45;
t61 = t47 ^ 2;
t69 = t51 ^ 2;
t71 = 0.5280000000e-11 - 0.3849000000e-13 * t42 + 0.7190000000e2 * t45 + 0.1168000000e-15 * t47 - 0.1296000000e1 * t42 * t45 - 0.2489000000e1 * t51 - 0.1451000000e-18 * t53 - 0.1326000000e-3 * t47 * t45 + 0.8141000000e-2 * t42 * t51 + 0.4539000000e-2 * t59 + 0.6325000000e-22 * t61 + 0.2091000000e-6 * t53 * t45 - 0.3455000000e-5 * t47 * t51 - 0.2499000000e-4 * t42 * t59 + 0.5321000000e-4 * t69;
if (-t37 == 0.0e0)
t73 = 0.0e0;
elseif (-t37 < 0.0e0)
t73 = t71;
else
t73 = -t71;
end
unappreturn = unique([BAT_A == -t35 / 0.271e3 - t73 / 0.271e3 BAT_V == 271 EM2_A == t35 / 0.271e3 EM2_P == t35 EM2_T == -FD_T EM2_V == 271 EM2_W == FD_W GBa_T == t44 GBa_W == t41 GBb_T == -ICE_T GBb_W == ICE_W GEN_A == t73 / 0.271e3 GEN_P == t73 GEN_T == -t44 GEN_V == 271 GEN_W == t41 ICE_mdot_g == t36]);

## Restart Maple memory except variable?...

Maple 17 , Maple Toolboxes

Hi Mapleprimers,

I was wondering if there way a way to use restart(); and clear Maple's memory, but protect the memory in a certain variable?  I would like to return the memory to the operating system, but keep a symholic function in memory.

Alternatively, is there a way to save a symbolic function to a file, then reload it at a seperate time?

## Maple Toolbox for Matlab: Segmentation ...

Maple 17 , Maple Toolboxes

Hi MaplePrime-ers,

I'm using Maple17 in Matlab 2012b to evaluate a symbolic function over a grid of values.  The number of values is generally ~500k, and therefore I have a loop that dumps the solutions into MATLAB where the values are parsed and stored more efficiently.

I put this proceess in an optimization routine, and I keep getting crashes.  The crashes are NOT repeatable.  They generally happen after 4-10 times the routine has been called.

This is one of the stack dumps.  Anybody have any ideas?  I talked to MATLAB support, but they weren't very useful (they started pointing fingers).

------------------------------------------------------------------------
Segmentation violation detected at Wed Jun 4 17:38:11 2014
------------------------------------------------------------------------

Configuration:
Crash Decoding : Disabled
Current Visual : 0x24 (class 4, depth 24)
Default Encoding: UTF-8
GNU C Library : 2.15 stable
MATLAB Root : /opt/Matlab/R2012b
MATLAB Version : 8.0.0.783 (R2012b)
Operating System: Linux 3.2.0-37-generic #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 x86_64
Processor ID : x86 Family 6 Model 23 Stepping 6, GenuineIntel
Virtual Machine : Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : The XFree86 Project, Inc (40300000), display wildnode0:15.0

Fault Count: 1

Abnormal termination:
Segmentation violation

Register State (from fault):
RAX = 00007f3bcc0a80c0 RBX = 00007f3b97fe6000
RCX = 0000000000000000 RDX = 00007f3bcc0a84a0
RSP = 00007f3b8cb29d60 RBP = 0000000000000003
RSI = 5851f42d4c957f2d RDI = 00007f3bde026360

R8 = 65a1566174cc9e28 R9 = 0000000000000002
R10 = 00007f3b8cb29d90 R11 = 0000000000002e88
R12 = 0000000000000001 R13 = 00007f3b8cb29df0
R14 = 0000000000000000 R15 = 0000000000000003

RIP = 00007f3b977d0604 EFL = 0000000000010283

CS = 0033 FS = 0000 GS = 0000

Stack Trace (from fault):
[ 1] 0x00007f3c962b14b2 /opt/Matlab/R2012b/bin/glnxa64/libmwfl.so+00521394
[ 3] 0x00007f3c9559f093 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00557203 _ZN2fl4diag13terminate_logEPKcPK8ucontext+000067
[ 4] 0x00007f3c9559bb9d /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00543645
[ 5] 0x00007f3c9559d835 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00550965
[ 6] 0x00007f3c9559da55 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00551509
[ 7] 0x00007f3c9559e0fe /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00553214
[ 8] 0x00007f3c9559e295 /opt/Matlab/R2012b/bin/glnxa64/libmwmcr.so+00553621
[ 10] 0x00007f3b977d0604 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01824260
[ 11] 0x00007f3b977cfc48 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01821768
[ 12] 0x00007f3b977d2f88 /opt/maple17/bin.X86_64_LINUX/libmaple.so+01834888
[ 13] 0x00007f3b9763d63f /opt/maple17/bin.X86_64_LINUX/libmaple.so+00173631
 1 2 3 Page 1 of 3