Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Consider a standard initial/boundary value problem for the heat equation on the interval x ∈ [0,1]:

restart;
pde := diff(u(x,t),t) = diff(u(x,t),x,x);
ic := u(x,0) = f(x);
bc := u(0,t)=0,  u(1,t)=0;

Then
pdsolve({pde, ic, bc});
produces the expected Fourier series solution.

However, if we change the interval to x ∈ [-1,1], as in:
bc := u(-1,t)=0,  u(1,t)=0;
pdsolve({pde, ic, bc});

then Maple fails to return a solution.  Why?

Dear all

I need a help how can i solve for example the following PDEs with Initial condition and boundary condition given at x=-1, and x=1.

pde:=diff(u(t,x),t)=diff(u(t,x),x$2);

ics:=u(0,x)=sin(x);

Bcs:=diff(u(t,-1),x)=0;

Bcs:=diff(u(t,1),x)=0;

Many thanks

 

 

 

In using Isolate in RootFinding to compute roots of a real polynomial, the output contains, say, z= some number.  How to get rid of the "z =" so that I can declare that "some number" to be some variable?

I am writing a matrix to file where each matrix element is placed on a new line. An example of such code:

restart:
HH:=Matrix([[x**2,x**z,z**12],[2*x,5**y,6**1]]):
filenameHH:=fopen("test.txt",WRITE,TEXT):

nRow,nCol :=LinearAlgebra[Dimension](HH);
for i from 1 to nRow do
   for j from 1 to nCol do
      fprintf(filenameHH,"%a\n",HH[i,j]):
   od:
od:
fclose(filenameHH):

When this is printed to file, it will print as the power sign ^ regardless of the input it is given. This particular output file will be read in by another language, and due to this the power symbol "^" is not desired, but instead " ** ". By converting the matrix into a string format and applying string operations, this can be done; but is there a simpler way to do it?

-Yeti

Hello,

I am solving a simple system of algebraic equations in a "for" loop. I would like to write all the values of solutions to a matrix, but I only get the symbols. Here is my code:

A:=1:E:=0.1:L0:=<5,5,5,5>:m0g:=0.05:u:=<-5/4,-1/4,-3/4,-1/4>:v:=<-1/2,-3/2,1/2,1/2>:w:=<0,1,0,-1>:
Force:=Matrix(m,2);
for i from 1 to m do
 r1||i:=H||i*L0(i)/(A*E)+H||i/m0g*(arcsinh(V_A||i/H||i)+arcsinh((m0g*L0(i)-V_A||i)/H||i))-sqrt(u(i)^2+v(i)^2);
 r2||i:=V_A||i*L0(i)/(A*E)*(m0g*L0(i)/(2*V_A||i)-1)+H||i/m0g*(sqrt(1+((m0g*L0(i)-V_A||i)/H||i)^2)-sqrt(1+(V_A||i/H||i)^2))-abs(w(i));
 rozw||i:=fsolve({r1||i, r2||i}, {H||i,V_A||i},H||i=0..1);Force(i,1):=H||i;Force(i,2):=V_A||i;subs(rozw||i,Force(i,..));
end do:
evalf(Force);

Thanks in advance,

Iza

I need to create randomly several {1,2,3}-sequences of length 15. I execute:

> with(RandomTools):

> w:=Generate(list(posint(range = 3), 15)):
 

The problem is that when I close the program and then open and run it again, it always produces the same sequences. 

What should I do in order to make it work really randomly? That is, to start at a "random" sequence as well?

Thanks!

Can any one help me correct my doc wherein I want to record 5 minutes with microphone and play it for the same duration through my speaker with a click of button component. I find problem in file path specification.This document in my PC is  in E:\A_PhD2017\MAPLEPhDFiles\RequestCorrection_Microphone_Speaker_from_primetime.mw

Components added are only three: microphone0, Speaker0 and Button0

``

``

``

Edit*Data*Available*Action*contains*the*following*commands

rate := DocumentTools:-GetProperty("Microphone0", samplerate); 1; R := DocumentTools:-GetProperty("Microphone0", value)

