Finding a term into an expression...

Dear friends:

I have a long expression having a/some RootOf(something..) inside it.

Any way to get just that "something..", i.e., the argument of RootOf() from that expression?

Thank you very much.

Nonlinear system of 14 equations/unknowns, 9 param...

Hello,

this is the second time I'm writing.

I posted this question in June http://www.mapleprimes.com/questions/201781-System-Of-Parametric-Equations.

This time I have  a similar problem because I'm trying to find a solution for a parametric system of equations but the number of equations and parameters is much bigger and using the tips you gave me last time I couldn't reach any result.

Here is the system:

1) alpha=v*a*u*b ;
2) alpha=v*a*u*(1-b);
3) alpha= v*z*c*(1-a) ;
4) alpha=v*z*(1-a)*(1-c) ;
5) alpha=1/2*v*a* u* b* (-p*u*b+p*u*b*a+b*g-g);
6) alpha=1/2*v*a*u*(1-b)* (p u b-p u b a-b g-p u+p u a);
7) alpha =1/2*v*c*z*(1-a)* (c* (-z*p*a+q)-q);
8) alpha=1/2*v*z*((1-a)*(1-c)* (c*z*p*a-z*p*a-q*c);
9) alpha=v*a*u*b*(1- b)*(-p*u+p*u*a+g) ;
10) alpha=v*a*u*b*z*c*p*(1-a) ;
11) alpha=a*u*b*z*(1-a)*(1-c) ;
12) alpha=a*u*z*c*(1-a)*(1-b);
13) alpha=v*a*u*z*p*(1-a)*(1-b)*(1-c);
14) alpha= v*c*z*(1-a)*(1-c)*(-z*p*a+q);

I have 14 equations/unknowns and 8 parameters (a, b, c, u, v, z, p, q).

I would like to write this system only in terms of alphas. In order to do so, I usually try to find the value for the parameters and the substitute them into the equations (and I have already found b,c,g,q using this technique) but I couldn't manage to find all of them.

Howveer, as you suggested me, with Maple there is the command "eliminate" that implement exactly what I'm looking for but I can't make it work.

This is my code:

> sys := {alpha = v*a*u*(1-b), alpha = v*a*u*b, alpha = v*z*c*(1-a), alpha = v*z*(1-a)*(1-c), alpha = (1/2)*v*a*u*(1-b)*(p*u*b-p*u*b*a-b*g-p*u+p*u*a), alpha = v*a*u*b*(1-b)*(-p*u+p*u*a+g), alpha =      z*c*a*u*(1-a)*(1-b), alpha = v*z*a*u*p*(1-a)*(1-b)*(1-c), alpha = (1/2)*v*a*u*b*(-p*u*b+p*u*b*a+b*g-g), alpha = v*z*c*a*u*b*p*(1-a), alpha = z*a*u*b*(1-a)*(1-c), alpha = (1/2)*v*c*z*(1-a)*(c*(-z*p*a+q)-q), alpha = v*c*z*(1-a)*(1-c)*(-z*p*a+q), alpha = (1/2)*v*z*(1-a)*(1-c)*(c*z*p*a-z*p*a-q*c)};

> eliminate(sys, {a,b,c, p, q, u, v, z});

> simplify(%, size);

I also tries to substitute in the system the four parameters I already found but still I can't find a solution.

What am I doing wrong? Or the problem is that it is too complicated?

Elena

Error, (in convert/matrix) expecting array, rtable...

hello, I put in the code:

