acer

32400 Reputation

29 Badges

19 years, 345 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

You can also obtain a somewhat messy piecewise result with explicit numeric bounds on `a`, `b`, and `c`.

solve( {a*x^2 + b*x + c, -1<a, a<1, -1<b, b<1, -1<c, c<1}, x, real, parametric );

@mehdi jafari The region within the cube [-1..1]×[-1..1]×[-1..1] for which there are real solutions is bounded by the conic specified by the discriminant (see my earlier comment). Do you need us to plot it for you?

Are you simply looking for the sign of the discriminant discr=b^2-4*a*c ?

By which I mean the fact that your quadratic has two real roots if discr>0, one real root (of multiplicity two) if discr=0, and zero real roots if discr<0 .

Did you intend to ask how to prove when this quadratic equation would have real roots?

acer

@Bendesarts I don't know of any simple visual cue that allows you to tell, merely at a glance, that an instance of a "Heading 1" has its text wrapped in a Font element.

Here's my limited understanding. "Heading 1" is a named format (style aspect), and in the upper portion of a .mw file the named formats are defined. For example my Maple 2015 .mw files have, by default, a "Heading 1" format that is defined as follows:

<Font name="Heading 1" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>

Now, if I select all of a Section title with the mouse cursor and use the main menubar to change the font to something other than Times New Roman at 18pt (as defined above as default for the Heading 1 format) then the saved .mw file contains this for the Section title. The text is just "BBB",

<Title>
<Text-field style="Heading 1" layout="Heading 1"><Font family="Courier New">BBB</Font></Text-field></Title>

Now if I subsequently change that back to the default for the Heading 1 format of Times New Roman at 18pt and resave then the .mw file has that title as only,

<Title>
<Text-field style="Heading 1" layout="Heading 1">BBB</Text-field></Title>

So it appears to me that the title is not marked up inside a Font element as long as (?) the chosen font and size match the default style for that format.

So some questions I'd ask you include: How did you create the "Heading 1" instances that contain the text wrapped in a Font element? Did you change the font? And do you use a custom style sheet? (I don't.)

Can't your external editor get rid of the Font element wrapping as it appears above? Or is it in another pattern? Or does it wrap around a Textfield? Also, have you considered editing the XML using Maple's XMLTools (even if only to read the .mw file in and parse to a nested function call...)? Maple's a handy high level tool for doing such manipulations.

 

A great deal of the computations done by the Finance package are made via external calls to a (bundled) Quantlib (dynamic shared) library.

But -- even if this is the case for the path generation in question -- it may be necessary to identify the particular version number of the bundled Quantlib library in order to get the right answer.

acer

What methodology are you using to "recover the structure of my worksheet by working on XMLElements"?

Are you using the XMLTools package? Are you reading in the .mw file, so that it becomes a large nested function call?

Are you saying that you just want to remove any qualification by Font, so as to be left with just a Textfield?

It's not clear to me how you are doing the work, so far, and so it's hard to make a concrete suggestion.

(It may or may not be of interest to you, but I have been working on a tool to scrape a .mw file so as to extract all its contents. Ie, all code to 1D Maple Notation, all Text to comment strings, optionally all Output to expressions saved aside, and even all unassigned rendered plots to actual PLOT structures save aside. And so on. I can't tell whether this is of possible use to you as I can't tell whether your target is plainext or rather just a modified .mw file, etc.) 

acer

You already asked this question in another post. This is spam.

acer

@Mac Dude These are not new features. I've seen these kinds things demonstrated in the Std GUI since very early in its existence. The example I gave can be created with the same steps in my Maple 15.01 for Windows 64bit as in my Maple 2015.1 on the same platform.

Here is is, done in Maple 15.01.

inlined1501.mw

Here is a revision with the style of 2D Math output customized to black (Format-Styles from the main menubar), and the text containing inlined 2D Math put into a GUI Table with custon properties.

Download inlinedmathtable.mw

Sure, the rtable subtype of the result returned by SparseLU:-Solve can be made to match that of the RHS of the linear system. See the code revision below.