Array(%id = 18446745571883247742)

(1)

Edit Click Action for Button contains the following commands.

R := DocumentTools:-GetProperty("Microphone0", value); 1; srate := DocumentTools:-GetProperty("Microphone0", samplerate); 1; DocumentTools:-SetProperty("Speaker0", samplerate, srate); 1; DocumentTools:-SetProperty("Speaker0", value, R)

16000

(2)

NULL

No errors displayed for both the above doc tools use``

Also nonstop continuous evaluation takes place! Where is the loop formation if at all there is any?

Thanks for answering

Ramakrishnan V


 

Download RequestCorrection_Microphone_Speaker_from_primetime.mwRequestCorrection_Microphone_Speaker_from_primetime.mw

PhDFiles\....mw

Hello,

I'm trying to write and simplify expressions involving partial derivatives of an arbitrary function, say f(x,y).

Specifically, I would like diff(f(t,y),t) to evaluate to D[1](f)(t,y), instead of 
diff(f(t,y),t)

And eval(diff(f(x,y),x),x=t) gives the same result. 

Interestingly, diff(f(2*t,y),t) does evaluate to 2*D[1](f)(2*t,y), as expected.

I could get some results by using a custom differentiation function
 

`diff/f` := proc(x,y,v) 
    if v = x then return D[1](f)(v,y):
    elif v = y then return D[2](f)(x,v):
    else return 0: # is there a fallback I can use without risking infinite recursion?
    fi:
end proc:

and it works for the simple case, but now diff(f(2*t,y),t) does not work.

All this makes me feel that there must be a way to get what I want by default, but I can't figure it out.

Is there? Thank you in advance!

Hi Mapleprimes people and robots,


My question is regarding a recursive sequence.  It can be defined non-recursively as - 


a(r) :=  0.8*3^r + 0.2*(-2)^r.

The first few terms are - 

1,2,8,20,68,188, and so on.

Here is my Maple Worksheet.
recursive_sequence_A133467.mw      recursive_sequence_A133467.pdf

I want some Maple code that will produce 30 terms of this sequence.  It is defined as

s[1]:=1:
s[2]:=2:

for n>2 we let s[n] = s[n-1] + 6*s[n-2].

Let me know if my question does not make sense.

Regards,
Matt

 

Hello,
I have a second problem which is related to converting horizontal axis to degrees ( or in terms of Pi :  0 - Pi/2 ).

Thank you for your helps

Bengu


restart;
s1 := (1/3*(4*(1.66+10^(-1))^2-x^2))^(3/2)/(x^2*(1+.66+10^(-1)))-sin(2*a);
s2 := (1/3*(4*(1.66+10^(-2))^2-x^2))^(3/2)/(x^2*(1+.66+10^(-2)))-sin(2*a);
s3 := (1/3*(4*(1.66+10^(-3))^2-x^2))^(3/2)/(x^2*(1+.66+10^(-3)))-sin(2*a);
k1 := series(s1, x);
                    (-2)                                 
       4.769067180 x     + (-0.5773502688 - 1. sin(2. a))

                           2    / 4\
          + 0.01164914507 x  + O\x /
k2 := series(s2, x);
                    (-2)                                 
       4.293792441 x     + (-0.5773502692 - 1. sin(2. a))

                           2    / 4\
          + 0.01293857500 x  + O\x /
k3 := series(s3, x);
                    (-2)                                 
       4.247636750 x     + (-0.5773502693 - 1. sin(2. a))

                           2    / 4\
          + 0.01307916821 x  + O\x /
p1 := convert(k1, polynom);
  4.769067180                                                2
  ----------- - 0.5773502688 - 1. sin(2. a) + 0.01164914507 x 
       2                                                      
      x                                                       
p2 := convert(k2, polynom);
  4.293792441                                                2
  ----------- - 0.5773502692 - 1. sin(2. a) + 0.01293857500 x 
       2                                                      
      x                                                       