> with(plots), with(ColorTools), with(LinearAlgebra), with(RandomTools), with(ExcelTools);
> A := `<|>`(`<,>`(1, 2, 0, 2, 3, 4, 3, 4, 7, 9, 5, 3, 4, 6, 7, 8, 3), `<,>`(0, 4, 7, 2, 2, 2, 4, 5, 6.5, 7, 5, 3, 2, 5, 9, 0, 1), `<,>`(1, 5, 2, 0, 4, 1, 2, 3, 4.3, 7, 8, 5, 3, 2, 9, 6, 4)); J := convert(Import("testB1.xlsx", "Cartesian", "E2:G18"), matrix);
Error, (in convert/matrix) expecting array, rtable or list
> B := matrix([, [.2], [.1], [.8], [.5], [.6], [.8], [.764], [.234], [0.4e-1], [.89], [.36], [.687], [.627], [.689], [.328], [.139]]); H := convert(Import("test.xlsx", "Cartesian", "D2:D18"), matrix);
Error, (in convert/matrix) expecting array, rtable or list
> C := [seq(Color([H[i, 1], 0, 0]), i = 1 .. RowDimension(A))];

And i get the error message everytime I try import m data list and I dont understand why. Any help would be appreciated. Thank you

Jennifer

Module/Package - Why are some functions (proc) not...

I've been using a maple package (written by another author) on earlier versions of Maple.  Recently I have been trying to rewrite it so it's a bit more Maple 16+ friendly (since I've read that Maple is not forward-compatible). However, I have been experiencing similar strange behavior in both the original and my current version:

After saving the module to my personal library, I load with(MyPackage). Most functions work fine (all but a handful out of dozens).  However, some functions won't be recognized (e.g., Coproduct(...) will return itself Coproduct(...)).

HOWEVER, when I execute the code in the module in its own Maple worksheet, all functions are recognized and work perfectly.  I look at the difference in the code between the functions that work upon loading the package (using with(MyPackage) command in a separate sheet) and those that don't, and there is no difference.

I'm assuming I'll just have to cut and paste the hundreds of lines of code for my package into each sheet I'd like to use it in, since I haven't been able to find others experience this problem in the knowledge base.  I'm hoping someone will be able to help out, however.

Maple having trouble simplifying...

Well, I'm having issues getting this expression to simplify.  I have a bunch of polynomial results I store in an array, and the simplify command isn't cancelling obvious terms which should cancel out.

June_18.mw

Curiously, it will simplify if I use the command by selecting it from the drop down menu when I select the expression (see lines (7) vs. (8))

writing data during iteration...

I am writing a big numerical code in maple. I need to write the results in each step in a file. I mean in the first step of loop it writes the results in the first line of a text file, in the second step writes in the second line and to the end. when I use writedata command, it needs to write a complete array or matrix and it is not what i need. In  other words I want to save data for each steps of iteration during the calculation and when it goes to ther next step it writes the result in the next line.

Can you help me to perform it?

Thanks

How to create all possible lists containing m elem...

Hey everyone,

New here but I'm a bit stuck. Ive looked around in list tools as well as tried but I havent had any luck.

Suppose I have a list defined as FirstList:=[A,B,C,D,E,F]. Now I want to create (and label) all possible
lists from FirstList which contain 4 elements which dont have an element repeated within the same list
In this example, there are 15 lists in total i.e.

Sublist:=[A,B,C,D]:
Sublist:=[A,B,C,E]:
Sublist:=[A,B,C,F]:
Sublist:=[A,C,D,E]:

..etc

Is there a simple way to do this???

Any help is appreciated!

Executing Sections in Maple...

Is there away to quickly execute a specific section within Maple? I know that I can execute a selection, but that sometimes requires me to select several lines of Maple code and can be tedious and tiresome.

Build array of coordinates from implicit equation....

Hallo,

Is there a fairly straightforward method for obtaining an array of coordinates from an implicit equation? I have an ellipse defined implicitly (by a horrendously involved expression) and can't figure out how to extract a set of coordinates from an implicitplot. I'm reluctant to use seq and fsolve with a fixed stepsize.

Would be grateful for some insight!

Thanks.

Weirp

How do I plot 2D animate in Maple?...

I wish to  plot 2D animate for the soltion of this equation here is the code

restart;
with(PDEtools):
with(ArrayTools):
with(plots):

f:=u->sech(u):
g:=v->sech(v):
h:=1/10:
N:=20:
M:=20:
V:=x->x^2:
psi:=Array(0..N/h+1,0..M/h+1):
for i from 0 to N/h do
psi[i,0]:=evalf(f(i*h)):
od:
for j from 0 to M/h do
psi[0,j]:=evalf(g(j*h)):
od:
for i from 1 to N/h do
for j from 1 to M/h do
psi[i,j]:=-psi[i-1, j-1]+(1-(1/8)*h^2*V((1/2)*h*(j-i-1)))*psi[i, j-1]+(1-(1/8)*h^2*V((1/2)*h*(j- i+1)))*psi[i-1,j]:
od:
od:
ls:=[seq([seq([i*h,j*h,psi[i,j]],i=0..N/h)],j=0..M/h)]: OpenMaple Problem...

Hello,

I am writing a program in C that uses the open maple library. It is not the first time that I use it but now I am facing a strange problem that involves the simplify command: suppose a,x,y are symbols that are not previously used in maple, the following lines

1)  EvalMapleStatement(kv, "simplify((a*x^2-y^2)/(x^2*y^2-1));");

