Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Recently, ChatGpt has gained a lot of attention and there are mixed reviews about it. Some people think highly of its capabilities, while others are more critical. Regardless, it has been an interesting  topic on assistant programming.

I'm going to give two examples to illustrate what's interesting and what's lacking.

First, I want ChatGpt to write a Maple code for the enumeration of all prime numbers up to 100. Then it writes:

primes:= proc(n)
   local i, j, primes;
   primes:= [2];
   for i from 3 to n do
      for j from 2 to i-1 do
         if i mod j = 0 then break;
      end do;
      if j = i then primes:= [op(primes), i]; end if;
   end do;
   return primes;
end proc;

primes(100);

I copy and paste this code, maple shows an error: Error, reserved word `do` unexpected

I report the error to it:

this code cannot run since "Error, reserved word `do` unexpected"

Then it gives: I apologize for the error in the previous code. Here is a corrected version of the code that can be run in Maple:

primes:= proc(n)
   local i, j, primesList;
   primesList:= [2];
   for i from 3 to n do
      for j from 2 to i-1 do
         if i mod j = 0 then 
            break;
         end if;
      end do;
      if j = i then 
         primesList:= [op(primesList), i]; 
      end if;
   end do;
   return primesList;
end proc;

primes(100);

Ok, It's tediously written code, but at least it's correct. 

Furthermore, I ask:

Is there a more concise approach that utilizes maple's built-in functions.

It tells me:

Yes, there is a more concise approach that utilizes Maple's built-in functions. Here's an example:

primes := [seq(i, i=2..100)]; primes := [op(select(isprime, primes))];

The seq function generates a list of numbers from 2 to 100. The select function filters out all non-prime numbers using the isprime function, which tests the primality of a number. The result is stored in the primes array.

Ok, this answer meets my expectations.

 

Another example is the generation of all 6th order non-isomorphic graphs, which pops up as:

# Load the GraphTheory package
with(GraphTheory):

# Generate a list of all non-isomorphic graphs with 6 vertices
graphs := NonIsomorphicGraphs(6):

# Print the list of non-isomorphic graphs
print(graphs);

But NonIsomorphicGraphs(6) as we know is the number  of non-isomorphic graphs but  not graphs  themselves.

 

So I say:

in the above codes, NonIsomorphicGraphs need the options output = graphs, outputform = graph

ChatGpt gives :

Here is a revised version of the code that takes into account the options output = graphs and outputform = graph:

 

# Load the GraphTheory package
with(GraphTheory):

# Generate a list of all non-isomorphic graphs with 6 vertices
graphsList := NonIsomorphicGraphs(6, output = graphs, outputform = graph):

# Print the number of non-isomorphic graphs
print("Number of non-isomorphic graphs: ", nops(graphsList));

# Print each non-isomorphic graph in the list
for i in 1 to nops(graphsList) do
  print("Graph ", i, ": ", graphsList[i]);
end do

It still has syntax errors. I made some artificial adjustments.

# Load the GraphTheory package
with(GraphTheory):

# Generate a list of all non-isomorphic graphs with 6 vertices
graphsList := [NonIsomorphicGraphs(6, output = graphs, outputform = graph)]:

# Print the number of non-isomorphic graphs
print("Number of non-isomorphic graphs: ", nops(graphsList));

# Print each non-isomorphic graph in the list
for i from 1 to nops(graphsList) do
  print("Graph ", i, ": ", graphsList[i]);
end do;

I pulled a wry face when  it builds a lot of codes  that do not exist in Maple.. Here's a little tidbit of my conversation with it.

This software still needs more work. I'm not sure how far it can go, but maybe programming becomes easier. Maybe more interesting examples will be found.

Hello everyone ! 

I am completely new to using math solving applications like maple.

I was introduced to it in my university course and since then I found it very helpful in solving 2nd degree differential equations and integrals.

However, i don't have any intuition for programming, so i found the commands of maple very confusing.

The last couple of weeks, I have been completely destroyed by a problem I've recently encountered...

I was given a bunch of (x,y) coordinates of a function and i was told that the function in question is a polynomial of a 3rd degree.

So my question is, can maple help me in solving this type of problems or no ?!?!?!

And if yes, can someone give me a general direction in which i have to go ?

Also, I was told that this problem can be solved in Excel ?

Thank you all in adavce ! 