p3 := convert(k3, polynom);
  4.247636750                                                2
  ----------- - 0.5773502693 - 1. sin(2. a) + 0.01307916821 x 
       2                                                      
      x                                                       
with(plots, implicitplot);
implicitplot([p1, p2, p3], a = 0 .. (1/2)*Pi, x = 0 .. 3, style = point, symbol = [box, cross, circle], labeldirections = [horizontal, vertical], labels = ["&theta; (radians)", "Switching  field (T)"], color = [blue, red, black], symbolsize = 13);


Hello,

How can I fit my equation with the experimental data given below? 

My equation is:  y = A*y^3+B*x ,  where x is the independent variable,  and y is the dependent variable. 
Also how can I determine A and B constants? 
Thanks

Bengu


restart;
Xvals := [.53993447, .5599647, .57995479, .59995566, .61996118, .63994512, .65994136, .6799731, .69996782, .71997949, .73997422, .75995044, .77994976, .7999707, .81995146, .83995244, .85996729, .87994951, .8999458];
Yvals := [-.79625455, -.75585259, -.67800183, -.47955884, -.25493698, -0.65747361e-1, .10114507, .26994542, .41484068, .50621122, .60363251, .65510417, .7251356, .75804148, .76002419, .8030069, .82774732, .8429559, .8692888];
with(Statistics);
points := ScatterPlot(Xvals, Yvals);
PLOT(CURVES(Matrix(19, 2, {(1, 1) = .53993447, (1, 2) = 

   -.79625455, (2, 1) = .5599647, (2, 2) = -.75585259, (3, 1) = 

   .57995479, (3, 2) = -.67800183, (4, 1) = .59995566, (4, 2) = 

   -.47955884, (5, 1) = .61996118, (5, 2) = -.25493698, (6, 1) 

   = .63994512, (6, 2) = -0.65747361e-1, (7, 1) = .65994136, 

   (7, 2) = .10114507, (8, 1) = .6799731, (8, 2) = .26994542, 

   (9, 1) = .69996782, (9, 2) = .41484068, (10, 1) = .71997949, 

   (10, 2) = .50621122, (11, 1) = .73997422, (11, 2) = 

   .60363251, (12, 1) = .75995044, (12, 2) = .65510417, (13, 1) 

   = .77994976, (13, 2) = .7251356, (14, 1) = .7999707, (14, 2) 

   = .75804148, (15, 1) = .81995146, (15, 2) = .76002419, (16, 

   1) = .83995244, (16, 2) = .8030069, (17, 1) = .85996729, 

   (17, 2) = .82774732, (18, 1) = .87994951, (18, 2) = 

   .8429559, (19, 1) = .8999458, (19, 2) = .8692888}, datatype 

   = float[8]), COLOUR(RGB, 0., 0.054901961, 0.47058824), 

  STYLE(POINT)), AXESLABELS("", ""), VIEW(DEFAULT, DEFAULT))
with(plots);
display(points);

Statistics:-Fit(a*y^3+b*x, Xvals, Yvals, y);
                              3                             
   HFloat(2.996866026020011) y  - HFloat(0.9272751314432008)
example("?");

  

 

I want to find the first positive solution of the system of trigonometric equations inside the loop.

The solutions are in the form of "d=number*_Z +number" but I need one exact solution to use it for next run of the loop.
 

restart;
L[0]:=0:
for i from 1 by 1 to 3 do
assume(0<d[i], d[i]<1):
assume(-0.01<a[i], a[i]<0):
L[i]:= L[i-1]+ d[i]:
sys[i]:={Re((-80*Pi*I*a[i]/((a[i]+1)^3))*exp(4*Pi*I*L[i])) = -0.4, Im((-80*Pi*I*a[i]/((a[i]+1)^3))*exp(4*Pi*I*L[i])) = 0.8}:
solve(sys[i], {a[i],d[i]}, useassumptions = true,AllSolutions=true):
end do;
 

These are the solutions:

d[1] = 0.03689590440 + 0.5000000000 _Z1

d[2] = -1.000000000 d[1] + 0.03689590440 + 0.5000000000 _Z2

