MaplePrimes Questions

Dears,

I have a question and I hope someone will be able to answer it.

I would like to create a matrix of functions depending on the number of the line or the arrow. I think the best is to show with a very basic example:

I have the following program

n:=4:

R:=Matrix(1,n):

for i from 1 to n do: R(1,i):=x->i*x:end do:

So, I have a matrix, one row, n columns. At the ith column, I want to have the function f(x)=i*x.

Unfortutanely, with my program, I obtain for example for the first column the function f(x)=11*x. At the second column, I get the same result. It seems that I can define matrices of functions but it is impossible in the definition of the function to use the number of the column. Do you have any idea about how to write a program?

Any help would be very appreciated. 

 

 

For a 2D parametric plot with only one parameter, in Maple we use plot([x,y,range]) but what about the case x and y are expressed by more than one parameter? How should I assign the range? For example I tried the following one

h := k[1]*k[3]+k[1]*k[4]+k[2]*k[4]:
x := k[2]/h:
y := (k[3]+k[4])/h:
A := seq(k[i] = 1 .. 2, i = 1 .. 4):
plot([x, y, A]);

But then I encountered the following error:
Error, (in plot) incorrect first argument [k[2]/(k[1]*k[3]+k[1]*k[4]+k[2]*k[4]), (k[3]+k[4])/(k[1]*k[3]+k[1]*k[4]+k[2]*k[4]), k[1] = 0.1e-2 .. 1000, k[2] = 0.1e-2 .. 1000, k[3] = 0.1e-2 .. 1000, k[4] = 0.1e-2 .. 1000]

For one parameter the above method doesn't make an error like the following:

x := t+1:
y := t^2:
A := t = 1 .. 2:
plot([x, y, A]);

So for more than one parameter, there should be another way to ask the plot. Does anyone know how to do that?

I want to plot a simple power function in diferent pieces by using diferent range and  for different values of parameter a[i] at i=0,1,2 define in the attached sheet.

plot_at_different_intervals.mw

Given a list L of n^2 integers, I can fill an nxn matrix through Matrix(n,n,L).  for instance:
n := 4:
L := [$1..n^2]:
A := Matrix(n,n, L);

I don't know how to do this with a 0-based Array.  I wished that as in the case of the Matrix, the command
B := Array(0..n-1, 0..n-1, L);
would assign B[0,0]=1, B[0,1]=2, ..., B[3,3]=16, but it doesn't.

I know how to fill B's entries through doubly nested for-loops but I suspect that there might be a clever way of doing that. If so, then please show me how.

 

I wonder if there is a way to represent each piece of a piecewise function in Maple.

For example, for a piecewise function: f:=x->piecewise(1<=x<=2,c[1]*x+c[2],2<=x<=3,c[3]*x+c[4],3<=x<=4,c[5]*x+c[6]);

I want to have a way to retrieve each piece, e.g.: c[3]*x+c[4], but f(x)[2] doesn't work.

Is it archievable?

On Y axis: (Each set represents a car and each set has 10 values for different position of same car)

[[761, 768, 776, 784, 793, 803, 813, 823, 833, 842], [723, 725, 728, 731, 734, 738, 743, 749, 756, 764], [516, 516, 516, 517, 519, 522, 526, 531, 536, 541], [382, 384, 386, 389, 393, 398, 404, 411, 419, 427], [78, 86, 95, 105, 115, 125, 135, 144, 154, 164], [751, 760, 770, 780, 790, 799, 809, 819, 829, 839], [773, 783, 793, 803, 812, 822, 831, 840, 850, 859], [160, 170, 180, 189, 199, 209, 219, 229, 239, 249],.....]

On X axis: (time for 1 to 10)

[1,2,3,4,5,6,7,8,9,10] for each of above sets. 

In each set for example, 1 corresponds to 761, 2 to 768 and so on until 10 to 842, then onto next set. The number of sets I will generate can be between 50-500. And I need to have all of the same graph. This data will tell me under the conditions I set how one car's position effects other cars. 

I also have relative velocity values in same format:

[[7, 7, 8, 8, 9, 10, 10, 10, 10, 9], [1, 2, 3, 3, 3, 4, 5, 6, 7, 8], [0, 0, 0, 1, 2, 3, 4, 5, 5, 5], [1, 2, 2, 3, 4, 5, 6, 7, 8, 8], [8, 8, 9, 10, 10, 10, 10, 9, 10, 10], [8, 9, 10, 10, 10, 9, 10, 10, 10, 10], [10, 10, 10, 10, 9, 10, 9, 9, 10, 9], [9, 10, 10, 9, 10, 10, 10, 10, 10, 10], [8, 8, 9, 9, 9, 10, 9, 9, 9, 9], [8, 9, 10, 9, 10, 9, 10, 9, 10, 9], [9, 10, 9, 9, 10, 10, 10, 10, 10, 10], [7, 7, 8, 9, 10, 10, 9, 9, 10, 10], [10, 10, 10, 9, 9, 10, 9, 10, 10, 10],...]

I will also need to graph this. 

Please Help!
 

Hello people in mapleprimes,

Please help me with simplifying the next expression.
This e1 has the expression of ((epsilon-1)*k/epsilon)^epsilon in the numerator and the denominator. How can I collect each of them with that expression?

e1.mw

Thanks in advance.

Taro

 

I have to plot 10 squares each one inscribed into each other. After the first one, which is a square with a side of 10m, each following square has got each edges wich are distant from the previous edges (side of the previous square)/4 metres, on the

 

sides of the previous square

How can i draw it?


 

Hello,

To check my arguments in a procedure I need something like

