Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Colleagues, help me please. There is a 256 by 256 matrix in the form of a histogram or heat map.

I want to smooth this histogram and get a surface function.

I used Lowess.

However, there is a problem. the resulting function f (x,y) of the surface is calculated for a long time and it is not possible to use it in NonLinearfit. My NonLinearFit does not give a result. I try to use this function as  A * f(x,y) where A is parameter/

And my idea is to use this function as a template when approximating new poorer matrices. like copulas

What should I do?

I can't understand why this error Error, adding lists of different length show up only when removing a print statement!

Why would a print has anything to do with an error message showing up or not?

some context. I wanted to call map on expression, but wanted to collect the result of operating on each indent in a list as map goes through the expression on term after the other. The expression will be type `+`.

I did not know how to do it inside map. So I create separate proc which map call.

Inside this proc, I use list to append to (this will small list, few terms at most).  To be able to do this, I made the list I want to collect thing into a global variable outside the proc.  Everything was working OK, until I remove a print statement  I had inside the proc for debugging.

I am sure there is a better way to do this all (i.e. collect map output into a list) and I am trying to find better way. But my question is: Why would this error shows up only when I remove a print statement from the last line in the proc?

I also notice when removing the line variable declaration global L now both version work with no error, but get warning Warning, (in f) `L` is implicitly declared local which is why I added declaration global L in first place.

Maple 2021.2 on windows 10

interface(version);

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

restart;

r:=2/(x^2+1)+1/(x^2+1)^2;
L:=[];
f:=proc(Z)
   global L;  
   #do some processing on Z, then collect it into list L
   L:=[ op(L), Z^2];
   #print("op(L) = ",op(L)," Z=",Z);   
end proc:
map(Z->f(Z),r);
L;

2/(x^2+1)+1/(x^2+1)^2

[]

Error, adding lists of different length

[4/(x^2+1)^2, 1/(x^2+1)^4]

restart;

r:=2/(x^2+1)+1/(x^2+1)^2;
L:=[];
f:=proc(Z)
   global L;  
   #do some processing on Z, then collect it into list L
   L:=[ op(L), Z^2];
   print("op(L) = ",op(L)," Z=",Z);   
end proc:
map(Z->f(Z),r);
L;

2/(x^2+1)+1/(x^2+1)^2

[]

"op(L) = ", 4/(x^2+1)^2, " Z=", 2/(x^2+1)

"op(L) = ", 4/(x^2+1)^2, 1/(x^2+1)^4, " Z=", 1/(x^2+1)^2

[4/(x^2+1)^2, 1/(x^2+1)^4]

 

Download why_error.mw

 

Thanks to everyone for the answers and information I did not know that map does process return value from a proc it calls. Good to know.

 

Apparently the Units[Simple] package has not implemented certain features of the original implementation, which (again) leads to very unexpected and wrong results.

This is not acceptable.

Either...

  1. Implement everything
  2. Give a proper warning

a := [0, 1.2, 2, 8, -1.3]

[0, 1.2, 2, 8, -1.3]

(1)

max(a)

8

(2)

Units[Simple]:-max(a)

8

(3)

max[index](a)

4

(4)

Units[Simple]:-max[index](a)

8

(5)

````

Download maxindex.mw

Hello,

I'm havig trouble getting answers to be in decimal form with a certain simple type of equation.

I'm new to Maple so I likely don't understand something basic but when I enter in numbers with decimals as the neumerator like (654321.987*123456.789)/2 I get 4.0390245740 x 10^10. Yet when I enter whole numbers like (654321*123456)/2 I get 40389926688.

I've checked the Number Format settings many times, it's set to "None".

How do I get decimals?

What am I doing wrong?

I'm asking this because I'm sure I'm just missing something.

If I solve a DE with numerics, i.e., dsolve(...,numeric), I get a procedure, say h. I want to answer: if I have a point a that I know, what are the root(s) of h(x) - h(a) = 1? In other words, solve for x.

