Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

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!

Hey friends

I want to solve this relation with respect to "M"analytically but maple answer me: "Warning, solutions may have been lost"

How I can solve this problem and get to an analytical solution. It must be noted -1<w<-1/3. we can fix "w" with any value inn this interval. It be accepted any solution for any fixed "w".

Thank you

Analytically_solution.mw

Hi everyone,

I am desperatly trying to find a reason to those weird results I get using LSSolve. It could really help me to understand, maybe I am using the function the wrong way.
I have a system of equations which is overdetermined that I wrote using an electrical simulation and kirchoff's laws.
I am trying to resolve it using the LSSolve function. Here is the list of residuals :

list := [-0.444299277411586e-2+(270.100000000000-Phi12_18)*D18, -.264819908561346+(627.030000000000-Phi23_18)*D18, .191242220011840+(-259.080000000000-Phi34_18)*D18, 0.269723795794403e-1+(-40.5060000000000-Phi45_18)*D18, 0.674200455699644e-2+(-10.1270000000000-Phi56_18)*D18, .109534122562258+(-197.290000000000-Phi67_18)*D18, 0.481462872723211e-3+(-2.41420000000000-Phi78_18)*D18, -0.346014532189641e-4+(-2.53290000000000-Phi89_18)*D18, -0.402474969346295e-4+(-2.94150000000000-Phi910_18)*D18, -0.632005430249463e-3+(-8.57100000000000-Phi1011_18)*D18, -0.105749265697549e-1+(-37.6580000000000-Phi1112_18)*D18, -0.116305497595306e-1+(-55.3250000000000-Phi1213_18)*D18, -0.581547498854927e-3+(-2.76630000000000-Phi1314_18)*D18, -0.371408130367776e-2+(-22.0900000000000-Phi1415_18)*D18, -0.886173700610320e-2+(-56.4810000000000-Phi1516_18)*D18, -0.478846208996643e-1+(262.447651185421-Phi12_18)*D29+(262.447651185421-Phi12_24)*D36, .348429199898355+(62.3165310883292-Phi23_18)*D29+(62.3165310883292-Phi23_24)*D36, .237294781239637+(41.8563477700905-Phi34_18)*D29+(41.8563477700905-Phi34_24)*D36, 0.356987380524040e-1+(6.12136413036823-Phi45_18)*D29+(6.12136413036823-Phi45_24)*D36, 0.892515544035472e-2+(1.53042068810978-Phi56_18)*D29+(1.53042068810978-Phi56_24)*D36, .163733792213247+(26.7554245920538-Phi67_18)*D29+(26.7554245920538-Phi67_24)*D36, 0.917897899527287e-3+(-0.110562085900856e-3-Phi78_18)*D29+(-0.110562085900856e-3-Phi78_24)*D36, 0.242480164562623e-4+(-.283316330467957-Phi89_18)*D29+(-.283316330467957-Phi89_24)*D36, 0.281967728090880e-4+(-.329007391842407-Phi910_18)*D29+(-.329007391842407-Phi910_24)*D36, -0.812318100863302e-3+(-1.22850243118112-Phi1011_18)*D29+(-1.22850243118112-Phi1011_24)*D36, -0.174002698946928e-1+(-9.57006175329410-Phi1112_18)*D29+(-9.57006175329410-Phi1112_24)*D36, -.125540933056649+(-44.2197489328973-Phi1213_18)*D29+(-44.2197489328973-Phi1213_24)*D36, -0.627722694977691e-2+(-2.21106159188713-Phi1314_18)*D29+(-2.21106159188713-Phi1314_24)*D36, -0.739424545575381e-1+(-24.8403831529913-Phi1415_18)*D29+(-24.8403831529913-Phi1415_24)*D36, -.203976357415920+(-68.0132712014090-Phi1516_18)*D29+(-68.0132712014090-Phi1516_24)*D36, 0.196522429267177e-1+(197.940000000000-Phi12_24)*D27, 0.368371276889244e-2+(57.8900000000000-Phi23_24)*D27, 0.144256702539785e-2+(48.4450000000000-Phi34_24)*D27, -0.115630146715321e-3+(10.-Phi45_24)*D27, -0.283028527731083e-4+(2.50010000000000-Phi56_24)*D27, -0.300476205822746e-2+(66.2640000000000-Phi67_24)*D27, -0.653509876948917e-3+(2.69040000000000-Phi78_24)*D27, -0.126753046978926e-2+(4.44790000000000-Phi89_24)*D27, -0.147212636486122e-2+(5.16530000000000-Phi910_24)*D27, -0.484316181019253e-2+(16.6000000000000-Phi1011_24)*D27, -0.298854531528585e-1+(96.8770000000000-Phi1112_24)*D27, -.120604432493978+(315.410000000000-Phi1213_24)*D27, -0.603334119632106e-2+(15.7700000000000-Phi1314_24)*D27, -0.664471982996522e-1+(167.170000000000-Phi1415_24)*D27, 0.786913003105101e-1+(-326.760000000000-Phi1516_24)*D27]


