Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I am writing a code which for various discrete x values needs to import from a pre established file,  values of f(x), which must be used for the present calculation, then forgotten. Is there any way I can set this up in Maple? If so I would be much obliged to learn how to do it. I have ~100 data pairs (x,f(x)), with no formula. 

Thanks in advance

David. 

I encountered a bug in a combination of simplify and Int. A minimal example is given by the following commands (code attached in file bug.mw):

 

restart:
# simplification bug: first result pulls r out from under the dr integration
integrand := r;
simplify(Int(integrand, phi = 0 .. 2*Pi, r = 0 .. 2));
simplify(Int(integrand, r = 0 .. 2, phi = 0 .. 2*Pi));
simplify(Int(integrand, r = 0 .. 2));
simplify(Int(integrand, phi = 0 .. 2*Pi));

give a wrong result at the first simplify, whereas the others work correctly. It seems that simplify only checks the first integration variable when deciding whether to pull out the factor r from the integral.

 

As Maplesoft does not advertise a dedicated bug report email/site I post it here. If there is one, where can one find it?

Cordially,

  htc

 

 

 

 

I want to animate Fourier Series of Example 1 in the link as follows.

I know that Maple already includes Fourier transform and series package. But I want to write a code from the beginning As if the packages never existed. You can find my try in this link (fourier.mw)

Can you help me for finishing the code?

Thanks.

 

 

We create a lot of Maple documents, and would like an efficient way to share data amoung documents. Some documents rely on the results of other Maple documents.

I have experimented with DocumentTools:-Retrieve. There is an example in the help pages for this that I can run, but for some reason I don't understand, the example uses "L6" as the label for expression to retrieve. In the document referred to, the label is (1).  I can't find L6 is the document, and the example doesnt work with label set to "1". So is there some method to set a label that DocumentTools:-Retrieve uses? If we could create meaningful lables, perhaps that would be a good method for us.

I can see that I can also use the menu option insert>reference and get an expression from another document. I assume that this is a one-time insert. If the value changes on the source document, there is no way to update. There is also nothing shown in the worksheet to show where the expression came from, so unless you add comments, there is no tracability.

Another similar question:

We may have a group of related documents. We would like to have each document be able to export data to a central file (or database?) What is the best way to do this? I could use ExcelTools:-Export  and assign each document a tab or address in the central file. Is there a better way?

Thanks.

Mike

 

 

my main module is getting big. I want to break it to main module, and submodule. But now everything is in the same .mpl file. I'd like to put the sub module in seperate mpl file. I do not know the syntax to do this and how to do it. I looked at the programming guide chapter 8.

Currently in main_module.mpl, lets say I have this

main_module:=module()
 option package;
 local C; 
 local sub_module;
 export main_entry;

 C:=99; #see if this can be "seen" from child module

 sub_module:= module()
    export main_entry;
    main_entry :=proc()
     print("In main_module:-sub_module:-main_entry(), C=",C):
    end proc;
  end module;
 
 main_entry :=proc()
   print("in main_module:-main_entry()"):
   sub_module:-main_entry();
 end proc;
end module;

Now main_module:-main_entry(); gives

                 "in main_module:-main_entry()"
       "In main_module:-sub_module:-main_entry(), C=", 99


I'd like to move the code of the submodule to another .mpl file. So I end up with two files, like this

# main_module.mpl
main_module:=module()
 option package;
 local C; 
 local sub_module;
 export main_entry;

 C:=99; #see if this can be "seen" from child module

 main_entry :=proc()
   print("in main_module:-main_entry()"):
   sub_module:-main_entry();
 end proc;
end module;

And

#sub_module.mpl
sub_module:= module()
    export main_entry;
    main_entry :=proc()
     print("In main_module:-sub_module:-main_entry(), C=",C):
    end proc;
 end module;

But when I do this, I can't call main_module:-main_entry(); since it gives error

Error, (in main_entry) `sub_module` does not evaluate to a module
I do not want to make sub_module a separate package. I want it to remain a sub module for the main module, so it can only be seen by the main module and no one else.

So logically sub_module is a child of main_module, but physically I want to put them in separate files to make it easier to modify.

I use plain text files for everything and use Maple to load the packages and test.

How does one go about doing this? How would this be done for the above example?

 

