Items tagged with function function Tagged Items Feed

Hi there,

I was trying to simulate the behaviour of a one-variable, discrete-time function having three parameters.

The function reads

M[n+1]=(b·theta^(m)·R[n])/(theta^(m)+R[n]^m)

defined for b, theta, m > 0

Say I want to simulate the function for the following values

b := [seq(1 .. 10, 1)];
theta := [seq(1 .. 5, 1)];
m := [seq(1 .. 2, 1)];

for n from 1 to 10.

 

I guess I need to build a 4-dimension array. But I was not able to find the right way to do this: should I use the Array strucutre? and if yes, how would I do it? As far as I've read, indexing would be an issue: should I create special indexing functions?

If I'm not wrong Maple matrices (Matrix) are just 2D.

 

Once the values of M computed, I would like to generate the corresponding plots, varying one parameter while the other two are fixed, and drawing the different M's in the same plot.

How can I achieve this?

Furthermore, if I would like to generate all possible combinations, I guess I would need to insert the solution given to the above question within a for loop. Will Maple display all plots or will it overlap/overwrite the preceding plot if used within a loop?

 

Thanks,

jon

In Maple, I want to define a set of functions by means of two for loops:

    printlevel:=2;

    # Node coordinates.
    N_x:=5;
    N_y:=4;
    N_elx:=N_x-1;
    N_ely:=N_y-1;
    h_x:=(x_e-x_s)/N_elx;
    h_y:=(y_e-y_s)/N_ely;
    x_n:=[seq(x_s+j*h_x,j=0..N_elx)];
    y_n:=[seq(y_s+j*h_y,j=0..N_ely)];

    # Partition of unity.
    for j from 2 by 1 to N_x-1 do
        for k from 2 by 1 to N_y-1 do
            phi[j,k]:=(x,y)->(x-x_n[j-1])*(x-x_n[j+1])*(y-y_n[k-1])*(y-y_n[k+1])/((x_n[j]-x_n[j-1])*(x_n[j]-x_n[j+1])*(y_n[k]-y_n[k-1])*(y_n[k]-y_n[k+1]));
        od;
    od;

However, this gives output in which the `[j,k]` vary but the `x_n[j-1]`, `x_n[j+1]`, `y_n[j-1]` and `y_n[j+1]` are not evaluated. But if I for instance input `x_n[3]` I correctly get 1/2 as answer.

How do I solve this?

Hi

How can I substitute a function in a matrix? This is what I tried but it's not working at all:

lign1:=x-y+2*z=1:
lign2:=(-2)*x+y+z=0:
lign3:=(-4)*x+y+7*z=2:
lign4:=3*x-2*y+z=1:
T := GenerateMatrix([lign1, lign2, lign3, lign4],[x, y, z], augmented);

Then I'd like to substitute another function with lign1:

lign5:=x+y+z=6:
T2:=subs(lign1=lign5, T);

But T2 = T and that wasn't really the point.

 

Sorry if the answer is obvious no amount of searching has helped me so far. I hope this question isn't too ridiculous.

Thanks

Hello,

 

I have a function, lets say g(x,y,...), that depends on many other functions. But I don´t want the results that are inside certain intervals, and I need to receive the results of those functions as something like NULL when asking for a result that is inside any of those intervals. That way, g(x,y,...) would also have to result in something like NULL if any of the lesser functions are NULL fora any given values.

 

I tryied using the piecewise command, and for the intervals that I wanted, it worked, but for those I wanted to be NULL, they were understood as 0, and so G(x,y,..) continued to exist but with a very different value.

 

To clarify what I need, I will try an exemple:

 

Imagine I have the function f(x)=x

 

I want to disconsider the results for x<2 and x>6, in a way that if I try the command 'f(1)', I will receive something like NULL and know that it is outside the range.

 

In the same way, I need the plot of this function f(X) to show the function only from 2 to 6, but not existing for the delimited intervals.

 