2)  EvalMapleStatement(kv, "simplify((2*x^2-y^2)/(x^2*y^2-1));");

only differ by the fact that the parameter a is replaced by 2 in the second line. But they return the following output:

1) (a*x^2-y^2)/(x^2*y^2-1)

that is correct, nothing to simplify..

2) Error, (in gcd/LinZip) input must be polynomials over the integers

I must be doing something wrong but I am getting nowhere...

Thanks...

P.S. This is the complete listing

#include <stdio.h>

#include <stdlib.h>

#include "maplec.h"

static void M_DECL textCallBack( void *data, int tag, char *output )

{

printf("%s\n",output);

}

int main( int argc, char *argv[] )

{

char err;  /* command input and error string buffers */

MKernelVector kv;  /* Maple kernel handle */

MCallBackVectorDesc cb = {  textCallBack,

0,   /* errorCallBack not used */

0,   /* statusCallBack not used */

0,   /* readLineCallBack not used */

0,   /* redirectCallBack not used */

0,   /* streamCallBack not used */

0,   /* queryInterrupt not used */

0    /* callBackCallBack not used */

};

ALGEB r, l;  /* Maple data-structures */

char *myargv[]={"maple"};

int myargc=1;

if( (kv=StartMaple(myargc,myargv,&cb,NULL,NULL,err)) == NULL ) {

printf("Fatal error, %s\n",err);

return( 1 );

}

EvalMapleStatement(kv, "simplify((a*x^2-y^2)/(x^2*y^2-1));");

EvalMapleStatement(kv, "simplify((2*x^2-y^2)/(x^2*y^2-1));");

StopMaple(kv);

return( 0 );

}

compiled with

gcc prova.c -I /Library/Frameworks/Maple.framework/Versions/Current/extern/include/ -L /Library/Frameworks/Maple.framework/Versions/Current/bin.APPLE_UNIVERSAL_OSX/ -l maplec

Saving the solution from fsolve...

Hello,

I have a question. Consider

fsolve(x^2+3*x+1=3, x);

I want to save the two roots into two variables. What kind of commend shall I use?

P.S. My further aim comes from solving an equation without analytical solution. Therefore I cannot plug in the solution formula.

matrix multiplication element by element...

Who knows: is there a maple command for two matrix multiplication element by element without summing?

Error in 2nd Order Coupled Nonlinear ODE System...