I tried $include "sub_module.mpl"; but it gives error.

main_module:=module()
 option package;
 local C; 
 local sub_module;
 export main_entry;

 C:=99; #see if this can be "seen" from child module
	
 $include "sub_module.mpl";

 main_entry :=proc()
   print("in main_module:-main_entry()"):
   sub_module:-main_entry();
 end proc;
end module;

Where the file "sub_module.mpl" contains the code for the submodule I want to insert at that location. When I read "main_module.mpl" Maple gives error

read "main_module.mpl";

Error, on line 10, syntax error, unexpected string:
 $include "sub_module.mpl";

This is too advanced for me. I am still learning module and package use in Maple.

thanks

I am attempting  to show that ocean wave B has a larger velocity than ocean wave A, because wave B has a longer wavelength.


 

I considered the displacement of two particels located at the peak of each wave at time = 0.  Differentiating the two displacement functions I determined the velocity function for each particle.  I used a sequence to determine the velocity for each particle over the time interval 1 to 20 seconds (integer).  The following syntax produces the information I need but I would like to format it as 3 columns in 20 rows, how could I edit the following syntax to do that?

restart;
R := {seq([t, evalf(-sin(t)), -.5*sin(.5*t)], t = 1 .. 20)};

This sequence prints 20 lists of t, evalf(-sin(t)), -.5*sin(.5*t)

What do I need to do to print 3 columns in 20 rows?

The first 3 rows would look something like

1 -0.84147 -0.23971
2 -0.9093 -0.42073
3 -0.14112 -0.49874

I am trying to show that two ocean waves of equal amplitude but different wavelenghts have different velocities and the wave with the largest wavelength will have the greatest velocity.    If someone has a suggestion about how to show this using SHM, any advice welcomed.

Les

 

Hi all, does anyone know why i can't export maple as a pdf file? I have tried saving as other type of files which works, but when pressing save as pdf nothing happens. 

 

I've used this guide, https://www.maplesoft.com/support/help/maple/view.aspx?path=worksheet/managing/exportPDF#bkmrk1

Hello all!
Can some one please help me in translating this code, for newton forward and backward interpolation, and get the same output in maple. I am not very good at matlab so that is why I am having problems converting it to maple code.

only forward or backward would be enough I am sure I will figure out the second myself.
https://www.codewithc.com/newtons-interpolation-in-matlab/

What is the best way to check if solve returned one or more solution? Currently I check if the returned sol is of type exprseq, and if so, I put the result in a list. If the sol is not of type exprseq, then I know only one solution is returned. Here is an example

foo:=proc(eq,x)
  local sol;
  sol:=solve(eq,x);
  if whattype(sol)='exprseq' then
     sol:=[sol];
  fi;
  return(sol);
end proc:

And now

Is there better way to do this?

 

Maple does not have a GOTO. I do ?goto and nothing comes up (I thought it did at one point, but it seems to be gone). I also saw 

99052-How-To-Write-Procedures-That-Use-Go-To-In-Maple

GOTO is considered bad, and I agree in general. But there ONE very good use for GOTO which can't be easily replaced, which is having a common exit label. (at one work place sometime ago, this was actually the only recommened use for it in the programming guidelines. and I agree.)

Without this, one ends up with deep if then else if then else if then else., etc....

But having a common exit, where one can do common clean up things is very good. This reduced code duplication and actually makes the logic more clear.

Here is just some silly example to  illustrate

foo:=proc(x)
  if x=10 then
     .....
    close file, print common message
    return(final_result);
  fi;

  if x=12 then
     .....
    close file, print common message
    return(final_result);
  fi;

 etc...

end proc;

With common exit point, one could do

foo:=proc(x)
   if x=10 then 
      .....
     final_result :=...
     goto common_exit;
   fi;

   if x=12 then 
      .....
     final_result :=...
     goto common_exit;
   fi;

common_exit:
   close file; 
   print common message;
   return(final_result);

end proc;

The alternative is to have deep  nested if then else, like this

foo:=proc(x)
    if x=10 then 
       ..... 
       final_result :=...;
    else
         if x=12 then 
            ..... 
            final_result :=...;
         else
             if x= 20 then
                .....
                final_result :=...;
             fi;
         fi;
   fi;

  close file; 
  print common message;
 return(final_result);
