## LSSolve: Can we make one of the variables not to b...

Hello there!
I was wondering if there is a way we can skip one or more variables from LSSolve to be optimized on a specific value?

For exmaple, please see the following file

 >
 (1)
 >
 (2)

Can I skip the value of x and just find a global minimum of the objective functions over the given range of x, not just the specific value?  Its because I need to keep x as a variable.

## Maple procedure doesnt give answer...

Bisection := proc (f, a, b, delta)

local startpoint, endpoint, midpoint; startpoint := a; endpoint := b;

do midpoint := (1/2)*startpoint+(1/2)*endpoint;

if abs(startpoint-endpoint) < delta or abs(f(midpoint)) < delta then

return midpoint

elif f(midpoint) < 0 then endpoint := midpoint

elif 0 < f(midpoint) then startpoint := midpoint

end if end do end proc

I'm trying to do a procedure for bisection method but it doesnt give me answer when  I type

Bisection (x-> x + 0.001 , 1, -1, 0.001 )

it returns Bisection (x-> x + 0.001 , 1, -1, 0.001 )

why this is happening, Is it because the procedure is wrong ? or does not provide answer

What is the difference between a divisor and a factor? Like:

with(numtheory):

X := 89733992396903316277681863138688595394562888838833;

S := map(expand, [op(ifactor(X))]):

And we have the singleton of unity for the output of:

divisors(X/(product(S[j], j = 1 .. nops(S))));

and so on:

seq(divisors(X/(product(S[j], j = 1 .. nops(S)-k))), k = 0 .. 3);

but yet if i try

divisors(X);

my computer freezes.

So yes although my friend is somewhat embarassed to not know the difference and needed me to ask for him what the difference between a divisor and a factor is.

Like is it just the uniqueness? ie a factor is one of the terms in the product of a number's prime factorization, where as any number that divides the number is considered to be a divisor?

like for example i can then go:

seq(min(`minus`(divisors(X/(product(S[j], j = 1 .. nops(S)-k))), {1})), k = 1 .. 10);

X:=X/(131*(139*(151*(163*(173*167)*157)*149)*137)*127)

from the first 10 terms reducing it original number substantially to:

17026820583257598495326242577

and carry this on i dont see why i cant end up with the divisor set that caused my computer to freeze if i just called divisors(X) as I originally did

 >
 >
 (1)
 >
 (2)
 >
 (3)
 >
 >
 (4)
 >

## How do I use a data file in 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.

David.

## Bug in integral simplification?...

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

## Animation of Fourier Series of a function...

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.

## How to best share data between maple worksheets?...

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

## how to have submodule in separate file?...

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

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

## How to print 3 columns and 20 rows...

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

## work space arrangement...

I have training video that shows the visualization window "docked" below the main window.   Can this work space arrangement be done in sim2017 ??

Also I push the anchor button and nothing seems to happen

## Trouble exporting maple as pdf file, Macintosh...

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.

## Newton's backward and forward interpolation: code ...

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/

## best way to check if solve returned one or more th...

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?

## how to have a common exit point in a proc?...

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.

## Output not correct for a piecewise...

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.

 >
 >
 >
 >
 (1)
 >
 >
 >
 >
 >