Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Is there an equivalent of currentdir() which instead of returning current working directory, returns the directory of the file being read. So assume I have an ".mm" or ".mpl" file saved in some location and there is another file with a location fixed relative to this file, but not fixed in absolute location on the computer and not fixed relative with current working directory. One natural thing is to have a line in the first file that takes its current location (not current working location of the user!) and then use the fixed relative path info, and then gives the location of the second file to the user. Using currendir won't help here because current working directory is not necessarily the same as the location of the file you are reading, the first file. One may say the user is reading the first file so he knows already its location, right? Well, if the user is also the writer of the file, sure, not a problem, he can manually edit the lines of the file and put that location inside the file instead of using currentdir etc. However, if the user is not the writer and also does not know how to edit or whatever else reason, then the file should be able to inform Maple of its own location, so that's why something like currentdir() but not for the working directory, instead for currently being read file's directory is helpful. I checked FileTools package quickly and couldn't notice anything like what I want. Anyone have any clue on name of such command if exists or any other trick that does what I want (except expecting the user to do something ^_^ so all from the writer's side please ^_^).

Hi, I want to generate a matrix of variables, say, something like, 

n:=4:

Matrix(n, n, [[a_11, a_12, a_13, a_14], [a_12, a_22, a_23, a_24], [a_13, a_23, a_33, a_34], [a_14, a_24, a_34, a_44]]) :

How can I do it automatically for arbitrary values of n?

How can I convert sinh(x)/cosh(x) to tanh(x) ?

One of the most difficult/nice tasks from my collection of old problems:
Calculate Int(from 0 to 1)Int(from 0 to 1)[1/(1-x*y)]dxdy .

Hi,

I am looking to design a learning sequence on the applications of integral calculus (arc length, area under the curve, solid of revolution). The animation of the solid is not optimal because I want to display the revolution over [1,2] while maintaining a global view of the curve over [-3,3]. Thank you for your insights.

 

S7_Arc_Intégrale_Animation.mw

i try find some part of solution of this kind of pde but i can't get results my openion is maybe this pde is wronge when i defined 

pde.mw

Let eps be a real number greater than zero. Calculate the limit lim(x-->oo)[x^(1-eps)*Integral(from x to x+1) sin(t^2)dt] .

my solution is a little bit long which when i click on pdetest command i wait at least more than a hour but still is runing and i don't get any result and not give me error , which i don't know my result is true or not so How i can find that my pde by this solution it will be zero or not ?

restart

with(PDEtools)

with(LinearAlgebra)

NULL

with(SolveTools)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

(1)

declare(u(x, y, t))

u(x, y, t)*`will now be displayed as`*u

(2)

declare(f(x, y, t))

f(x, y, t)*`will now be displayed as`*f

(3)

pde := diff(u(x, y, t), t)-(diff(diff(u(x, y, t), `$`(x, 4))+5*u(x, y, t)*(diff(u(x, y, t), `$`(x, 2)))+(5/3)*u(x, y, t)^3+5*(diff(u(x, y, t), x, y)), x))-5*u(x, y, t)*(diff(u(x, y, t), y))+5*(int(diff(u(x, y, t), `$`(y, 2)), x))-5*(diff(u(x, y, t), x))*(int(diff(u(x, y, t), y), x))

diff(u(x, y, t), t)-(diff(diff(diff(diff(diff(u(x, y, t), x), x), x), x), x))-5*(diff(u(x, y, t), x))*(diff(diff(u(x, y, t), x), x))-5*u(x, y, t)*(diff(diff(diff(u(x, y, t), x), x), x))-5*u(x, y, t)^2*(diff(u(x, y, t), x))-5*(diff(diff(diff(u(x, y, t), x), x), y))-5*u(x, y, t)*(diff(u(x, y, t), y))+5*(int(diff(diff(u(x, y, t), y), y), x))-5*(diff(u(x, y, t), x))*(int(diff(u(x, y, t), y), x))

(4)

pde_nonlinear, pde_linear := selectremove(proc (term) options operator, arrow; has((eval(term, u(x, y, t) = a*u(x, y, t)))/a, a) end proc, pde)

-5*(diff(u(x, y, t), x))*(diff(diff(u(x, y, t), x), x))-5*u(x, y, t)*(diff(diff(diff(u(x, y, t), x), x), x))-5*u(x, y, t)^2*(diff(u(x, y, t), x))-5*u(x, y, t)*(diff(u(x, y, t), y))-5*(diff(u(x, y, t), x))*(int(diff(u(x, y, t), y), x)), diff(u(x, y, t), t)-(diff(diff(diff(diff(diff(u(x, y, t), x), x), x), x), x))-5*(diff(diff(diff(u(x, y, t), x), x), y))+5*(int(diff(diff(u(x, y, t), y), y), x))

(5)

thetai := t*w[i]+y*p[i]+x

t*w[i]+y*p[i]+x

(6)

eqw := w[i] = -5*p[i]^2

w[i] = -5*p[i]^2

(7)

Bij := proc (i, j) options operator, arrow; (-6*p[i]-6*p[j])/(p[i]-p[j])^2 end proc

proc (i, j) options operator, arrow; (-6*p[i]-6*p[j])/(p[i]-p[j])^2 end proc

(8)

NULL

theta1 := normal(eval(eval(thetai, eqw), i = 1)); theta2 := normal(eval(eval(thetai, eqw), i = 2))

-5*t*p[1]^2+y*p[1]+x

 

-5*t*p[2]^2+y*p[2]+x

(9)

eqf := f(x, y, t) = (-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[2]^2+y*p[2]+x)-(6*(p[1]+p[2]))/(p[1]-p[2])^2

f(x, y, t) = (-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[2]^2+y*p[2]+x)-6*(p[1]+p[2])/(p[1]-p[2])^2

(10)

eq17 := u(x, y, t) = 6*(diff(diff(f(x, y, t), x), x))/f(x, y, t)-6*(diff(f(x, y, t), x))^2/f(x, y, t)^2

u(x, y, t) = 6*(diff(diff(f(x, y, t), x), x))/f(x, y, t)-6*(diff(f(x, y, t), x))^2/f(x, y, t)^2

(11)

eqt := eval(eq17, eqf)

u(x, y, t) = 12/((-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[2]^2+y*p[2]+x)-6*(p[1]+p[2])/(p[1]-p[2])^2)-6*(-5*t*p[1]^2-5*t*p[2]^2+y*p[1]+y*p[2]+2*x)^2/((-5*t*p[1]^2+y*p[1]+x)*(-5*t*p[2]^2+y*p[2]+x)-6*(p[1]+p[2])/(p[1]-p[2])^2)^2

(12)

``

pdetest(eqt, pde)

NULL

Download test.mw

Hi,

I'm looking to animate the Riemann sum only on the interval [0,2], while keeping a global view of the curve (G). I tried the background option, but without success. Any ideas? Thanks!

S7_Riemann_Animation_Aire.mw

Hi. How to plot the 2d output like this? I don't know how to declare "a" and "b" random constant?
The pair of equations x = a and y = b graphically represents lines which  are, a. parallel , b. intersecting at (b, a), c. coincident, d.  intersecting at (a, b)

a := (rand(3 .. 4))(); b := (rand(0 .. 3))(); plot(x = a); plot(y = b)

3

 

2

 

Error, (in plot) unexpected option: x = 3

 

Error, (in plot) unexpected option: y = 2

 
 

``

Download x=a_y=b_plot.mw

In a procedure what is the way to only allow specific values in a variable?

ie/

change:=proc(a::integer, b={10,20,30})#only values 10, 20 and 30 allowed for variable b
  a*b;
end proc:

Trying to find a formula such that when n is negative the value is +1 and when n is positive the value is 0, without using an if statement. 

The square grid is given in the Euclidean plane. All grid points therefore have integer coordinates. Investigate whether there are three points in this grid plane that form an equilateral triangle.

Consider the following:

MyTableElement1 := proc(L::list(nonnegint))
  ## L will have only two elements
  local M, x, y;
  M:=L;
  x:=convert(M[1],string);
  y:=convert(M[2],string);

  return cat("\\begin{tabular}{c} ",x," \\\\ ",y," \\end{tabular}")

end;

MyTableElement1([2,3]);

will output

"\begin{tabular}{c} 2 \\ 3 \end{tabular}"

as desired. However, if one inserts an \hline into the table,

MyTableElement2 := proc(L::list(nonnegint))
  ## L will have only two elements
  local M, x, y;
  M:=L;
  x:=convert(M[1],string);
  y:=convert(M[2],string);

  return cat("\\begin{tabular}{c} ",x," \\\\ \\hline ",y," \\end{tabular}")

end;

will output

"\begin{tabular}{c} 2 \\ \hline 3 \end{tabular}"

again as desired. However, if I copy and paste this int a document, I get

"\begin{tabular}{c} 2 \\ hline 3 \end{tabular}".

Note that \hline is now just hline. Putting "\\\\" in front of the hline outputs

"\begin{tabular}{c} 2 \\ \\hline 3 \end{tabular}",

but this does not compile properly. How can I get a proper \hline command to appear in the table? Thank uou for your consideration.

After a long chat with ChatGPT I finally received a fully working code for a proc for a generalized Woodbury Identity for the inversion of the sum of two or more positive definite matrices.
I was inspired by a family member who is a trained professional programmer, who told me that in his professional work he uses ChatGTP for an initial draft of his program.  
I did find out that ChatGTP makes errors: from simple ones like writing 'Simplify' instead of 'simplify' to serious conceptual errors, for example in recursive loops. However, ChatGTP seems to 'understand' the error after given specific feedback. Although, this does not mean that the next proposal does not contain the same logical error. But after a long chat I received a nice proc that seems to work. 
My second surprise was that Gemini suggested a formula for the generalized Woodbury lemma that was unknown to me, and I was unable to find on Scholar Google or https://math.stackexchange.com. Based on a special case of that formula, I was able to write the second proc myself. 
In conclusion, to start working it can be helpful to collaborate with AI friend, a little patience may help, AI may not be astute as someone on Mapleprimes wrote, but neither am I. I am now retired, and it is fun to play with Maple and AI. 
By the way, the search term Woodbury did not give a single hit on Mapleprimes.With_a_little_help_from_my_friends.mw
kind regards,Harry 

 

First 13 14 15 16 17 18 19 Last Page 15 of 2198