d[3] = -1.000000000 d[1] - 1.000000000 d[2] + 0.03689590440 + 0.5000000000 _Z3

 

Hello all, 

 

This is my first time with Maple, I have been a student of Mathematica for 7 years. I purchased Maple to learn a new software and I have heard great things about it. I somehow dont feel the flexibility of Mathematica in Maple documentations. It seems to be a bit constrained and not very straight forward in some aspects. Please correct me if I am wrong and also point out to tutorials or documents that I should be looking at before nose diving into Maple.

worksheet example here: 

I have faced 2 simple problems which I think is a bug in some form, or I may be wrong. Please advise.

  1. How do I insert Equation 7 before Equation 6? The worksheet wont let me do it.
  2. Why are 'and' and 'in' bolded automatically in SECTION format?

Yahoo Finance recently discontinued their (largely undocumented) historical stock quote API.

Previously, you get simply send a HTTP:-Get request like this…

HTTP:-Get(“http://ichart.yahoo.com/table.csv?s=AAPL&a=00&b=1&c=2016&d=00&e=1&f=2017&g=d&ignore=.csv")

…and get historical OHLCV (open, high, low, close, trading volume) data in your worksheet (in this case for AAPL between 1 January 2016 and 1 January 2017).

This no longer works! Yahoo shut the door on this easy-to-use and widely disseminated API.

You can still download historical stock quotes from Yahoo Finance into Maple, but the process is now somewhat more involved. My complete code in this worksheet but I'll step through the process below.

If you visit the updated Yahoo Finance website and download historical data for a ticker, you see a URL like this in the status bar of your browser

https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1497727945&period2=1500319945&interval=1d&events=history&crumb=C9luNcNjVkK

Let's examine how ths URL is constructed.

  • period1 and period2 are Unix time stamps for your start and end date
  • interval is the data retrieval interval (this can be either 1d, 1w or 1m)
  • crumb is an alphanumeric code that’s periodically regenerated every time you download new historical data from from the Yahoo Finance website using your browser. Moreover, crumb is paired with a cookie that’s stored by your browser.

Here’s how to extract and supply the cookie-crumb pair to Yahoo Finance so you can still use Maple to retrieve historical stock quotes

Send a dummy request to get a cookie-crumb pair

res:=HTTP:-Get("https://finance.yahoo.com/lookup?s=bananas"):

Grab the crumb from the response

i:=StringTools:-Search("CrumbStore\":{\"crumb\":\"",res[2]):
crumbValue := res[2][i+22..i+32]
                  crumbValue := "btW01FWTBn3"

Store the cookie from the response

cookieHeader:=res[3]["Set-Cookie"]
    cookieHeader := "B=702eqhdcmq7cl&b=3&s=0t; expires=Mon,17-Jul-2018 20:27:01 GMT; path=/; domain=.yahoo.com

Construct the URL

  • Your desired start and end dates have to be defined as Unix time stamps. Converting a human readable date (like 1st January 2017) to a Unix timestamp is simple, so I won't cover it here.
  • The previously retrieved crumb has to be added to the URL.
ticker:="AAPL":
p1 := 1497709183:
p2 := 1500301183:
url:=cat("https://query1.finance.yahoo.com/v7/finance/download/",ticker,"?period1=",p1,"&period2=",p2,"&interval=1d&events=history&crumb=", crumbValue):

Send the request to Yahoo Finance, including the cookie in the header

data:=HTTP:-Get(url,headers = ["Cookie" = cookieHeader])

Your historical data is now returned

The historical data is now easily parsed into a matrix.

Please note that any use of Yahoo Finance has to be consistent with their terms of service.

I need a help on the error message below as when I enter it on my browser the answer is that there isn't any hel for this subject.

Error Message:

Error, (in DynamicSystems:-EquilibriumPoint) the independent variable in the equations does not match the 'continuoustimevar' (t) specified by the DynamicSystems[SystemOptions].

Thank you!

1 2 3 4 5 6 7 Last Page 3 of 1286