Items tagged with procedure

Hi guys, i'm working on a problem using the runge kutta method (4). The problem is, when I run this program, with the given starting values, it perfectly calculates every value of x[w-i] except x[0] and i have no idea why. Can anyone help? Thanks!

In Kitonums'answer of

http://www.mapleprimes.com/questions/220229-How-Do-I-Solve-A-Differential-Equation-In-Maple

I read a code of remove(t->t=".", b);
t->t="." is a Boolean-valued procedure.

But, then, why does (t->t=".")(9); not return false like (t->t^2)(3); returns 9?
How can I have maple return false?

Thanks in advance.

i wrote a procedure for determine a lambda symmetries and first integrals of ODEs.

Procedure is running but commands is getting error.

Can  anybody help me.

Thanks in advance. procedure.mws

Hi everyone,

I created a procedure "SIM" which depends on two formal parameters x and y. I write Threads:-Map(SIM, x, y) in order to execute it with the Threads package.

I would like to create .mpl files automatically, each one made of the code Threads:-Map(SIM, x, y) with specific values of x and y. For instance:

Threads:-Map(SIM, 5000, 1), then Threads:-Map(SIM, 5000, 2) ... and so on until Threads:-Map(SIM, 5000, 5000).

The fact is, I tried writing the following:

for y from 1 to 5000 do
a[y] := Threads:-Map(SIM, 5000, y);
save a[y], sprintf("SIM_%d.mpl", y)
end do

However, it does not work. The error message says "Error, save can only save names". I also tried, but without success:

for y from 1 to 5000 do
a[y] := Threads:-Map(SIM, 5000, y);
save convert(a[y], name), sprintf("SIM_%d.mpl", y)
end do

Any idea? Thanks a lot.

 

 

Hi Maple Primes,

Can this code be improved?

I know that the Goldbach Conjecture has been checked with computer tools above 10^10.

Request for comments.

check_g_conjecture_26_b.mw

check_g_conjecture_26_b.pdf

Regards

Matt

 

Trying to write a generat purpose procedure insteat of having 3 or 4 different named procceduers.

Need to determine the input types of say A,B,C

Proc(A,B,C)

1) A,B,C could be for the form 3/2 , 5x-7 , x^2-sqrt(x+3)  i.e numbers or formulas

2) A,B,C could be 2 elenent lists [2,3]  , [5x-6y,8x+2] ,[2,sqrt(3)]  i.e 2D points

3) A,B,C could be 3 element lists as above    i.e 3D points

4) A,B,C could be 2D vectors

5) A,B,C could be 3D vectors

A, B, C will not be of mixed types but would be good to check A, B, C for consistency and if not retrun an error

Looking to calculate output based on

If type 1) ......

elif type 2).....

.

.

elif type 5)...

end if

return.....

end proc

 

 

I need to write a procedure that adds all multiples of 5 and 7 less than an arbitrary number. I was thinking something maybe with mod? I am very new to Maple. 

 

On in this same assignment, we are also supposed to generate a sequence using the Fibonacci equation but from an arbitrary pair of initial conditions. So if there are some parallels between these two problems, I would love to learn from that angle.  

We recently in class learned about do loops, so if there is a way to attack these problems with do loops, I would like to hear!

I'm trying to numerically integrate components of the procedure-vector.

interim:=t->evalf(int(r1_lab_deriv(x)[1],x=0..t));

interim(5);

Getting this type of error:

Error, (in r1_rot_deriv) invalid input: fdiff expects its 2nd argument, N, to be of type {integer, name, list(integer), list(name), list(name = constant), set(name), set(name = constant), name = constant}, but received t = x

 A bit of googling gave me an impression that integration of procedures can be rather quirky.

File: ProcIntergration.mw (Problem occurs in the last lines of the file.)

Hello

I wonder if there is a way to see the progress of a specific procedure.  I have checked the forum for some answers and found that some of them propose a progress bar. However the progress bar doesn't seem to fit within a procedure.   

I don't need anything fancy but I need to see the progress of the loop inside of the procedure (over 3,000,000 times).   

