Items tagged with proc proc Tagged Items Feed

How to use proc

14 hours ago by serena88 20

Hi, i am learning how to use "proc", could you please help me with this?

Case 1:

ReturnInteger:=proc(x,y,z)::integer;
g:=3+y;
x^2-g;
end proc:

ReturnInteger(3,2,4)

Case 2: How do I have a few outputs at a time?

Outp:=proc(x,y,z)::integer;
x^4+3
x+3*y;
y+z;
end proc:

Outp(3,4,2)

I am looking for it to produce 3 answers.

Question 3, when i took away the "::integer", it still works. May I know...

decom:=proc(n::posint,m::posint)
> local a,c,d::posint,e,f,i,j,k,l,s,t,u;s:=[];t:={};u:={};
> if m=n then return [[1$m]];fi;
>  for i from 1 to nops(decom(n-1,m)) do
>   a[i]:=op(i,decom(n-1,m));# a is a list
>   c[i]:=[op({op(a[i])})];
>   #d[i,j]:=coun(a[i],op(j,c[i]));#c:unrepeated numbers in a. d:number of repeatance
>    for k from 1 to nops(c[i]) do
>     e[i,k]:=aadd1(c[i],k);

decom:=proc(n::posint,m::posint)
> local a,c,d::posint,e,f,i,j,k,l,s,t,u;s:=[];t:={};u:={};
> if m=n then return [[1$m]];fi;
>  for i from 1 to nops(decom(n-1,m)) do
>   a[i]:=op(i,decom(n-1,m));# a is a list
>   c[i]:=[op({op(a[i])})];
>   #d[i,j]:=coun(a[i],op(j,c[i]));#c:unrepeated numbers in a. d:number of repeatance
>    for k from 1 to nops(c[i]) do
>     e[i,k]:=aadd1(c[i],k);

Hi,

i want to use "dsolve({ODE1, IC1, IC2},numeric)" in a procedure. But it has some problems with the curly brace. Is there a special command to replace the curly brace?

Thanks

Hey,

i have 2 differential equations and want to solve the first one when x is positive and the second when x ist negativ. For this problem i wrote the follwing procedure. But when i try i have the posted error. Has someone a good idea to help me?

Thanks a lot

 

> DGL3 := 10*(D(D(x)))(t) = x(t);

> DGL4 := 10*(D(D(x)))(t)+5000 = x(t);

 

Tsolver:=proc()
global DG1, DG2, func, var, var_min, var_max, x, Dx, N:

Hi,

Im trying to animate a simple pendulum with maple 15. I'm able to make to the pendulum masse move, but, somehow, I can't animate the rope of the pendulum. I tried to draw the rope with the plottools library line , but no success.

Pendulum:=proc(x,y)plots[pointplot]([x,y],color=blue, symbol=solidcircle,symbolsize=25) end proc:
A:=animate(Pendulum,[XCoordinate,YCoordinate],t=0..8,frame=100):
Rope:=plottools[line]([0,1],[XCoordinate,YCoordinate],color=blue,thickness=3):

Hello everyone

I want to check whether a recurrence relation produces integers. What I have written is rather messy, I ideally would like some kind of Proc where I can just put in the recurrence relation, the initial conditions and the number of terms I would like to check. Then get a result out which tells me whether the terms in the sequence are all integer. 

 

I have written the following (which tells me what I want to know but in a crude way)

I've set up part of my procedure to calculate the values of i from 1 to 15 using for loops.  I only need the values from 1 to 15, but a later part of my procedure if failing because it says it cannot evaluate the value for i=16.  How do I tell Maple that i>=16 doesn't matter/do nothing for i>= 16?

After understanding how one part of code works i also see that it uses trick of eval (namely "procedural substitution"):

restart;
r:=f(g(u), h(w)):
eval(r, [g=proc() ll; end proc]):

gets full substitution with arguments

and

restart;
r:=f(g(u), h(w)):
eval(r, [g=ll]):

do simple one 'by name'.

Where can i read about that?

custom component

November 20 2011 by a_simsim 0 MapleSim

Dear Maplers

I would like to define a component in MapleSim, which is difficult to write with a single equation, but rather it would be defined with a bunch of equations (a procedure). Can it be done programatically, i.e. can I write my own code (procedure) in Maple programming language to define the component? Or should I subdivide the problem to smaller steps (equations) and define a component for each of them? What would be the best way? Could you possibly give an example?

test.zip

1) Compile under vc express 2010 debug config. Don't forget point out your location of maplec.lib in configuration properties/Linker/General/Additional library directories. Assure that configuration is at least Debug or all.

2) Run sheet test_bombard.mw from Debug directory.

 

Have permanent crash on BombardByRandoms call. If i would transmit creating of rtable from 'InitInternal'...

b) Define a procedure f(x, y) which returns 1 if x < y and 1 if

I have a module to overload the * operator for the function f such that:

a*f(b,c,d) = f(a*b,a*c,a*d)

FPackage :=  module()option package;    export `*`;    `*` :=    overload    (      [        proc(a::algebraic, b::specfunc(anything, f))          option overload;          map2(:-`*`, a, b...

How do I edit a large proc to replace a couple of lines or add a few more if I don't save it and the screen was cleared?  Am I out of luck and have to retype it all back in?

And how do I substitute in a proc n_pts<5 to n_pts<5  or say substitute i=50 to i=30 .  I'm stuck with the operators.  I thought using delayed evaluation would work.  ie/  newproc:=subs( 'i=5' = 'i=30' , eval(newproc))

Hi,

somehow Maple does not integrate a procedure in the correct way. And I don't know why. Could you please help?

This procedure creates a matrix of a special form

P:=proc(n,k,A,d,Lambda)

local p,i,j,m,off,eps:  

if n<6 then print("n greater 6"): return: end if:  

if (n mod 4)<>2 then print("n has to be n (mod 4) = 2 "): return: end if:  

eps:=proc(m,A,Lambda,k) (k+m*Lambda*2)^2+A/2 end proc:  

1 2 3 4 Page 1 of 4