end proc;

For complicated logic, I do not think the last case is better than the second one using GOTO.

The second case also eliminates duplicate code as was done in first case. Also first case has multiple return points from the proc, which is not good. As having one common return point is better.

Why was goto removed from Maple? Can one still use it somehow? Where is the documenation for it?

update

 

goto seems to be there. I did not think of trying, since ?goto did not show it. But now I found I could do this and it works

foo:=proc()
  local x;
  x:=10;
  goto(common_exit);
  x:=20;
common_exit:
  print(x);
end proc;

So please Maplesoft., do not remove GOTO.

Hi, I realise it looks a little messy and I apologize for that, but I wanted to exclude the data pairs for which x or y are equal to 1, and the manner in which I have done has always worked for me thus far, so I would like to understand why or how I should produce output like this in the future thanks in advance.

 


 

`𝓃` := proc (X) options operator, arrow; numer(X) end proc:

`𝒹` := proc (X) options operator, arrow; denom(X) end proc:

delta := proc (x, y) options operator, arrow; piecewise(x = y, 1, x <> y, 0) end proc

[seq(seq(piecewise(`or`(`mod`(`&nscr;`(product(1-delta(`mod`(x, ithprime(j)), 0)/ithprime(j), j = 1 .. x)), y) = 0, `and`(`and`(`and`(`mod`(`&dscr;`(product(1-delta(`mod`(y, ithprime(j)), 0)/ithprime(j), j = 1 .. y)), x) = 0, igcd(x, y) = 1), x <> 1), y <> 1)), [x, y], NULL), x = 1 .. 20), y = 1 .. 20)]

[[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1], [3, 2], [5, 2], [7, 2], [9, 2], [10, 2], [11, 2], [13, 2], [15, 2], [17, 2], [19, 2], [20, 2], [7, 3], [13, 3], [14, 3], [19, 3], [5, 4], [13, 4], [15, 4], [17, 4], [11, 5], [7, 6], [13, 6], [19, 6], [15, 8], [17, 8], [19, 9], [11, 10], [13, 12], [17, 16], [19, 18]]

(1)

``

``

``

``

``


 

Download 05062018.mw

Larson 6th edition gives the following solution; 

However, LineInt(VectorField(`<,>`(x, y)), Path(`<,>`(4*t, 3*t), t = 0 .. 1))

returns 25/2 and 

LineInt(VectorField(`<,>`(x, y)), Path(`<,>`(4*t, 3*t), t = 0 .. 1), output = integral)

returns

Int(25*t, t = 0 .. 1)

Why are the solutions different?

lineInt.mw

 


In the following file when p is a fraction other than 1/2 the integral is not evaluated. Please help

INTEGRAL2.mw
 

 

I am stumped at this.

I made a proc A which takes arguments using keywords. When I call A directly, it works. When I pass the argument I want to call A with to another proc B, and then from B call A with that argument, it fails. Maple tells me that it missing arguments. Here is a MWE

restart;
procA := proc({the_equation::`=`:=NULL})
  print("it worked, you passed in ", the_equation);
end proc:

procB :=proc(the_equation)
  print("inside procB, the equation is ", the_equation);
  procA('the_equation'=the_equation); 
end proc:

 

Now, calling procA directly, works

the_equation:= y=3:
procA('the_equation'=the_equation);

              "inside procA, you passed in ", y = 3

But when caling procB, and then have procB call procA, the argument passed in is NULL

procB(the_equation);

                  "inside procB, the equation is ", y = 3
                 "inside procA, you passed in "  <=== WHY NULL?

   

 

 

I must be doing something wrong, I just do not see it.

Update: rebooting the PC fixed this error for me. Now help comes up OK.

original question:

I am on windows 7, home editon, running Maple 2018.

For some reason, now each time I tried to get help, I get the message that it lost connection with server. I closed Maple, started it up again, and same error happens. Movie below.

This also happend from new worksheet also Each time I type ?anything I get the above.

 

Any idea what can cause it? and where I should look for errors?

I did not nothing before this to anything on system. Was just editing some worksheet which opens fine. It is only help that seems to be having hard time.

 

 

First 800 801 802 803 804 805 806 Last Page 802 of 2217