Any suggestions?   

Many thanks

 

PS. I am running Maple 2016 too but I would rather see a solution that works on Maple 14 too, if possible.

i copy maple code from notepad to maple in maple window,

there is no error

my function in the code

explicit define parameters are Local type

for example

appendto("...");

func1(aaa)

Local aaa;

 

but when i run cmaple to read the code text file in window 8

it return error

missing operator, syntax error

at Local aaa;

originally 

i have defined

Local aaa, ii;

for ii from 1 to nops(aaa) do

etc.

but it has error too,

then i change to one by one

Local aaa;

Local ii;

still have error at Local aaa;

What is the best way to export/update multiple values from a single procedure? As far as I understand, a procedure does not let you update global values (the inputs), and it returns the value for the last step performed. Let's say for example, I had a procedure like this:

proc(a,b,c)

local x,y;

*series of steps that use a,b, and c to calculate x and y*

end proc

 

How do I get the results for x and y out of the procedure? 

 

Thanks

Hi, I have this procedure (from Maple 5) but I am using it in Maple 15. My problem is this program can not run. I think there is some commond incorrect, but not sure which ones. Please help me in this problem. Thanks a lot.

cocycle.mw

NULL

Cocycle := proc (L, n) local i, j, k, h, v, u, w, C, eqns, e, f, g; v := vector(n); eqns := {}; u := vector(n); w := vector(n); C := array(antisymmetric, 1 .. n, 1 .. n, []); for i to n do for j from i+1 to n do for k from j+1 to n do for h to n do v[h] := L[i, j, h]; u[h] := L[j, k, h]; w[h] := L[k, i, h] end do; e := array(sparse, 1 .. n, [k = 1]); f := array(sparse, 1 .. n, [i = 1]); g := array(sparse, 1 .. n, [j = 1]); eqns := `union`(eqns, multiply(transpose(e), multiply(C, v)))+multiply(transpose(f), multiply(C, u))+multiply(transpose(g), multiply(C, w)) end do end do end do; print('The*cocycles*are', eqns) end proc

proc (L, n) local i, j, k, h, v, u, w, C, eqns, e, f, g; v := vector(n); eqns := {}; u := vector(n); w := vector(n); C := array(antisymmetric, 1 .. n, 1 .. n, []); for i to n do for j from i+1 to n do for k from j+1 to n do for h to n do v[h] := L[i, j, h]; u[h] := L[j, k, h]; w[h] := L[k, i, h] end do; e := array(sparse, 1 .. n, [k = 1]); f := array(sparse, 1 .. n, [i = 1]); g := array(sparse, 1 .. n, [j = 1]); eqns := `union`(eqns, multiply(transpose(e), multiply(C, v)))+multiply(transpose(f), multiply(C, u))+multiply(transpose(g), multiply(C, w)) end do end do end do; print('The*cocycles*are', eqns) end proc

(1)

NULL

NULL


Download cocycle.m

Hello

It has been years since I last used maple so I apologize if my question makes no sense and my code is outdated (and wrong!).   

I need to write a function (proc) that uses a functional operator inside.  Something like

test:=proc()

local f,vars, func, aux, res;

f:=arg[1]; # a list

vars:=arg[2]: # a list

aux:=op(vars):

func:=aux -> f:  # a function from () to []

res:=func(op(func(aux))):

return(res):

end:

 

This is the basic idea of the proc.  If f:=[y, y*z-x, -15*x*y-x*z-x] and vars:=[x,y,z], the function of a function does not return as it supposes to.  Please tell me what I am doing wrong and how to improve and update the code.

 

many thanks

 

Ed

 

 

 

hi....how i can extract Coefficients  (i.e. {f1[2],f2[2],f2[3],f3[2],.....f3[6]}) from every algebric equations and create matrix A ,in form AX=0, (X are f1[2],f2[2],f2[3],f3[2],.....f3[6] ) then the determinant of the matrix of coefficients (A) set to zero for obtaining unknown parameter omega.?