I know that all D values must be positive. When resolving the system without any constraints (D >= 0), i get the values I expected (knowing the input I used in the simulation), with a really low error :

result := LSSolve(list);

[1.82130325886306*10^(-8), [D10 = 0.200009334740825e-2, D11 = 0.666620509302803e-3, D14 = 0.222215208246154e-2, D15 = 0.128202791383597e-2, D17 = 0.499886140344411e-2, D19 = 0.302925526676043e-3, D2 = 0.100002349341980e-2, D20 = 0.142849446596938e-3, D22 = 0.111121127122156e-1, D23 = 0.222228054119820e-2, D25 = 0.714293621502836e-3, D26 = 0.833326349912537e-3, D28 = 0.217396531719902e-3, D3 = 0.400217567900069e-3, D6 = 0.166878862202449e-3, D7 = 0.999969828547956e-2, Phi1011_17 = -1.22850243118112, Phi1011_19 = -20.5335193736012, Phi1011_21 = -104.090964313150, Phi1011_23 = 19.2144499395683, Phi1112_17 = -9.57006175329410, Phi1112_19 = -81.6848630234903, Phi1112_21 = -242.149849175388, Phi1112_23 = 109.001351349915, Phi1213_17 = -44.2197489328973, Phi1213_19 = -92.8267195929548, Phi1213_21 = -204.444165890808, Phi1213_23 = -61.4447612788985, Phi12_17 = 262.447651185421, Phi12_19 = 262.149192406679, Phi12_21 = 256.248405276737, Phi12_23 = 246.521172863223, Phi1314_17 = -2.21106159188713, Phi1314_19 = -4.64255435896474, Phi1314_21 = -10.2212158757032, Phi1314_23 = -3.07798400495386, Phi1415_17 = -24.8403831529913, Phi1415_19 = -30.5944507718603, Phi1415_21 = -45.5847025259923, Phi1415_23 = -77.3297680041818, Phi1516_17 = -68.0132712014090, Phi1516_19 = -74.2023324471993, Phi1516_21 = -95.1952296374558, Phi1516_23 = -132.328467080565, Phi23_17 = 62.3165310883292, Phi23_19 = 200.804225452845, Phi23_21 = 130.018791598707, Phi23_23 = 73.7043262431720, Phi34_17 = 41.8563477700905, Phi34_19 = 343.409987932231, Phi34_21 = 159.593996060841, Phi34_23 = 62.6564757702407, Phi45_17 = 6.12136413036823, Phi45_19 = 12.3839171939746, Phi45_21 = 46.0005281797016, Phi45_23 = 13.1665796516893, Phi56_17 = 1.53042068810978, Phi56_19 = 3.16614687399595, Phi56_21 = 11.4998114891963, Phi56_23 = 3.29093394692614, Phi67_17 = 26.7554245920538, Phi67_19 = -244.288977944524, Phi67_21 = 376.351493538080, Phi67_23 = 88.4830465193635, Phi78_17 = -0.110562085900856e-3, Phi78_19 = -6.28061380389266, Phi78_21 = 43.7035845962372, Phi78_23 = 3.35123473697264, Phi89_17 = -.283316330467957, Phi89_19 = -6.18811507913178, Phi89_21 = -13.9258224376815, Phi89_23 = 5.20325572546379, Phi910_17 = -.329007391842407, Phi910_19 = -7.18580970783931, Phi910_21 = -16.1669897128450, Phi910_23 = 6.04291224185087]]


When adding the constraints that D should be positive (and that are actually positive in the previous result), I get a worse result in term of precisions :