Looking for the solution of this a non linear system y = x^2 + 2*x - 3 ,  y = x^3 + 3*x^2 - 4*x - 8 (The system has 3 real solutions A = (-3.35, 1.51)    B = (-0.72, -3.92)  C = (2.07, 5.42) ).

i have tried to solve it as follows:

eq1 := x^2 + 2*x - 3

eq2 := x^3 + 3*x^2 - 4*x - 8

fsolve({eq1 = eq2})

I get 

   {x = -3.346462190}, {x = -0.7222456338}, {x = 2.068707823}

That is what i expected.
 

But if i try to use solve and then evalf i find three complex solutions.

solution := solve({eq1 = eq2}, explicit)

evalf(%);
      
  { x = 2.068707824 - 4x10^(-10)   I },     { x = -3.346462190 - 7.660254040 x10^(-10)    I },   { x = -0.722245634 + 9.660254040x10^(-10)    I }
    

Why ? I don't understand.

Moreover, solving the equations as follows:
sys1 := y = x^2 + 2*x - 3;
sys2 := y = x^3 + 3*x^2 - 4*x - 8;

fsolve({sys1, sys2}, {x, y})

yeld just one solution:

               {x = 2.068707823, y = 5.416967705}

Someone can explain me this behaviour ?

Dear Users,

I hope everyone here is fine. I want to extract dat file from the attached contour plot file. Please help me to resolve this issue. Many thanks in advance

Dat_file.mw

restart:
PDEtools[declare](f(x), prime = x):
PDEtools[declare](Theta(x), prime = x):
PDEtools[declare](Phi(x), prime = x):
N := 4; M := .1; Kp := .1; Gr := 0.1e-1; Gc := 0.1e-1; Pr := 1; S := 0.1e-1; Sc := .78; Kc := 0.1e-1; La := 1
f (x):=  sum((p^(i))*f [i] (x), i = 0 .. N) ;
Theta(x):=  sum((p^(i))*Theta[i] (x), i = 0 .. N) ;
Phi(x):= sum((p^(i))*Phi [i] (x), i = 0 .. N);
HPMEq1 := (1-p)*(diff(f(x), x, x, x))+p*(diff(f(x), x, x, x)+(1/2)*(diff(f(x), x, x))*f(x)-(M^2+Kp)*(diff(f(x), x)-La)+Gr*Theta(x)+Gc*Phi(x))
HPMEq2 := (1-p)*(diff(Theta(x), x, x))/Pr+p*((diff(Theta(x), x, x))/Pr+(1/2)*(diff(Theta(x), x))*f(x)+S*Theta(x))
HPMEq3 := (1-p)*(diff(Phi(x), x, x))/Sc+p*((diff(Phi(x), x, x))/Sc+(1/2)*(diff(Phi(x), x))*f(x)+Kc*Phi(x))
for i from 0 to N do equ[1][i] := coeff(HPMEq1, p, i) = 0 end do
for i from 0 to N do equ[1][i] := coeff(HPMEq2, p, i) = 0 end do
for i from 0 to N do equ[1][i] := coeff(HPMEq3, p, i) = 0 end do
cond[1][0] := f[0](0) = 0, (D(f[0]))(0) = 0, Theta[0](0) = 1, Phi[0](0) = 1, Theta[0](5) = 0, Phi[0](5) = 0, (D(f[0]))(5) = 1; for j to N do cond[1][j] := f[j](0) = 0, (D(f[j]))(0) = 0, Theta[j](0) = 0, Phi[j](0) = 0, Theta[j](5) = 0, Phi[j](5) = 0, (D(f[j]))(5) = 0 end do
for i from 0 to N do pdsolve({cond[1][i], equ[1][i]}, f[i](x)); f[i](x) := rhs(%) end do
f(x) := evalf(simplify(sum(f[n](x), n = 0 .. N))); convert(f(x), 'rational'); subs(x = 1, diff(f(x), x))

Please rectify the error
Thank you

Error, (in PD/PD) too many levels of recursion

Maple Input:
restart; with(RealDomain); log[2](x^2 - 6*x) = 3 + log[2](1 - x); Maple returns as solution
ln\x - 6 x/ ln(1 - x) ------------ = 3 + --------- ln(2) ln(2) "(->)" [[x = 2], [x = -4]]
Is the solution x = 2 correct?

Substituting x=2 into the original Function Maple returns correct: log[2](2^2 - 6*2);