As for the zeroes of a sparse Matrix, it depends on how you contruct the Matrix. If you used the Matrix command then, yes, you need to specify all the scanned data. But I only used the command because it was convenient. You can also create a sparse Matrix with the syntax M:=Matrix(3,3,storage=sparse,datatype=float[8]) where no entries are initially assigned. You can then start assigning entries, like M[2,4]:=3.12, say. Or you can import the whole sparse Matrix from a file with special formatting, using ImportMatrix.


restart:

SparseLU:=module()

   option package;

   export LU,Solve,Free;

   local extlib, Anz, NumericA, numrows;

   LU:=proc(M::Matrix(:-storage=:-sparse,:-datatype=:-float[8],

                      :-order=:-Fortran_order))

      local extfun, numcols;

      if extlib='extlib' then

         extlib:=ExternalCalling:-ExternalLibraryName("linalg",':-HWFloat');

      end if;

      extfun:=ExternalCalling:-DefineExternal(':-hw_SpUMFPACK_MatFactor',

                                              extlib);

      (numrows,numcols):=op(1,M);

      (Anz,NumericA):=extfun(numrows,numcols,M);

      NULL;

   end proc:

   Solve:=proc(numrows::posint, V::{Matrix,Vector})

      local B,extfun,res;

      if type(V,'Matrix'(':-storage'=':-sparse',':-datatype'=':-float[8]',

                         ':-order'=':-Fortran_order')) then

         B:=V;

      else

         B:=Matrix(V,':-storage'=':-sparse',':-datatype'=':-float[8]',

                   ':-order'=':-Fortran_order');

      end if;

      if extlib='extlib' then

         extlib:=ExternalCalling:-ExternalLibraryName("linalg",':-HWFloat');

      end if;

      extfun:=ExternalCalling:-DefineExternal(':-hw_SpUMFPACK_MatMatSolve',

                                              extlib);

      if not(Anz::posint and NumericA::posint and numrows::posint) then

          error "invalid factored data";

      end if;

      res:=extfun(numrows,op([1,2],B),Anz,NumericA,B);
      if rtable_options(res,':-subtype') <> rtable_options(V,':-subtype') then
          res := convert(res,rtable_options(V,':-subtype'));
      end if;
      res;

   end proc:

   Free:=proc()

      local extfun;

      if not NumericA::posint then

         error "nothing valid to free";

      end if;

      if extlib='extlib' then

         extlib:=ExternalCalling:-ExternalLibraryName("linalg",':-HWFloat');

      end if;

      extfun:=ExternalCalling:-DefineExternal(':-hw_SpUMFPACK_FreeNumeric',

                                              extlib);

      extfun(NumericA);

      NumericA:=-1;

      NULL;

   end proc:

end module:

MM:=Matrix([[0.,0.,-25.],[-53.,-7.,0.],[0.,-70.,0.]],

           ':-storage'=':-sparse',':-datatype'=':-float[8]'):

with(SparseLU):

LU(MM);

VV:=Vector([1,1,1]);

VV := Vector(3, {(1) = 1, (2) = 1, (3) = 1})

ans:=Solve(3,VV);

ans := Vector(3, { sparse_data }, datatype = float[8], storage = sparse)

rtable_options(ans,':-subtype');

Vector[column]

LinearAlgebra:-Norm(MM.ans - VV);

0.

VV:=LinearAlgebra:-RandomMatrix(3,2,':-datatype'=':-float[8]');

VV := Matrix(3, 2, {(1, 1) = -53.0, (1, 2) = 40.0, (2, 1) = 21.0, (2, 2) = 97.0, (3, 1) = -25.0, (3, 2) = 43.0}, datatype = float[8])

ans:=Solve(3,VV);

ans := Matrix(3, 2, { sparse_data }, datatype = float[8], storage = sparse)

rtable_options(ans,':-subtype');

Matrix

LinearAlgebra:-Norm(MM.ans - VV);

0.


Download sparselu.mw

@ClearBlueSky In my followup S is a formula for approximating MTBF. It is devoid of LambertW and GAMMA related functions.

So, you would need a function to compute the finite summation Sum(1/i!, i=0..n). Plug that and the values for R and t into the formula given by S.  I presume you can do that in Excel.