LSSolve(list, {D10 >= 0, D11 >= 0, D14 >= 0, D15 >= 0, D17 >= 0, D19 >= 0, D2 >= 0, D20 >= 0, D22 >= 0, D23 >= 0, D25 >= 0, D26 >= 0, D28 >= 0, D3 >= 0, D6 >= 0, D7 >= 0});

[0.667302976414869964e-1, [D10 = 0.240199442379079e-2, D11 = 0.666577572133538e-3, D14 = 0.222218786790062e-2, D15 = 0.128192441757651e-2, D17 = 0.278678889056743e-2, D19 = 0.200473317719685e-3, D2 = 0.109938538155804e-2, D20 = 0.840721762649974e-4, D22 = 0.685770482726534e-3, D23 = -1.387530857*10^(-312), D25 = 0.714397733627028e-3, D26 = 0.833201232339238e-3, D28 = 0.204319731851617e-3, D3 = 0.419994015872111e-3, D6 = 0.191996909862889e-3, D7 = 0.103884505319047e-1, Phi1011_17 = -.709707335593168, Phi1011_19 = -15.7863975896827, Phi1011_21 = -151.171843708558, Phi1011_23 = 19.2211409030343, Phi1112_17 = -8.90604676283968, Phi1112_19 = -75.8627539382983, Phi1112_21 = -311.423930967299, Phi1112_23 = 109.002880650927, Phi1213_17 = -54.9212365194647, Phi1213_19 = -89.9790565093006, Phi1213_21 = -250.971671756001, Phi1213_23 = -61.5160003335629, Phi12_17 = 251.480872515883, Phi12_19 = 255.977573006508, Phi12_21 = 254.397100891354, Phi12_23 = 246.524672366158, Phi1314_17 = -2.74614386328796, Phi1314_19 = -4.48401822538664, Phi1314_21 = -12.5381572344771, Phi1314_23 = -3.08154491280567, Phi1415_17 = -31.8947514252141, Phi1415_19 = -30.8090400512349, Phi1415_21 = -51.0499196769535, Phi1415_23 = -77.3268969229600, Phi1516_17 = -87.7947790488482, Phi1516_19 = -75.5403005246575, Phi1516_21 = -101.763771364478, Phi1516_23 = -132.314524393221, Phi23_17 = 94.0093590848714, Phi23_19 = 86.4429757025976, Phi23_21 = 108.554765004168, Phi23_23 = 73.7072279431268, Phi34_17 = 87.6938924370977, Phi34_19 = 82.3922347753764, Phi34_21 = 88.5582078636840, Phi34_23 = 62.6604078051191, Phi45_17 = 13.1910198060107, Phi45_19 = 69.3008595136787, Phi45_21 = 15.5530983566712, Phi45_23 = 13.1677681559684, Phi56_17 = 3.29792072169498, Phi56_19 = 17.4003349272078, Phi56_21 = 3.88187632917493, Phi56_23 = 3.29123115133383, Phi67_17 = 60.0045707036166, Phi67_19 = 54.3070868626015, Phi67_21 = 87.9421288802858, Phi67_23 = 88.4929920125095, Phi78_17 = .279952186311827, Phi78_19 = -3.50632712699693, Phi78_21 = -20.3872167203319, Phi78_23 = 3.35213748642018, Phi89_17 = -0.991299169828910e-1, Phi89_19 = -4.44636683843093, Phi89_21 = 297.888811926331, Phi89_23 = 5.20500671661437, Phi910_17 = -.115101700555720, Phi910_19 = -5.16603761776826, Phi910_21 = 346.033351291632, Phi910_23 = 6.04494564310825]]

I also get the warning "limiting number of major iterations has been reached".
Can someone explain me?

It may not seem important at first sight, but sometimes when using my program I get wrong values and a negative D, which is not possible. Therefore I try to add a positive constraint, but the LLSolve function doesn't return anything except the error "no improved point could be found", which is weird because when I manually substitute the value I consider correct, i get a really low error. I can show you the related list of equations if you are interested...

 

Thanks in advance,

Lilian

the following code results in an error message: Error, (in forget) lexically scoped parameter out of context

If I click on this error message, it brings me to a page which I visited too often.

if I uncomment the irrelevant minimize command, the error message disappears.

How can I prevent this error without giving irrelevant commands?

kind regards,

Harry Garst

I would like to use method wsolve for solving polynomial equations. The method has been implemented by Wang: https://link.springer.com/chapter/10.1007/978-3-7091-6604-8_9