Ad if I continue and make g(x)=f(x)+10 , I don´t want g(x) to exist if f(x) doesn´t exist, and same for the g(x) plot, which shouldn´t be shown in the intervals where f(x) don´t exist.

 

 

Thank you very much for your atention!

 

 

Hi there,

first post. I am a beginner both with Maple and this forum, so please forgive my mistakes. Just here to learn.

I could not successfully use the Maple editor here, so the code goes as plain text, although I also attach the code: MapleSimulation_test.mw.

I am trying to simulate the function below for certain values of the parameters, but when executing the loop, Maple prints just R. Can anyone tell me where my error is, please?

 

f := .25; g := 1; R[0] = 5; R[1] = 4.8; nDays := 30;

lambda1:=(1 - f + sqrt((1 - f) + 4*g*f)*1/2;

lambda2:=(1 - f - sqrt((1 - f) + 4*g*f)*1/2;


       -lambda2*R[0] + R[1]
k1:=--------------------------;
       lambda1 - lambda2

       lambda2*R[0] - R[1]
k2:=-------------------------;
      lambda1 - lambda2

R:=n-> k1*lambda1^n + k2*lambda2^n


for n from 2 to nDays
do R:=evalf(subs(n=%,R));
od;

Consider the following two variable funtion:

f(x,y)=x^2+y^2-5

then we want to draw a contourplot:

contourplot(f,x=-10..10,y=-10..100)

My problem is that I want maple to diplay the value of the function "f" relating to each curve on the contour plot!
How can I do this?

Please see the following code.

Example.mw

Hi. It is be good to be with you after 4 years.

I want to ask about Curvefitting for Data. If I have a numerical data and i want to find a function in x and y for these data.

 

 

but if restart the program,the menu of Plot Builder is appear,in same function(x^2+y^2+(1/1000000000)*z-25 = 0),why thing like this happen?

when run the order like this, the menu of Plot builder disapper

Thank you in advance for your help

How can I plot a volume (many surfaces) in X,Y, Z axis where X,Y,Z are functions in 4 variables (a,b,c,d), and the domain for the 4 variables are 

-90<=a>=90, -10<=b>=10, -12<=c>=12, -90<=d>=0,

 

X := proc (a, b, c, d) options operator, arrow; 324.*cos(b)*sin(c)*cos(d)+324.*sin(b)*sin(d)+323.5*cos(b)*sin(c) end procX := proc (a, b, c, d) options operator, arrow; 324.*cos(b)*sin(c)*cos(d)+324.*sin(b)*sin(d)+323.5*cos(b)*sin(c) end proc

Y := proc (a, b, c, d) options operator, arrow; (324*1.*sin(a)*sin(b)*sin(c)+324*1.*cos(a)*cos(c))*cos(d)+(-1)*324.*sin(a)*cos(b)*sin(d)+323.5*sin(a)*sin(b)*sin(c)+323.5*cos(a)*cos(c)-100 end proc

Y := proc (a, b, c, d) options operator, arrow; (324*1.*sin(a)*sin(b)*sin(c)+324*1.*cos(a)*cos(c))*cos(d)+(-1)*324.*sin(a)*cos(b)*sin(d)+323.5*sin(a)*sin(b)*sin(c)+323.5*cos(a)*cos(c)-100 end proc

Z := proc (a, b, c, d) options operator, arrow; (324*cos(a)*sin(b)*sin(c)-324*sin(a)*cos(c))*cos(d)-324*cos(a)*cos(b)*sin(d)+323.5*cos(a)*sin(b)*sin(c)+(-1)*323.5*sin(a)*cos(c)+150 end proc

Z := proc (a, b, c, d) options operator, arrow; (324*cos(a)*sin(b)*sin(c)-324*sin(a)*cos(c))*cos(d)-324*cos(a)*cos(b)*sin(d)+323.5*cos(a)*sin(b)*sin(c)+(-1)*323.5*sin(a)*cos(c)+150 end proc

i want to use dictionary or hashtable in maple

the key are a function, value are a list of things

 

how to do?

Hi all

I have written the following code in maple to approximate arbitrary functions by hybrid of block-pulse and bernstein functions but it doesn't work properly especially for f(t)=1.0, so what is the matter?

bb1.mws

 


best wishes

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department

I'm used to Mathcad, and I am very new to Maple. Something I cannot figure out right now is how to define multiple elments of a matrix using a function.


Input Data

Define system dimensions as n:=2;

i:=1..n;

j:=1..n;

lambda:=Matrix(n);

Lambda:=Matrix(n);

upsilon:=vector(n); 

Minor side note: I originaly had upsilon defined using the syntax "Vector[row](ncomp)", but this was giving me an 'exponentiation' operation error, so I changed it to what it is now (basically a list/array, which I guess has different type definitions that no longer cause the error?).

lambda[1,2]:=471.0433;

lambda[2,1]:=883.7530;

upsilon[1]:=58.69;

upsilon[2]:=18.07;

The Problem I'm Having

Now I just want to define Lambda using a function to define all elements (like I would in Mathcad).

Lambda[i,j]:= (upsilon[j]/upsilon[i]) * exp (-lambda[i,j]/2853);

which gives me an extremely long error message:

Error, invalid input: exp expects its 1st argument, x, to be of type algebraic, but received Matrix(2, 2, {(1, 1) = -0.3504976272e-3, (1, 2) = -.16509955895845776, (2, 1) = -.30975332953088164, (2, 2) = -0.3504976272e-3}, datatype = float[8]

As far as I can tell (keep in mind that this is my very first Maple project) that it doesn't like lambda as a matrix? But shouldn't it just evaluate to the element? and why is (2,2) and (1,1) giving values, because it should intialize to zero, so exp(0) = 1 in these cases??

I tried to simplify further by just trying

Lambda[i,j]:=(upsilon[j]/upsilon[i]);

but then it just gives me 1, and when I look into Lambda all the elements are now 1 when only the diagnol elements should be 1 (the rest some fractional amount)??

I am at a complete loss. I thought about doing something like For i = 1 to n etc. but then it just looks like coding, which defeats the purpose of trying to make a calculation sheet documenting the procedure...

Any help and/or insights into what I am doing wrong here would be most welcomed :)

P.S. I've just noticed that there is an upload option :/ Wilson_Equation.mw.

 

Hi,

This maybe a really simple question, I remember this is doable but couldnt find where the answer is.

Say I write a function to sum up all values in the list,

mysum:=proc(data::list)

return printf("The sum is %3.3f. ", sum(data[i],i=1..numelems(data)));

end proc;

 

and I use it like,

mysum(listA);

mysum(listB);

 

How would I print out a more informative string, like this:

"The sum of listA is %3.3f. "

"The sum of listB is %3.3f. "

 

Use "data", the input, as a string argument.

 

Thanks,

 

casper

Hi Maple friends.

If I have a table of values, how can Maple provide the function?

For example:

x=10,15,20,25,30,35,40

y=2.01,4.87,6.50,9.875,14.00,18.90,24.40

How can Maple find out the y function with respect to x? 

Thanks in advance.

Hi,

 

I'm trying to make a piecewise function that will have period 12. That is, it repeats every 12 units across the x-axis.

 

I managed to do one cycle successfully with

plot(piecewise(0<=t and t<2, 4,2<=t and t<12,0), t=0..13);

But I'm not sure how to do it periodically. I thought about using modular arithmetic in the conditions and setting up something like

H(t)=piecewise(0<=modp1(f(t),12) and modp1(f(t),12)<2, 4,2<=modp1(f(t),12) and modp1(f(t),12)<12,0);

but this clearly doesn't work.

 

Some direction or advice would be appreciated. Thanks!

 

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