MaplePrimes Questions

How can i sove further to get exact value

 

I am new to maple. I am trying to plot3d  the following differential eq:

eq1 := diff(c(x, t), t) - 1.5*diff(c(x, t), x, x) + 0.05/(x + 0.001) = 0

With these initial conditions:

ics := c(x, 0) = 0, c(0, t) = 10, D[1](c)(20, t) = 0

And then I slove and plot this:

sol := rhs(dsolve({eq1, ics}, c(x, t)))

plot3d(sol, x = 0 .. 20, t = 0 .. 100, labels = [x, t, c])

But I only get an empty coordinate system with no plot. I don't have this problem when in the last line of the eq, I have 0.05*x instead of 0.05/(x + 0.001).

Could someone help me with what might be the problem?

 

 

 

Hi,

How to change Maple symbol " I " to mathematical symbol " i " ?

Thanks

How to do this in Maple please?

Iterate an array and select x items so that the sum of the selected items equal or are above a value.

Eg. 10 real numbers in an array, random for example between 0..10 and select some of them so the value is equal or greater than y, e.g 5.2 , as close as possible to optimize the selection.

restart; with(plots):with(LinearAlgebra):unprotect(O); alias(conj = conjugate); conj z = lambda*v+a; La droite D est représentée par son équation complexe Appelons H l'affixe h le pied de la perpendicukaire abaissée de O sur (D) Les vecteurs OH et V sont orthogonaux donc z = lambda v + a h*conj(v)+conj(h)*v = 0; Le point H appartient à la droite (D) donc : h = lambda*v+a; conj(h) = conj(a)+lambda*conj(v); (lambda*v+a)*conj(v)+(conj(a)+lambda*conj(v))*v = 0; solve(%, lambda); h := simplify(subs(lambda = %, lambda*v+a)); a := 3-I*4; v := -2/3+4*I; evalc(h); H := [Re(h), Im(h)]; Représentation graphique d'un cas particulier : f := proc (x) options operator, arrow; -3*x+5 end proc: a := 3: A := [a, f(a)]:O:=[0,0]: zo := [8/3+I*f(8/3)]; ze := [2+I^(eval(diff(f(x), x), x = 2))]; Zo := [8/3, f(8/3)]; Ze := [2, f(2)]; ex := -3*x+5; V := `

I've never noticed this before, becuase I do not like to with()  packages, but like to add the name of the package at each command and alwsys try to use explicit commands.

Compare this first example, which does not work, since the "." in the codeis the global "dot" command ?dot

restart;
VC:=VectorCalculus:
f:=y*sin(x)+y^2;
VC:-Nabla . VC:-Nabla(f,[x,y])

So the dot above is the one used for normal dot product, which is visible without loading any package as in: <1,2>.<3,4> gives 11

Now when I next loaded the VectorCalculus explicitly, but kept the same code the same, i.e. using the same ".", now it worked

restart;
with(VectorCalculus);
VC:=VectorCalculus:  #do not need this now, but to keep the code the same
f:=y*sin(x)+y^2;
VC:-Nabla . VC:-Nabla(f,[x,y])

It worked because Maple now used VectorCalculus:-`.`  ,Even though I did not tell it to do this, it searched the package since it is loaded) and now decided to use VectorCalculus:-`.` instead of the global `.` dot defined before loading this package.

But how did Maple know which dot to use? 

Did it say to itself, the dot in the middile must be VectorCalculus:-`.` and not the global `.` due to the type of the operands around the dot, it automatically found the correct match? 

So imagine if one has loaded more packages, and some might have its own `.` operator that takes the same operands, does Maple search them all to find the correct dot to use based on type of operands to bind it to? and how in this case it knows which to use, if there is more than one match among all loaded packages? I can see this causing confusion, becuase one is never sure in this case which operator was used. I do not know if Maple issues a warning in this case or not.

I do not use input 2D math in document mode. But was trying it now to see if I can enter this to check my hand solution

In worksheet, this is what I do

restart;
VC:=VectorCalculus:
f:=y*sin(x)+y^2;
VC:-DotProduct(VC:-Del,VC:-Gradient(f,[x,y]))

But I do not know how to enter   if possible, in document mode 2D math. THis is what I tried. Created document mode. Picked the DEL operator from the left side common symbols window. But I do not know how to do the rest.

Clearly I am doing something silly. This is why I prefer plain Maple code, becuase I can see what I am typing :)

But was wondering, how to do the above in docuemnt mode + 2D math? To make it look close to how it shows in the book. Does one need special palette for this?

 

 

Hello

In Section 14.5 - External Calling ..., page 489, the authors gave an example on how to use the command line in Unix to call maple with arguments. I followed the example but added a mpl-file to see if the arguments were sent to it.  

Example (Linux):

/opt/maple2020/bin/maple -c n:=4 -c 'path:="/home/eduardo/examples";' example.mpl > output.txt &

Maple sends out the following error message: "Error, incorrect syntax in parse: '/' unexpected (near 7th character of parsed string)".

The msg is clear where the error is but I could not figure out what to do. The single quotes were supposed to take care of that, weren't they?  

Many thanks.

Ed

Edit: I have added the double-quotes.   The problem still persists.  

I wanted to overwrite an existing variable of type table by the one returned from a call to a proc().

But it does not work, unless eval() is called on the returned result from the proc()

But if the variable that recieves the return value from the proc() was not already a table type, then it works without using eval. Why is that? 

Here is an example

restart;
foo:=proc(A::table)
  A["c"]:=3; #add new field
  return A;
end proc;

A:=table():
A["a"]:=1:
A["b"]:=2:
B:=foo(A):
whattype(B);
print(B)

           table(["a" = 1, "c" = 3, "b" = 2])

In the above, it worked. is table now, and assigned the updated table from the proc.  But 

A:=table():
A["a"]:=1:
A["b"]:=2:
A:=foo(A): #without eval, it does not work.
whattype(A);
print(A)

             symbol
               A

I expected A to be overwritten, just like B was. To fix this, I have to change A:=foo(A): by A:=eval(foo(A)):

But why eval was not needed in the first example, and was needed for the second example?

btw, the same thing happens with Record(), not just table()

just like to understand the reasoning behind this. I expected both cases to work the same way. But it works different if the variable happend to be unassigned (like B above).

Hello all,

I was hoping to get some general tips for tackling numeric integrals. As someone with little experience in the subject, I find myself overwhelemed by the many different integration methods. 

Experts, what are the first steps you take when trying to find a numeric solution to an integral? How might you zero-in on a particular integration method? What about tweaking error parametrs, etc.? Is there a general framework for approaching these problems, or is it all guesswork?

Thanks!

Hi everyone:

How can I convert the following phrase (eq) into the phrase in the photo?

eq:= -w*z^2/(2*E*MI*alpha^2)+w*H*sinh(alpha*H)*cosh(alpha*z)/(alpha^3*E*MI*cosh(alpha*H))-w*H*sinh(alpha*H)/(alpha^3*E*MI*cosh(alpha*H))+w*cosh(alpha*z)/(alpha^4*E*MI*cosh(alpha*H))-w/(alpha^4*E*MI*cosh(alpha*H))+w*H*z/(E*MI*alpha^2)-w*H*sinh(alpha*z)/(E*MI*alpha^3):

the phrase in the photo:

tnx...

I want to write a proc, say f, that takes an single argument Z, as in
f := proc(Z::?) ...
where the only acceptable Z values are pairs [x,y], where x and y are selected from the set {a,b,c,d}. The entries a,b,c,d of that set are prescribed symbolic constants. 

Thus, the following are legal calls to f:
f([a,a]), f([a,b]), f([d,c])
but these are illegal:
f([a]), f([a,b,c]), f([a,x])

I don't know what to put for the "::?" in the proc's definition in order to enforce those constraints.  Any ideas?

Extra: In fact, I would prefer to ban the f([a,a]) option as well (no repeated symbols) but that's of secondary importance since it is easy to inspect and handle that within the proc's body.

Hello. I am a student who has been given access to Maple through my school. Normally, the program works just fine and without any problems. But today I tried to do a linear regression which did not work as it used to do. Though, the exponential (ExpReg) and the potential (PowReg) regression still works normally.

Here is a picture of what the error looks like:

As shown on the picture, I use a special extension called the 'Gym-pakke' which we use in my high school. As far as I know, this extension is created for Danish high schools?

Another thing that I had like to emphasize, is that the linear regression still works whenever I copy-paste the command from a previous document - a document from before the issue began. But I am tired of having to copy-paste every time I have to do a linear regression.

Please help me solve this problem, thanks! :)

Hi there!

I am trying to save the coefficients of a polynomial in a list to work with them in a rather complicated procedure. It is about representing a polynomial via a set of orthogonal polynomials phi_n which change depending on the input. For example, phi_s*phi_0=1*phi_s, so the coefficient of phi_s is 1 and the rest is 0. I save this as a[s][0][s]:=1. In this procedure, however, the coefficient of phi_{s+1} or phi_{s+10} might come up, and I have not declared them as 0, so the procedure stops whenever something like a[s][0][s+2] or a[s][0][s+10] appears. I could work with polynomials I guess, saving x^s for the result of

phi_s*phi_0 and working with coeff (x^s,n), which would indeed return 0 if n is not s instead of aborting the entire procedure, however, to me, it's not quite beautiful coding to encrypt the needed coefficients in another polynomial instead of just extracting them into a list. Is there a way to tell Maple that anything unspecified, a[s][j][x], shall just be 0?
 
Thank you in advance, Daniel
 
 

I did two attempts with different ideas
 

 

restart;

Task (a) A list of numbers in Maple :

L:=[1,2,3,4,5];

[1, 2, 3, 4, 5]

(1)

 

In general summing up numbers sum(a, i = k .. n) = sum(a_i, i = 1 .. 5) and sum(a_i, i = 1 .. 5) = a1+a2+a3+a4+a5

underscript? ..i like to write a with underscore n : how to that

#S:={seq(L[i],i=1..5)};

#L:= [seq(L[i],i=1..5)];

For summing up numbers in a list of L i can use a ...

Sumlist := proc (L,N):  

Sumlist:=proc(L,N)

   a:=1;

   for i from 1 to N do

      a:=seq(L[i],i=1..5);

   end do;

end proc:

 

Warning, (in Sumlist) `a` is implicitly declared local

 

Warning, (in Sumlist) `i` is implicitly declared local

 

L:=[1,2,3,4,5];

[1, 2, 3, 4, 5]

(2)

N:=3;

3

(3)

Sumlist(L,N);

1, 2, 3, 4, 5

(4)

 

And now to sum the number sequenze  from the procedure?

 

restart;

Sumlist:=proc(L,N)

   a:=1;

   for i from 1 to N do

      a:=seq(L[i],i=1..5);
      #sum(a, i=1..5); # for this probably a second do loop nested ?

   end do;

end proc:

 

Warning, (in Sumlist) `a` is implicitly declared local

 

Warning, (in Sumlist) `i` is implicitly declared local

 

L:=[1,2,3,4,5];

[1, 2, 3, 4, 5]

(5)

N:=3;

3

(6)

Sumlist(L,N);

1, 2, 3, 4, 5

(7)

 

 

 

 

========================================================================

Also possible by? : a1 = 1, a2=a1+1, a3=a2+1, etc

restart;

 

Sumlist:=proc(L,N)

   a:=1;

   for i from 1 to N do

      a:=L[i]+1;

   end do;

end proc:

 

Warning, (in Sumlist) `a` is implicitly declared local

 

Warning, (in Sumlist) `i` is implicitly declared local

 

L:=[1,2,3,4,5];

[1, 2, 3, 4, 5]

(8)

N:=2;

2

(9)

Sumlist(L,N);

3

(10)

L[1];

1

(11)

 

Try some things out, but summing up list ?


 

Download betounes_ex_set_2_task_5.mw

 

First 428 429 430 431 432 433 434 Last Page 430 of 2308