nm

2776 Reputation

17 Badges

7 years, 151 days

MaplePrimes Activity


These are answers submitted by nm

Removed as not needed.

L1:=[1,2,5,6,9];
andmap( x->x>0, L1 );

         true

L2:=[0,-2,5,6,9]:
andmap( x->x>0, L2 );

       false

You can't really expect to translate such code to Maple. Using MmaTranslator or any other tool.

MmaTranslator is meant to translate mathematics from Mathematica syntax to Maple syntax. It also  supports few core Mathematica commands such as Table, If, Do, etc...

So only common mathematical functions and basic constructs that have Maple equivalent can be translated. 

But Manipulate can't be translated to Maple. What do expect Maple to translate Manipulate to?  

Let try it. Here is a full Manipulate program

with(MmaTranslator)
FromMma(`Manipulate[Plot[Sin[c x],{x,-1,1}], {{c,1,"c"},0,2,.1}]`)

Maple returns

Manipulate(plot(sin(c*x), x = -1 .. 1), [[c, 1, "c"], 0, 2, 0.1])

Good luck running the above in Maple.

There are thousands of Mathematica commands that can't be expected to be translated. For example

FromMma(`Graphics3D[Sphere[{0, 0, 0}]]`)

Will just give

Graphics3D(Sphere([0, 0, 0]))

You can't run the above in Maple.

You could translated a Table command for example

FromMma(`Table[i,{10}]`)

Which gives

[seq(i, i = 1 .. 10)]

To translate all of Mathematica commands and functions to Maple means that Maple will have to reimplement all of Mathematica functions inside it (those that have no direct corresponding in Maple ). May be this will take 20 millions or so lines of code to do. Which is not realistic.

 

 

I am sure these functions are important for your work.

But I think given the small resources Maplesoft seem to have, I would prefer Maplesoft put its important resources on things that can impact many more users. Here is a partial list of mine in order or priority (I can add more, but will keep it short)

  1. Fix Latex. myself, will use Maple much more if it has good latex output. This is critical. Most science and math publications use Latex. Maplesoft seems to think Latex is not important for some reason.
  2. Improve the debugger. This is very important and will help so many people to better debug the code. Using the debugger now is a pain compared to other systems.
  3. Improve the help system. On the web, Maple help is terrible (sorry, but true, most of the web pages are not readable). Inside Maple, the help is better, but it is still hard to easily find options and what one wants. Have to read long pages to be able to spot what one wants. Maple help pages need to be much more organized. Also need many more examples.
  4. Improve the user interface. Maple user interface is still not as polished or user friendly as some of the competitors. 

After doing all of the above, then Maplesoft could add these special functions you want :)

try

sum('subs(x = 0, diff(x^2, x$k))', k = 1 .. 2);

which gives 2. 

Need to prevent immediate evaluation.

I would like to make similar graphs for y',y'',y''' etc and i couldn't think of how to do it.

For the above part, what I normally do is get the solution, use unapply to make it a function, then plot it and its derivatives. May be you can do something similar to your ODE. I used the following example for illustration:

restart;
ode:=diff(y(t),t$2)+1/10*diff(y(t),t)+2*y(t)=sin(t);
ic:=y(0)=0,D[1](y)(0)=0;

diff(diff(y(t), t), t)+(1/10)*(diff(y(t), t))+2*y(t) = sin(t)

y(0) = 0, (D(y))(0) = 0

sol:=dsolve([ode,ic],y(t)):
y:=unapply(rhs(sol),t);

proc (t) options operator, arrow; -(1990/80699)*exp(-(1/20)*t)*sin((1/20)*799^(1/2)*t)*799^(1/2)+(10/101)*exp(-(1/20)*t)*cos((1/20)*799^(1/2)*t)-(10/101)*cos(t)+(100/101)*sin(t) end proc

p1:=plot(y(t),t=0..2*Pi,'color'='red');
p2:=plot(diff(y(t),t),t=0..2*Pi,'color'='blue');

plots:-display(p1,p2)

 


 

Download plot_1.mw

Maple 2019.1

Your input is not right. I do not understand what concatentation operator || is doing in the above actually. (did not know one can use || inside matrix)

May be, in simple terms, you can show what is your A,B,C,D matrices are?

This is how I do these things:

restart:
a   := Matrix([[0,1,0,0],[0,0,1,0],[0,0,0,1],[-100,-90,-32,-8]]):
b   := Matrix([[0],[0],[5],[6]]):
c   := Matrix([[1,0,0,0]]):
d   := Matrix([[1]]):
sys := DynamicSystems:-StateSpace(a,b,c,d);

DynamicSystems:-ResponsePlot(sys, 
       DynamicSystems:-Step(),duration=10,color=red,legend="step");