As it is written in the text the metod is part of charsets package. But I can seem to find it and active it. I can find package online (http://wang.cc4cm.org/charsets.html), but I don't know how to add it to Maple.

I need to use this method in order to prove geometry theorems (and not any other method will do) and compare my results with results of other researchers.

hello.i have a problem for solving this equation.i dont why my past post about this is deleted.!!!

please help me

thanks,,,

9.mw
 

restart:

A1:= 27159:  n:= 0.59:  A2:= 70941:  h0:= 3e-4:   
L:= 0.8:  dpx := -98100:  uc:= 0.007:  k:=2.7:

ODE:= (A3,y)->
   (h0^(n+1)*L/sqrt(n)*(A1*exp(sqrt(n)*y/L)-A2*exp(-sqrt(n)*y/L))/k+dpx*y*h0^(n+1)/k+A3*(h0)^n/k)^(1/n)
;

proc (A3, y) options operator, arrow; (h0^(n+1)*L*(A1*exp(sqrt(n)*y/L)-A2*exp(-sqrt(n)*y/L))/(sqrt(n)*k)+dpx*y*h0^(n+1)/k+A3*h0^n/k)^(1/n) end proc

(1)

ODEINT:= proc(A3)
option remember;
local y;
   evalf(Int(ODE(A3,y), y= 0..1, epsilon= 1e-7)) - uc
end proc:

ReINT:= proc(A3x, A3y)
   Digits:= 15:
   Re(ODEINT(A3x + I*A3y))
end proc:

ImINT:= subs(Re= Im, eval(ReINT)):

Digits:= 7:
a3:= fsolve([ReINT, ImINT]);

fsolve([ReINT, ImINT])

(2)

A3:= Complex(a3[]);

Complex(fsolve([ReINT, ImINT])[])

(3)

Solve as IVP:

Digits:= 15:
sol:= dsolve({diff(u(y),y) = ODE(A3,y), u(0)=0}, numeric, range=0..1,  output=listprocedure):

Warning,  computation interrupted

 

NULL

``

NULL

NULL

plots:-odeplot(
   sol, [[y, Re(u(y))], [y, Im(u(y))]], y= 0..1,
   legend= [real, imag], labels= [y, u(y)]
);

Verify that boundary condition at u(1) is satisfied:

 

 

 

abs(eval(u(y), sol(1)) - uc);

sol(.5);

"\"

fy3 := eval(u(y), sol); with(CurveFitting); fy33 := PolynomialInterpolation([[0, fy3(0)], [.1, fy3(.1)], [.2, fy3(.2)], [.3, fy3(.3)], [.4, fy3(.4)], [.5, fy3(.5)], [.6, fy3(.6)], [.7, fy3(.7)], [.8, fy3(.8)], [.9, fy3(.9)], [1, fy3(1)]], y)

DEBI := int(fy33, y = 0 .. 1)

NULL

``

plot(DEBI, y = 0 .. 1)

``

``

``

``

``


 

Download 9.mw

 

Hi,

I want to solve this equation with respect to M, But Maple answer me: "solution may have been lost"

 

How I can solve this equation?

Thanks guyz

Solutionmayhavebeenlost.mw

Greetings Sirs,

I have recently aquired Maple for some mathematics, and being a new user, I basically google for everything at the moment.

While it has gone well so far, I seem to have hit a bump that I cannot figure out.

I have a function: f(x)=3.2+0.4sin(1.25x), 0<x<5

Trying to find the places where "f(x)=3.5" would normally be done with the equation "3.5=3.2+0.4sin(1.25x)", and when I solve for the equation in Maple I get a solution too.

Problem is though, I know there is supposed to be multiple solutions. Having used wolframalpha, and being capable of seeing the plot in Maple, I know there is two points within the period "x=0..5" that is the solution.

But when I try to solve the equation, I get only one solution per solve, and the second solve doesn't make much sense for me. These are what I use:

As you can see, in the first solve the entire function is being taking into consideration, yet I only get one solution... In the second solve I have tried specifying a period, but I still only get one solution.

Basically any help here is appreciated, because from what I understand, having read google, the solve command or fsolve command is supposed to give multiple results if they are there.

With appreciation,
Ciesi

(Edit: Image size changed)

Dear sir, 

 

I request your kind help with regard to the above cited subject.

 

 

With warm regards.

 

Mr.M.Anand

Associate Professor in Mathematics.

Aurora's Technological & Research Institute, 

Hyderabad-INDIA

Hi,

While running a maple code, I am getting a "invalid if statement termination" error. Most of time when I use nested for loop and if statement inside the loop, I am getting this error. Another error I get frequently is "Error, unterminate loop". I am using "shift+Enter" instead of Enter to avoid blanks but still such error appears. Can any one provide some rules which I should keep in mind to avoid these errors. My maple worksheet is enclosed-

invalid-if-stat-term-error.mw

Thanks and Regards,

Nilesh

 To Whom It Might Concern,

I purchased Maple on Jun 5, 2017 for my Window laptop. However, my harddrive in my laptop was broken and i lost all my stuff including Maple. I am using my husband's laptop right now. How can re install Maple? I still have the transaction number (removed). Would you let me know what I can do to re-install the software? Also, my husband's laptop is a Mac. 

I am looking forward to hearing from you.

Nancy Phu.

I would like to create a Maple Workbook of my Lattice Package so I can put it on MapleCloud. I had an email exchange with Daniel Skoog from Maplesoft about this, and he even sent me an example that looked easy enough to adapt to my purposes. Alas, it does not work. Here is the code I wrote to assemble the already extant files:

restart;
                "Maple Initialization loaded..."
# Build Lattice workbook following example from Daniel Skoog, MapleSoft:
currentdir();
 "/Applications/Math_Calc/Maple 2015/Packages/Lattice/Lattice

    Version 1.1.0 release files"
# We have all files already from the App Center submission, so just assemble the workbook
PackageTools:-Create("Lattice.maple",\
"MLA file"="Lattice.mla",\
"Lattice.help",\
"Source"="Lattice1.1.mpl",\
"Build procedure"="Lattice1.1.mw",\
"Manual"="The Lattice Package Users Guide.mw",\
"Release Notes"="V1.1 Release Notes.rtf");
Error, (in march) unable to attach worksheet file The Lattice Package Users Guide.mw


When I look at the created workbook (Lattice.maple), the only members included are Lattice.help, the Build procedure Lattice1.1.mw and the source file Lattice.mpl. In particular, Lattice.mla is not there, which is the most important one.

What am I doing wrong? What does "march" (which sounds like machine architecture) have to do with it??

I also don't quite know how to "install" it. I assume I just put the whole workbook into a directory accessible through libname ?

Mac Dude

PS: I could have sorted this privately with Daniel, but this may be of interest to others as well so I hope he'll answer through this forum.

Lattice1.1_workbook_maker.mw

I want to solve this equation with assumptions!!!

restart;
assume(d::real, d>0):
assume(a::real, -0.01 < a, a < 0):
sys:={-800*Pi*a*cos(6.557377048*Pi*(3.470797713+d))/(a+1)^3 = -.9396060697, 800*Pi*a*sin(6.557377048*Pi*(3.470797713+d))/(a+1)^3 = -.3238482794};
solve(sys, {a,d},useassumptions=true, AllSolutions=true);

one of the solutions has true "a" but "d" is wrong, I want one true solution!

Maple help pages are terrible.  Sorry, but this is true.

I am looking for one example of how one is supposed to open a file and correctly check that the open was successful and no error occured, all done in code. As in a script.

All what help in fopen says is that if this and that, it generates an error.

            "

OK. But to check for this in code? Why not show an example? the help page on iostatus just lists possible errors. Again, not a SINGLE example of actual Maple code showing how to actually check or handle an error. It just says to call iostatus() and shows the output without an example of what to do next and what to check for.

Lets say one does this:


fileName := "C:\\foo.txt";
fd       := fopen(fileName,WRITE):

Now what? How to check the above was successful? Do I need a trap and catch? catch what? Do I need to check for fd being greater or equal to zero and also use trap in addition? And if an error happens, how to know what it is? How to to format the message, etc.. all in CODE (not interactive) and not by saying just look at the screen and see if there is an error message.

Spend 30 minutes in the help pages and could not find ONE example that shows how to actually check for errors.

I have no idea who writes Maple helps pages, but I find the help pages useless most of the time.

Compare the help for linux fopen for example, where is gives exact details of how to handle the error and find the exact error, all in code.

 

3 4 5 6 7 8 9 Last Page 5 of 1287