myproc := proc(M :: Matrix(square, rational)

                       , N :: Matrix(shape=triangular[lower, unit], datatype = rational
                       , O :: Matrix(shape = square, dimension = 5

               )

end proc;

How does that work in Maple? What is the correct Syntax? I tried many different things that doesn't fit.

If I calculate the integral:

z:=exp(I*t)

evalf(Int(z^(1/2)*(diff(z, t)), t = 0 .. 2*Pi))

I get -1.33333333*I

If I calculate

int(z^(1/2)*(diff(z, t)), t = 0 .. 2*Pi)

I get -4/3

so where is the I coming from? Am I doing sth  something   wrong?

I might add: if I calculate the same for z:=0.5+exp(I*t) I get 0 and -I*0.4714....

so what is going different here?

Try this command.

display(semitorus([0, 0, 0], 0 .. Pi, 1, 2), lightmodel = light4, orientation = [-140, 60], scaling = constrained, style = patchnogrid)

I get this mess. The picture on the help page doesn't look any better.Setting the range 0..2 Pi looks fine though. So I think it is a bug.

What I was trying to do is plot 3/4 of a torus i.e circle disk swept in 3/4 of a carcle with capped ends. What is a good way?

I am trying to use a do loop with if/else statements to create a 5x5 unit matrix. I made an empty array. Converted it to a matrix. Then made a do loop where I was trying to get the matrix elements where i=j to be 1 and all else to be 0. It didn't spit out a matrix.

Any advice? I assume I must have missed a small detail in syntax.


 

with(LinearAlgebra):

````

U := array(1 .. 5, 1 .. 5);

array( 1 .. 5, 1 .. 5, [ ] )

(1)

NULL

for i to 5 do for j to 5 do if i = j then U[i, j] := 1 else U[i, j] := 0 end if end do end do

U;

U

(2)

``


 

Download fail_unit_matrix_loop.mw

By the way, I am open to completely different methods, also! I was just trying to use loops to do it rather than inbuilt commands.

Hi all,

I am working on a Maple file to find the right force excerted in a specifik angle (theta). This is the script Maple than has to work out:

 

eq4 := Fh1 = (1/2)*(solFh2*sqrt(2)-40)/sin(theta);
eq5 := Fh1 = (1/2)*(solFh2*sqrt(2)-100)/cos(theta);
sol := solve({eq4, eq5}, {Fh1, theta});

Next it gives me the answers as following:

sol := {Fh1 = 121.6477702, theta = .9606764638}, {Fh1 = -121.6477702, theta = -2.180916190}

Which is correct: I get a force (Fh1 = ± 121.6477...) with 2 angles (theta = .9696... or theta=-2.1809...)

 

If i want to continue working with Fh1 it gives an error saying it has 2 values for it (obviously a positive and a negative value). Is there a way to continue working with the positive values of Fh1 and theta?

 

I was thinking of solving the intersect equation on the positive 'theta'-axis in a form like:

 

sol := solve({eq4, eq5}, {Fh1, theta>0}); as theta is my horizontal axis and a positve theta gives me a positive Fh1 but Maple doesn't work that straightforward. 

 

Thanks a lot!

Hi I was wondering if you can help me with some maple commands about using Euler's method. My professor created a tutorial on using some commands to calculate the value via Euler's method. 

Her commands in the tutorial for using Euler's method  for a differential equation- dy/dx= x+y   y(0)=1

x0:=0:y0:=1:xf:=1:n:=10:

h:=evalf((xf-x0)/n);

f:=(x,y) -> x+y

x:=x0:y:=y0:

This next step confuses me the most, my professor uses this syntax to compute the values of approximation via Euler's method. N represents the number of pieces we want to approximate the value with. X0 is initial and XF is final. 

forifrom1tondo k:=f(x,y):y:=y+h*k:x:=x+h:print(x,y):od:

I tried replicating this syntax on the exact same problem, copying the syntax commands word for word. Yet, I keep getting the same error "unable to parce" error, with the "od" being highlighted. But on her tutorial, it gave her an two columns with the intervals (n) and all it's values. She even did the same did for only wanting 1 loop printed 

forifrom1tondo k:=f(x,y):y:=y+h*k:x:=x+h:od:print(x,y):.   And it gave her only 1 loop.

I tried both and still got the error. Please Help, Thanks in advance

Hey, i'm trying do demonstrate that a nonlinear system has a semistable limit cycle but i get a warning at the plot command saying "Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct" and i dont understand it. So i wonder if someone here could help me? 

 

restart; with(PDEtools); with(plots);
eq1 := diff(x(t), t) = x(t)*(x(t)^2+y(t)^2-1)^2-y(t);
                                             2       
           d              /    2       2    \        
          --- x(t) = x(t) \x(t)  + y(t)  - 1/  - y(t)
           dt                                        
eq2 := diff(y(t), t) = y(t)*(x(t)^2+y(t)^2-1)^2+x(t);
                                             2       
           d              /    2       2    \        
          --- y(t) = y(t) \x(t)  + y(t)  - 1/  + x(t)
           dt                                        
tr := {x(t) = r(t)*cos(theta(t)), y(t) = r(t)*sin(theta(t))};
     {x(t) = r(t) cos(theta(t)), y(t) = r(t) sin(theta(t))}
eq1b := dchange(tr, x(t)*eq1+y(t)*eq2, [r(t), theta(t)], simplify);
              / d      \       2 /        4         2\
         r(t) |--- r(t)| = r(t)  \1 + r(t)  - 2 r(t) /
              \ dt     /                              
eq1b := expand(eq1b/r(t));
                d                    5         3
               --- r(t) = r(t) + r(t)  - 2 r(t) 
                dt                              
eq2b := dchange(tr, y(t)*eq1-x(t)*eq2, [r(t), theta(t)], simplify);
                      2 / d          \        2
                 -r(t)  |--- theta(t)| = -r(t) 
                        \ dt         /         
eq2b := simplify(eq2b/(-r(t)^2));
                         d              
                        --- theta(t) = 1
                         dt             
sol1 := dsolve({eq1b, r(0) = r[0]}, r(t));
          /      /  /     2  \                 
          |      |  | r[0]   |          2     2
r(t) = exp|RootOf|ln|--------| (exp(_Z))  r[0] 
          \      \  \r[0] - 1/                 

                           2     2
   - ln(r[0] + 1) (exp(_Z))  r[0] 

       /             2\                                       
       |(exp(_Z) - 1) |          2     2            2        2
   - ln|--------------| (exp(_Z))  r[0]  + (exp(_Z))  _Z r[0] 
       \ exp(_Z) - 2  /                                       

                                /     2  \              
                2     2         | r[0]   |             2
   + 2 (exp(_Z))  r[0]  t - 2 ln|--------| exp(_Z) r[0] 
                                \r[0] - 1/              

                                2
   + 2 ln(r[0] + 1) exp(_Z) r[0] 

         /             2\                                   
         |(exp(_Z) - 1) |             2                    2
   + 2 ln|--------------| exp(_Z) r[0]  - 2 exp(_Z) _Z r[0] 
         \ exp(_Z) - 2  /                                   

                           /     2  \           
                   2       | r[0]   |          2
   - 4 exp(_Z) r[0]  t - ln|--------| (exp(_Z)) 
                           \r[0] - 1/           

                                 /             2\           
                           2     |(exp(_Z) - 1) |          2
   + ln(r[0] + 1) (exp(_Z))  + ln|--------------| (exp(_Z)) 
                                 \ exp(_Z) - 2  /           

                                          /     2  \        
              2                   2       | r[0]   |        
   - (exp(_Z))  _Z - 2 t (exp(_Z))  + 2 ln|--------| exp(_Z)
                                          \r[0] - 1/        

                                  /             2\        
                                  |(exp(_Z) - 1) |        
   - 2 ln(r[0] + 1) exp(_Z) - 2 ln|--------------| exp(_Z)
                                  \ exp(_Z) - 2  /        

              2                                    2            
   - (exp(_Z))  + 2 _Z exp(_Z) + 4 t exp(_Z) + r[0]  + 2 exp(_Z)

      \\    
      ||    
   - 1|| - 1
      //    
sol1 := simplify(sol1);
          /      /   /     2  \                
          |      |   | r[0]   |               2
r(t) = exp|RootOf|-ln|--------| exp(2 _Z) r[0] 
          \      \   \r[0] - 1/                

                                2
   + ln(r[0] + 1) exp(2 _Z) r[0] 

       /             2\                                     
       |(exp(_Z) - 1) |               2                    2
   + ln|--------------| exp(2 _Z) r[0]  - exp(2 _Z) _Z r[0] 
       \ exp(_Z) - 2  /                                     

                               /     2  \              
                     2         | r[0]   |             2
   - 2 exp(2 _Z) r[0]  t + 2 ln|--------| exp(_Z) r[0] 
                               \r[0] - 1/              

                                2
   - 2 ln(r[0] + 1) exp(_Z) r[0] 

         /             2\                                   
         |(exp(_Z) - 1) |             2                    2
   - 2 ln|--------------| exp(_Z) r[0]  + 2 exp(_Z) _Z r[0] 
         \ exp(_Z) - 2  /                                   

                           /     2  \          
                   2       | r[0]   |          
   + 4 exp(_Z) r[0]  t + ln|--------| exp(2 _Z)
                           \r[0] - 1/          

                                /             2\          
                                |(exp(_Z) - 1) |          
   - ln(r[0] + 1) exp(2 _Z) - ln|--------------| exp(2 _Z)
                                \ exp(_Z) - 2  /          

                                        /     2  \        
                                        | r[0]   |        
   + exp(2 _Z) _Z + 2 t exp(2 _Z) - 2 ln|--------| exp(_Z)
                                        \r[0] - 1/        

                                  /             2\        
                                  |(exp(_Z) - 1) |        
   + 2 ln(r[0] + 1) exp(_Z) + 2 ln|--------------| exp(_Z)
                                  \ exp(_Z) - 2  /        

                                                  2            
   + exp(2 _Z) - 2 _Z exp(_Z) - 4 t exp(_Z) - r[0]  - 2 exp(_Z)

      \\    
      ||    
   + 1|| - 1
      //    
sol2 := dsolve({eq2b, theta(0) = theta[0]}, theta(t));
                    theta(t) = t + theta[0]
theta[0] := (1/4)*Pi;
                              1   
                              - Pi
                              4   
plot1 := polarplot([subs(r[0] = .1, rhs(sol1)), rhs(sol2), t = 0 .. 10], color = red);
Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct
plot2 := polarplot([subs(r[0] = 2, rhs(sol1)), rhs(sol2), t = 0 .. 10], color = blue);
Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct
display({plot1, plot2}, scaling = constrained, tickmarks = [4, 3], view = [-2 .. 2, -2 .. 2]);

3 4 5 6 7 8 9 Last Page 5 of 1445