Default digits is 10. Solve gives exact solution. When converted to numerical using only 10 digits you get the difference shown

if you increase the Digits to say 16, now both give the same answer.

restart;

sol:=solve(cos(2*arccos(x)));
evalf(sol);
Digits:=16:
evalf(sol);

(1/2)*2^(1/2)

.7071067810

.7071067811865475

restart;

fsolve(cos(2*arccos(x)));
Digits:=16:
fsolve(cos(2*arccos(x)));
 

.7071067812

.7071067811865475

 

 

Download 072919.mw

If your expression is sums/addition as you show, you could try patmatch

restart;
foo:=proc(expr)
  local  b,c,la;
  local result:={};
  if patmatch(expr,b::nonunit(realcons)+c::anything,'la') then
     assign(la);
     result := b;
  fi;
     
  return(result);
end proc:

And now

expr:=35.438*y1(x)-34424*y2(x)+78.34+2*z1(x)+33*x:
foo(expr)

gives 78.24

and

expr:=2*z1(x)+33*x:
foo(expr)

gives {}

 

You can use the option 'series' to get series solution,. Change Order to obtain more terms. But for series solution, initial conditions must be given at a single point, Which is not the case in your ode. But Maple can solve analytically.

If you solve it using series, without IC, it works
 

restart;
ode:= diff(g(r),r$2)- r/R*g(r)=0;
ic:=g(2*R)=0, D[1](g)(0)=R;
dsolve([ode,ic],g(r)) assuming R>0

diff(diff(g(r), r), r)-r*g(r)/R = 0

g(2*R) = 0, (D(g))(0) = R

g(r) = -2*R^(4/3)*Pi*AiryBi(2*R^(2/3))*AiryAi(r/R^(1/3))/(GAMMA(2/3)*(3^(2/3)*AiryAi(2*R^(2/3))+3^(1/6)*AiryBi(2*R^(2/3))))+2*AiryAi(2*R^(2/3))*R^(4/3)*Pi*AiryBi(r/R^(1/3))/(GAMMA(2/3)*(3^(2/3)*AiryAi(2*R^(2/3))+3^(1/6)*AiryBi(2*R^(2/3))))

Order:=10;
dsolve(ode,g(r),'series') assuming R>0

10

g(r) = series(g(0)+(D(g))(0)*r+((1/6)*g(0)/R)*r^3+((1/12)*(D(g))(0)/R)*r^4+((1/180)*g(0)/R^2)*r^6+((1/504)*(D(g))(0)/R^2)*r^7+((1/12960)*g(0)/R^3)*r^9+O(r^10),r,10)

 

 

Download t.mw

 

 

 

 

 

"with solutions k*Pi and -Pi/48 + K*Pi/8"

What is K above? Is this supposed to be an integer? If so, the above misses many solutions:

restart;
eq   := sin(9*x-(1/3)*Pi) - sin(7*x-(1/3)*Pi);
pt1  := [seq( [k*Pi,0] ,k=-2..2)];
pt2  := [seq( [-Pi/48+k*Pi/8,0],k=-2..2)];
pt   := [op(pt1),op(pt2)];

plots:-display([
        plot(eq,x=-2*Pi..2*Pi,color=blue),
        plots:-pointplot(pt,color=red,symbol=circle,symbolsize=20)]
       );

 

You can see there are many zeros your solution missed.

You could use map. To map a function to list. Here is an example

my_values:=[1,2,3];
foo:=x-> x^2;
map(foo,my_values)

     [1, 4, 9]

So in your case

 

fI := [12.5, 16, 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000]:
x:= 23;
y:= 36;
Lp:= z->8-10*log[10]((1+(z/(2*x))^2.5)*(1+(y/(2*z))^1.7));
map(Lp,fI)

gives

[3.274233826, 4.233853584, 4.851085247, 5.179646200, 5.157642183, 4.688048956, 
3.809126215, 2.467329267, 0.689125561, -1.242681054, -3.35483821, -5.82698075, 
-8.13745542, -10.49146441, -12.95740533, -15.52422767, -17.93167078, -20.43110843, 
-23.01860293, -25.43771840, -27.85814511, -30.53677413, -32.95859769, -35.38074288, 
-37.88959767, -40.48306044, -42.90564400, -45.41479325, -48.00845170, -50.43115414, 
-52.85387222, -55.53409784, -57.95683404]

 

one way might be

x:= C*exp(I*T[1]*e*eta);
algsubs(e*T[1]=T[2],x)

You can obtain a series solution

dsolve([ode,y(0)=C1,D(y)(0)=C2],y(t),'series')

 

 

try isprime.  as in 

select(isprime,{$1..100});

 

{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}

 

1 2 3 4 5 6 7 Page 1 of 7