Note that  if m=3 then 6 equations is appeare and if m=4 then 9 equations is appeare.thus i need a procedure that works for every arbitary value of ''m''.

in attached file below m=4 thus we have 9 equations, i.e. 3 for eq1[k_] and 3 for eq2[k_] and so on...

also we should use boundary conditions for some amount of fi[j] (i=1,2,3 and j=2,3,...,7)

be extacting above Coefficients for example from first equation ,

''**:= (1/128)*f1[2]*omega^2-(1/4)*f2[2]-(1/2)*f2[3]+(1/4)*f2[4]+(1/4)*f3[2]-(1/2)*f3[3]+(1/4)*f3[4]+140*f1[2]-80*f1[3]+20*f1[4]'''

must compute

coeff(**, f1[2]); coeff(**, f2[2]) and so on...

 

 

 

 

 

fdm-maple.mw

 

 ############################Define some parameters

 

 
restart; Digits := 15; A1 := 10; A2 := 10; A3 := 10; A4 := 1; A5 := 1; A6 := 1; A7 := 1; A8 := 1; A9 := 1; A10 := 1; A11 := 1; B1 := 10; B2 := 10; B3 := 10; B4 := 1; B5 := 1; B6 := 1; B7 := 1; B8 := 1; B9 := 1; B10 := 1; B11 := 1; C1 := 10; C2 := 10; C3 := 10; C4 := 1; C5 := 1; C6 := 1; C7 := 1; C8 := 1; C9 := 1; C10 := 1; C11 := 1; C12 := 1; C13 := 1; C14 := 1; C15 := 1; C16 := 1; A12 := 1; B12 := 1; C18 := 1; C17 := 1; C19 := 1; n := 1; U := proc (x, theta) options operator, arrow; f1(x)*cos(n*theta) end proc; V := proc (x, theta) options operator, arrow; f2(x)*sin(n*theta) end proc; W := proc (x, theta) options operator, arrow; f3(x)*cos(n*theta) end proc; n := 1; m := 4; len := 1; h := len/m; nn := m+1
 ############################Define some equation

eq1[k_] := -2*f1[k]*(-A11*n^4+A10*n^2+A12*omega^2)*h^4+(A6*(f2[k-1]-f2[k+1])*n^3+A9*(f3[k-1]-f3[k+1])*n^2-A5*(f2[k-1]-f2[k+1])*n-A8*(f3[k-1]-f3[k+1]))*h^3+(4*(f1[k]-(1/2)*f1[k-1]-(1/2)*f1[k+1]))*(A3*n^2-A2)*h^2+(-A4*(f2[k-2]-2*f2[k-1]+2*f2[k+1]-f2[k+2])*n-A7*(f3[k-2]-2*f3[k-1]+2*f3[k+1]-f3[k+2]))*h+12*A1*(f1[k]+(1/6)*f1[k-2]-(2/3)*f1[k-1]-(2/3)*f1[k+1]+(1/6)*f1[k+2]):
  ``

 

 

 

 

                                     ######################################  APPLY BOUNDARY CONDITIONS

f1[nn+1] := f1[m]:
 

for k from 2 to m do eq1[k_]; eq2[k_]; eq3[k_] end do

-(1/64)*f2[4]+(1/128)*f2[3]+(1/64)*(f3[4]-(1/2)*f3[3])*(omega^2-1)-(1/64)*f1[2]+(1/32)*f1[3]+(1/64)*f1[4]-280*f3[4]-120*f3[2]+300*f3[3]+20*f3[7]

(1)

``



Download fdm-maple.mw

 

Hi MaplePrimes,

 

I try again to ask about a procedure I wrote.  Maybee someone can spot my error.

 

collatz_conjecture_2.mw

Here is the broken procedure - 

cs := proc (n::integer)::integer;
local count;
description "Find the number of steps for a Collatz sequence to reach 1";
count := 1;
while 1 < n do
if `mod`(n, 2) = 0 then n := (1/2)*n else n := 3*n+1 end if;
count := count+1
end do;
return count
end proc

Regards,

Matt

 

1 2 3 4 5 6 7 Last Page 1 of 23