I thought this would just involve something like fsolve or solve/evalf, or perhaps a root finding package, but I can't figure it out. What I want to avoid is having to write a procedure to hone in on the root myself, since my code is already quite slow.

Any help would be greatly appreciated.

EDIT 1: Here is my MWE (or, what should work in my mind but doesn't). The ODE isn't important, it's just an easy example.

restart;

ode := diff(f(x),x) = f(x);

initial_condition := f(0)=1;

a := 1;

h := dsolve({ode,initial_condition},numeric);

solution := fsolve(h(x) - rhs(h(a)[2]) = 1);

University of Costa Rica     

Course: SP-1493

Student: Lic. Marcus Vinicio Mora Salas

Instructor: Dr. Erick Castellón Elizondo

 

Assigment 7

Description

   

e2.301

 

Express sin(theta) in terms of

i)   cos(theta), and

ii)  tan(theta), and

iii)  cot(theta);

the latter part is more difficult than the preceding two parts.  Each square root that appears is assumed to include both positive and negative roots; for arbitrary angle theta, the sign of the root is given by the quadrant of the angle.  Test your results with a numerical value of theta. In an analogous manner, each circular trigonometric function is expressible in terms of any other circular trigonometric function, but possible ambiguity of signs of square roots exists.   

eq := [sin(theta)^2 + cos(theta)^2 - 1,

Error, invalid input: convert expects its 2nd argument, form, to be of type name, but received -sin(theta)

sin(theta)

 

Download tareaclase8.mw

In this question I have to do what I said in the title. Really I don't understand the question very well, or at least I don't understand the objetive, because if I use solve I get an error and if I use isolate I only can get sin in terms of cos and even wen I could get all answer, I needed a starting point, it's say an identity to solve the exercise. Therefore, my question is, Maple have some comand to express trigonometric functions in terms of another without introducing identities?

Seems to me informative to see a earth-like surface on a sphere and in particular from the zeta function.
Another simple complex function will do it also.

Note: i saw a  3D picture with a colored sphere , where you can see zeroes and poles on the surface of the sphere
A colored complex function is that hard to make with Maple too?: it are all polar coordinates as complex points in the complex plane. 
The angle is standing for hue and the magnitude is standing for the lightness 

Hi

I am trying to get a family of curves on one graph. Each curve a different colour and labeled

P=2, Q=0 , P=2,Q=1 , etc

mmcdara 's proposal for inspiration?

https://www.mapleprimes.com/questions/233088-How-Do-I-Plot-A-Function-Of-Two-Variables

Family_of_curves_plot.mw

I looked at combinat package but it is too large and could not find what I want.

I'll explain with example to make it easy. Given n=2 I want to generate all possible arrangements of sets of length n where each element can be either +1 or -1. So it will be 2^n=4 possible arrangements

And for n=3 then want to generate all possible sets of length 3 where each element can be either +1 or -1 so it will be  2^n=2^3=8 possible sets

And for n=4 it will be 2^n=16 possible arrangements

And so on. I picked [+1,-1] in the above as an example.   

Is there a command to do this in Maple?  I can ofcourse program it using using loops and if's and so on. But thought there might be a command in Maple package which will generate all these possibles sets. Either as list of lists or Matrix or any other format. 

 

Hello there, 

When I tried to write an expression with the '1d' subscript, I found that it was automatically translated as '1.'. The following worksheet shows an example. Is there any chance to preserve the expression as I intended to see?

restart;

eq3_130:= Psi[fd] = L[ffd]*i[fd]+L[f1d]*i[1d]-L[ad]*i[d];

Psi[fd] = -L[ad]*i[d]+L[f1d]*i[1.]+L[ffd]*i[fd]

(1)

 

Download Q20220121.mw

Our user wondered about using PolynomialIdeals:

1.  If we have n+1 polynomials,  f, g1,...,gn,  how to determine if  f  is in the ideal generated by  g1,...,gn?

2.  If so, how to write  f  as a polynomial combination of   g1,...,gn? 

We suggested that;

The nicest interface to answer the first question is given by the ?PolynomialIdeals,Operators page: you can write

with(PolynomialIdeals):
with(Operators):
J := <g1, g2, ..., gn>;
f in J; # true or false

To answer the second question, you need to use the lower level  package (which underlies the  package). This will also answer the first question for you. In particular the  command. You can write:

(Edit Feb 1, 2022 - use  instead of 

with(Groebner):
G := [g1, g2, ..., gn];
ord := tdeg(x,y,z); # replace x, y, z with the appropriate variables; you can also use other variable orders -- see ?Groebner,MonomialOrders

b := Basis(G, ord);
n := NormalForm(f, b, ord, 'Q');
# if n = 0 then f is in the ideal; Q is the list of coefficients:
f - add(Q[i] * b[i], i = 1 .. numelems(b)); # this will be equal to n.

Really , the complex plotting possibilities in Maple are difficult to decipher. 

I tried something, but  in general the visualizing for me is not that easy

Now i must look at the complexplot where i got a circle for  the complexplot(sin(x + I), x = -Pi .. Pi) example ?

Hello,

     Can you enter debug in a worksheet vs a proc?   

    I have a for loop that is crashing in the middle with a bad calculated number to provide to a thermoprops function.   Is there a way to single step through a for loop (1500 iterations) to see which line is getting tripped up?  I can not post the worksheet as it's private development.   The question is generic to any "for loop".

   I have also tried "porting" into a code edit region, but still can not enter the debugger mode.   Is proper debugger only available if I turn the "for loop" into a proc?   If yes, what is the availability of packages called right after restart for the worksheet for a proc, or do all the pre-calcs developed in the worksheet and the packages to be variables fed into the proc or packages re-declared insde a new proc ???

  Sorry if this is a trival question.

Thanks in advance,
Bill

I solve numerically a DAE system whose independent variable is named t and the dependent variables are d[1](t), ..., d[n](t).
I would like to to 2D or 3D plots of the solutions and color the resulting curve using a function f(...) of the remaining dependent variables.

Here is a simple example.

restart

with(plots):

0

(1)

sys := {
   diff(x(t), t) = v(t)
  ,diff(v(t), t) = cos(t)
  ,x(0) = -1
  ,v(0) = 0

  ,px(t) = piecewise(x(t) >=0, 1, -1)
  ,pv(t) = piecewise(v(t) >=0, 1, -1)
}:

sol := dsolve(sys, numeric):

 

odeplot(sol, [t, x(t), v(t)], t=0..4*Pi)
 

 

# I would like to color this space curve depending on the signs of x(t) and y(t)
#
# for instance, f being a "color function"
f := proc(s)
  local a, b:
  if s::numeric then
    a := round(eval(px(t), sol(s))):
    b := round(eval(pv(t), sol(s))):
    return piecewise(a+b = 2, "Green", a = 1, "Red", b = 1, "Blue", "Gold")
  end if:
end proc:

SOL := proc(s)
  if s::numeric then
    eval([t, x(t), v(t)], sol(s))
  end if:
end proc:


# I would like to make something like this to work

plot3d(SOL(s), s=0..4*Pi, colorfunc=f(s)):  #... which generates a void plot


 

# In some sense a continuous version of this

opts := symbol=solidbox, symbolsize=20:
display( seq(pointplot3d({SOL(s)}, opts, color=f(s)), s in [seq](0..6, 0.1)) );

 

 

Download coloring.mw

How can I fix (if possible) the syntax in the command 

plot3d(SOL(s), s=0..4*Pi, colorfunc=f(s)):

???

Thanks in advance

First 220 221 222 223 224 225 226 Last Page 222 of 2097