undefined and log[2](1 - 2).; undefined. So x =2 should not be a solution of this function.

Hi,

I am trying to automatically combine plots that I created with an index: ex. IP[i] := plot(...

I can combine them manually, but the maximum value of i can be almost any number greater than 1, and I don’t want to edit things all the time. i can also be very big. I have tried several random ways of embedding the index, but I’ve had no success.

Any ideas? Thanks.

Jno.

Please Help!  The flow gets me like this,Where should i fix this problem.The flow changes for me fluctuate through the series range.What to do to get upflow in f(eta) and downflow in theta(eta)

 MVP.mw

I want to import a numeric 2800*1 matrix from matlab to maple by following command, but faced error as bellow:

X := ImportMatrix("E:/.../Omega.mat", source = MATLAB);
 ImportMatrix:-ModuleApply called with arguments: E:/.../Omega.mat, datatype = auto, delimiter = (), format = (), mode = (), output = all, ragged = true, skiplines = 0, source = MATLAB, sourceid = all, transpose = false
 #(ImportMatrix:-ModuleApply,36): error
Error, (in ImportMatrix) Array index out of range
 locals defined as: file = E:/.../Omega.mat, src = Matlab, ext = ext, res = res, x = x, isv7 = isv7, del = false

Where is the problem?

How to import?

This is my current code:

with~([NumberTheory, DocumentTools]):
tb := Tabulate([seq]([galois](CyclotomicPolynomial(i, x),x), i = 1 .. 10)):

I hope to export it into SVG file, but this code will report a error information:

Export("aatest.svg", tb)

# this is an example:

with(plots);

A := [[[6, 13], [6, 7], [5, 7], [5, 5], [7, 5], [7, 4], [4, 4], [4, 13]], [[13, 13], [13, 20], [20, 20], [20, 23], [22, 23], [22, 22], [23, 22], [23, 16], [16, 16], [16, 9], [9, 9], [9, 6], [7, 6], [7, 7], [6, 7], [6, 13]], [[13, 23], [20, 23], [20, 20], [13, 20]], [[13, 24], [20, 24], [20, 23], [13, 23]], [[22, 24], [22, 23], [20, 23], [20, 24]], [[24, 24], [24, 22], [23, 22], [23, 23], [22, 23], [22, 24]], [[22, 22], [22, 23], [23, 23], [23, 22]], [[22, 25], [25, 25], [25, 16], [23, 16], [23, 22], [24, 22], [24, 24], [22, 24]], [[25, 6], [16, 6], [16, 9], [23, 9], [23, 16], [25, 16]], [[9, 6], [9, 9], [16, 9], [16, 6]], [[6, 6], [6, 7], [7, 7], [7, 6]], [[6, 20], [13, 20], [13, 13], [6, 13]], [[20, 28], [28, 28], [28, 16], [25, 16], [25, 25], [22, 25], [22, 24], [20, 24]], [[16, 5], [9, 5], [9, 6], [16, 6]], [[7, 5], [7, 6], [9, 6], [9, 5]], [[5, 5], [5, 7], [6, 7], [6, 6], [7, 6], [7, 5]], [[4, 23], [13, 23], [13, 20], [6, 20], [6, 13], [4, 13]], [[23, 9], [16, 9], [16, 16], [23, 16]], [[9, 1], [1, 1], [1, 13], [4, 13], [4, 4], [7, 4], [7, 5], [9, 5]]];
NULL;

arte := seq(polygonplot([A[i]], color = ColorTools:-Color([rand()/10^12, rand()/10^12, rand()/10^12]), axes = none, style = polygon, view = [1 .. max(A[]), 1 .. max(A[][])]), i = 1 .. nops(A));
display(arte);

Dear all 
For n geater or equal 2, I would like to solve to find an integrer n that such satisfy an inequality. 

I would like to see how large does n have to be for  the following ineqlaity satisfied. 
But, unfortunattely Maple return 
Warning, solutions may have been lost

restart;
epsilon:=0.001;
solve(10^n /factorial(n) <= epsilon, n);

thank you 

printf("%", [[]]);

Yeah, it is incompatible with the Maple syntax. But I don't know why this command actually causes a serious logic error here. Actually, this seems fairly trifling in my view. Can you produce it again? 

restart

printf("%", [[]]);

NULL

Download printfIssue.mws

First 115 116 117 118 119 120 121 Last Page 117 of 2097