Thanks for adding information about the range of R=0.0..1.0 to your post.

It seems to me that a series approximation fits the MTBF well for R in that range, with t>0, n::posint, etc.

The approximating formula is given by S below. You indicated that you could handle a finite sum (which appears in S).

Let me know, if I've misunderstood. (I discounted this earlier, since I didn't know R and the series approach breaks down for certain t and n when R>1.)

The plot and the Explore are meant to illustrate that ee, eeG, and S agree quite well in the given ranges of the parameters.

restart:

ee := solve(R = exp(t/MTBF) * (t/MTBF) * Sum(1/(i!), i=0..n),MTBF);

t/LambertW(R/(Sum(1/factorial(i), i = 0 .. n)))

eeG := solve(R = exp(t/MTBF) * (t/MTBF) * sum(1/(i!), i=0..n),MTBF);

t/LambertW(exp(-1)*R*GAMMA(n+1)/GAMMA(n+1, 1))

S := convert(series(ee,R=0,6),polynom);

(Sum(1/factorial(i), i = 0 .. n))*t/R+t-(1/2)*t*R/(Sum(1/factorial(i), i = 0 .. n))+(2/3)*t*R^2/(Sum(1/factorial(i), i = 0 .. n))^2-(9/8)*t*R^3/(Sum(1/factorial(i), i = 0 .. n))^3

eplot:=proc(T,N)
   plot(eval([ee, S, eeG],[t=T, n=N]),
        R=0..1,
        style=[line,point,point],
        symbol=[solidcircle,diagonalcross],
        symbolsize=[8,16],
        color=[green,black,red],
        numpoints=20);
end proc:

eplot(33.0, 5);

#Explore(eplot(t,n), parameters=[t=0..100, n=1..10]);

 


Download MTBF1.mw

@Markiyan Hirnyk He didn't ask for a closed form. He asked about something he could use in Excel.

Note that the latter part of my Answer (not Comment) was about what was giving him grief, not what I was suggesting to do. And the first part got rid of the GAMMA calls he seemed to not want. That left the LambertW. So in my followup Comment I discussed obtaining an approximating expression.

Now, obtaining a black box approximating mechanism that allows for arbitrary float R and posint n, to work in Excel, is more work...

If you know particular values for n and t as well as the range for R then you can use Maple to construct H = P(R)/Q(R) which approximates your expression quite well, where P(R) and Q(R) are polynomials in R with float coefficients.

For example (there are other similar ways... you can even get an estimate of the error bound).

restart:

ee := solve(R = exp(t/MTBF) * (t/MTBF) * Sum(1/(i!), i=0..n),MTBF);

t/LambertW(R/(Sum(1/factorial(i), i = 0 .. n)))

P := plot(value(eval(ee,[n=15,t=0.3])),R=0..3,color=green):

H := eval(numapprox:-chebpade(value(eval(ee,[n=15,t=0.3])),R=0.1..3,[4,4]),
     T = orthopoly[T]);

(-.1046598996+.3979979186*R+.2094792186*((20/29)*R-31/29)^2+0.2631635411e-1*((20/29)*R-31/29)^3+0.7344468442e-3*((20/29)*R-31/29)^4)/(-.6116268169+.8210912092*R+.6724478367*((20/29)*R-31/29)^2+.1360729330*((20/29)*R-31/29)^3+0.7230731934e-2*((20/29)*R-31/29)^4)

PH := plot(H, R=0..3, color=red, style=point, numpoints=20):

plots:-display(P, PH, view=-10..10);

 

 

Download LW2.mw

 

@tomleslie Saving to .m format was not always discouraged. It's a convenient way to save results of time consuming computations. It's easier to do than to store in an .mla archive, especially if there are several such results to handle separately.

One major reason for its being discouraged, AFAIK, is that it cannot handle everything. It can't handle modules and records in general. Localness is a problem. For a many instances that is not a problem, however.

Some of the best resources on basic and introductory Maple programming are older texts and web resources, some of which use this functionality as a stock tool.

So it's not so surprising that people would utilize the functionality.

First 328 329 330 331 332 333 334 Last Page 330 of 592