I'm calculating the geodesics to a parametrized system in R3. When trying to solve the geodesic equations for a surface of revolution, I'm getting a strange error. The goal is to write the code for any parametrized surface, not just revolution (hence I didn't use the short cut for surfaces of revolution).

For the code, I find the first fundamental for, then the geodesics, then turn the christoffel symbols into a time-variant array. (Gamma for the position of (u,v) in the uv-plane, and C as the array so I can take derivatives with respect to time.)

The code for creating the Christoffel Symbols and the parametrization of the paraboloid:

restart; with(LinearAlgebra):
V := (u, v) -> <v*cos(u), v*sin(u), v^2+1>;

Christoff := proc (X)
local x1, x2, M, N, i, j, k, s, E, F, G, g, Q, Delta, Prelim, cyclicPrelim;
global Gamma, C; #GAMMA
x1 := (u, v) -> <diff(X, u), diff(X, u), diff(X, u)>;
x2 := (u, v)-> <(diff(X, v), diff(X, v), diff(X, v))>;
E :=  (u, v) -> DotProduct(x1(u, v), x1(u, v), conjugate = false);
F := (u, v) -> DotProduct(x1(u, v), x2(u, v), conjugate = false);
G := (u, v) -> DotProduct(x2(u, v), x2(u, v), conjugate = false);
simplify([E(u, v), F(u, v), G(u, v)]);
M := (u, v) -> <E(u, v), F(u, v); F(u, v), G(u, v)>;
simplify(M(u,v));
printlevel := 3;
Delta := simplify(Determinant(M(u, v)));
N := (1/Delta)*<G(u, v), -F(u, v); -F(u, v), E(u, v)>;
Q := simplify(map(diff, M(u, v), u));
Q := simplify(map(diff, M(u, v), v));
for i to 2 do for j to 2 do for k to 2 do
Prelim[i, j, k] := Q[k][i, j];
simplify(Prelim[i, j, k] ); end do end do end do;
#(OPTIONAL PRINTOUT) print(Prelim);
for i to 2 do for j to 2 do for k to 2 do
cyclicPrelim[i, j, k] := Prelim[i, j, k]+Prelim[j, k, i]-Prelim[k, i, j] ;
end do end do end do;
#(OPTIONAL PRINTOUT)  print(cyclicPrelim);
for i to 2 do for j to 2 do for k to 2 do
Gamma[i, j, k] := simplify((1/2)*add(N[i, s]*cyclicPrelim[j, s, k], s = 1 .. 2));
end do end do end do;
# for k from 1 to 2 do
#print(`GAMMA[i,j,k] =` Matrix([[ `%a` , `%a` ],[ `%a` , `%a` ]])` \n`, Gamma[1,1,k], [Gamma[1,2,k], Gamma[2,1,k], Gamma[2,2,k]);
# end do;
#printf('GAMMA[%a,%a,%a] = %a \n', i,j,k, Gamma[i,j,k]);

print([Gamma[1,1,1], Gamma[1,2,1], Gamma[2,1,1], Gamma[2,2,1], Gamma[1,1,2], Gamma[1,2,2], Gamma[2,1,2], Gamma[2,2,2]]);

for i from 1 to 2 do
for j from 1 to 2 do
for k from 1 to 2 do
C[i,j,k]:= apply(Gamma[i,j,k],t);
end do end do end do;
C:=Array(1..2,1..2,1..2,[ [ [ apply(Gamma[1,1,1],t), apply(Gamma[1,2,1],t) ], [ apply(Gamma[1,1,2],t), apply(Gamma[1,2,2],t) ] ], [ [ apply(Gamma[2,1,1],t), apply(Gamma[2,2,1],t) ],  [ apply(Gamma[2,1,2],t), apply(Gamma[2,2,2],t) ] ] ]);
print(C);

end proc;

The differential equation solver:

inits:=[u(0)=1, D(u(t))(0)=1,v(0) = 1, D(v(t))(0)=1];

sys1:= [D[1\$2](u(t))+C[1,1,1]*(D(u(t)))^(2)+2*C[1,1,2]*(D(u(t)))*(D(v(t)))+C[1,2,2]*(D(v(t)))^2=0, D[1\$2](v(t))+C[2,1,1]*(D(u(t)))^(2)+2*C[2,1,2]*(D(u(t))*D(v(t)))^(2)+C[2,2,2]*(D(v(t)))^2=0];

L:=dsolve({sys1} union {inits});

The error message that comes up is:

"Error, (in unknown) invalid input: op expects 1 or 2 arguments, but received 0"

Any help would be greatly appreciated.