tomleslie

13876 Reputation

20 Badges

15 years, 181 days

MaplePrimes Activity


These are replies submitted by tomleslie

I'm running Maple on 64-bit Windows 7, and it does exactly what I would expect, see below


 

restart;
version();
with(RealDomain):
with(Grid):
a := 1:
Seq(1/a, i = 1 .. 2);

 User Interface: 1238644
         Kernel: 1238644
        Library: 1238644

 

1238644

 

1, 1

(1)

 


 

Download noError.mw

what you are trying to achieve, therefore I cannot help. I appreciate that this is probably a language problem. But until I know what you are trying to do I cannot really help :-(

  1. If you call a procedure (any procedure) with the argument 1/0, then the argument is evaluated, and generates an error before the procedure is invoked. Since the divide_by_zero Error is generated before the procedure is invoked, using a NumericEventHandler() statement within the procedure is TOTALLY POINTLESS
  2. Specifying the NumericEvenetHandler() at the "top" level will work, but as I stated in my previous post, you will not be able to distinguish between +1/0-1/0.and 0/0. One answer  will apply to all of these. You may be happy with any of +infinity, -infinity, 1, 0 applied to ALL cases, but I don't think I would be
  3. The code I posted previously does not handle the case 0/0, since csgn(0)=0. Ihave modified the code (see below) where I have chose to set 0/0=1. If you d not like this cooice then commnt it out and uncomment any of the other three nswers you want

restart;
f:=proc(a, b:=1)
              local u, x;
              if      b=0
              then if       a=0
                       then x:=1
                    # x:=-infinity;
                    # x:= infinity
                    # x:= 0
                      else x:=csgn(a)*infinity
                      end if
              else x:=a/b
             end if:
             Digits:=15;
             if      x>10^9
            then u:=1/x;
                     evalf(Pi/2*arccos((u*u-1)/(1+u*u)));
            else evalf(Pi/2*arccos((1-x*x)/(1+x*x)))
            end if
     end proc:

 

Try explaining  (in English - not code!) what you are trying to achieve. Because right now I have no idea

because, if I start with

restart;
f := -ln(-1-ln(exp(x)))+ln(-ln(exp(x)))-Ei(1, -1-ln(exp(x)))+Ei(1, -ln(exp(x)));
solve(limit(diff((subs(x=q, f)-f),h), h=0) = f, q);

It executes without error, but produces nothing interesting because

  1. f depends only on x (Check this with indets(f, name))
  2. the comand subs(x=q, f)-f reurns an expression wcich depends only on 'x' and 'q'
  3. so diff((subs(x=q, f)-f),h) returns 0 because nothing depends on 'h'
  4. so (limit(diff((subs(x=q, f)-f),h), h=0) is actually limit(0, h=0), which (unsurprisingly returns 0
  5. so limit(diff((subs(x=q, f)-f),h), h=0) = f evaluates to f=0: although this is a really complictaed way to get this equation!
  6. Note 'f' only depends on x (see [1] above). Thus solve(limit(diff((subs(x=q, f)-f),h), h=0) = f, q) is equivalent to solve(f=0, q) and since 'f' does' not depend on 'q', solve() returns nothing

If                   f(x,y)=x.y)
then  diff( f(x(,y), x) = 0  will return y=0, and
         diff( f(x,y), ,y) = 0  will return x=0.

So your execution group

yy := [diff(f(x, y), x) = 0, diff(f(x, y), y) = 0];

will return,{x=0, y=0} - and I can assure that the subsequent pdsolve command, which is now

pdsolve({ x=0, y=0})

is never going to return anything interesting.

pdsolve() expects a partial differtnia equation (or s set/list of these) - but trust me, supplying x=0,y=0 does not comprise any kinfd of soluble PDE (system)

          

The only advice I can give is that (as a general rule!!) names that start with an underscore (with the exception of _Env) are used as global variable names by Maple and are effectively reserved for use by library code. (see the help page with ?names)

So the only way anyone could solve your problem is to see which library code you are calling, with which arguments, etc, etc. Since you don't provide this, I doubt if anyone here can help

 

 

@Adam Ledger 

Use the big green up-arrow in the toolbar to upload an executable worksheet which demonstrates your issue

@Adam Ledger  My original response stands

@vv 

But of course I could be wrong!

The whole point in a fitting problem is that Y is not equal to X.b. So suggesting that b = X^(-1).Y can is unlikely be true.

The quantity Y-X.b provides a vector of "residuals", hence the expression Transpose(Y-X.b).((Y-X.b) produces a scalar which is the sum of the squares of the residuals. A little thought shows that this expression is quadratic in each  of the elements of 'b'. Hence differentiating with respect to each element in b, one ends up with set of equations which are linear with respect ot each element in b. This set of linear equations can be solved to provide the optimal value of 'b' - ie the one which minimises the squared sum of residuals.

For me the OP's problem occurs when one is not using the "simple" error measure corresponding to the squared sum of residuals provided by

Transpose(Y-X.b).((Y-X.b)

Other fitting criteria can be justifiably invoked, and can usually(?) be interpreted as changing the error to be minimised as

Transpose(Y-X.b).K.((Y-X.b)  rather than Transpose(Y-X.b).((Y-X.b)

However such criterai may not be quadratic in the elements of b, so the consequnet differntiation wrt the element of b will not be linear and hence I am uncertain whether an unambiguous minimum could be guaranteed. This is somethin I'd like o look at on a case-by-case basis for any specified error criterion.

Error, (in Engine:-Dispatch) cannot determine if this expression is true or false: 1000 < 5^(1/2)

Now everything I have tried (including the 'is' command which you use) returns 'false'. So why would the OP get any error message saying this condition could not be determined? See my repsonse to the OP's earier question at http://www.mapleprimes.com/questions/222394-RootOf-Error-Needing-To-Be-Dispatched

and into the habit of posting the code which leads to the Error messages

Error messages in anyprogramming language are usually a bit "cryptic" and diagnosing why they occur can only be performed by analysing the code which led up to them

I modified my original response to handle the data for 'depth' and 'veloc' which you supplied. My original code still seems to work in

Maple 18
Maple 2015
Maple 2016
Maple 2017

see the attached which was run in Maple 18 (chnages from my earlier post are higlighted in red)


 

  restart;
  with(Statistics):
#
# Running on Maple 18
#
  version();

 User Interface: 991181
         Kernel: 991181
        Library: 991181

 

991181

(1)

#
# Define a "useful" procedure
#
  Dens := proc(v)
               local theta, r;
               evalf[8]
               ( Int
                 ( Int
                   ( 4*r/(1-0.84*cos(theta)^2)^(1/2)*exp(-r*(6.25-5.245*cos(theta)^2)^(1/2)),
                     theta = 0. .. 2*Pi
                   ),
                   r = 0. .. v
                 )
               )  assuming v>=0
          end proc:

#
# OP too inefficient to provide data for fit, so generate
# data using the model function, adding a random value to
# the dependent values. Use parameter values aPar=2.5, and
# bPar=0.75, just because I have to use something, and these
# are in the within the ranges specified by the OP.
#
# The fit process therefore *ought* to return something
# *close* to these values
#
#  aPar:= 2.5:
#  bPar:= 0.75:
#  r:= rand(-0.1..0.1):
#  depth:= [i $ i=1..10]:
#  veloc:= [ seq
#            ( bPar*(1+aPar*k)/k*Dens(k/(1+aPar*k))+r(),
#              k in depth
#            )
#         ]:
#
# Use OP's values for depth and veloc
#
  depth:=[.033, .099, 0.198, 0.264, 0.363, 0.759, 1.25, 1.748, 2.246, 2.744, 3.232, 3.73]:
  veloc:=[0.180, 0.25, 0.296, 0.324, 0.516, 0.606, 0.757, 0.760, 0.784, 0.804, 0.794, 0.790]:

#
# Set up and perform the fit
#
  f:= (z, aVal, bVal)-> bVal*(1+aVal*z)/z*Dens(z/(1+aVal*z)):
  FitFinalDens := NonlinearFit
                  ( f(u,a,b),
                    depth,
                    veloc,
                    u,
                    initialvalues = [a = 1.4, b = 0.13],
                    parameternames = [a, b],
                    output = [residuals, parametervector],
                    parameterranges=[a=1.1..3.0, b=0.02..0.8]
                  );

FitFinalDens := [Vector(4, {(1) = ` 1 .. 12 `*Vector[row], (2) = `Data Type: `*float[8], (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order}), Vector(2, {(1) = 1.57463600214463, (2) = .139336393547862})]

(2)

#
# Plot the data used and the fit achieved
#
  dataPoints:= plots:-pointplot( depth,
                                 veloc,
                                 symbol=solidcircle,
                                 symbolsize=20
                              ):
  fitCurve:= plot( z-> f( z,
                          FitFinalDens[2][1],
                          FitFinalDens[2][2]
                        ),
                   0.1..10
                 ):
  plots:-display( [ dataPoints,
                    fitCurve
                  ]
                );

 

 

 


 

Download dataFit2.mw

Regrettably I cannot check as far back as Maple 14 - there is a limit as to how many versions of Maple I can keep active on my machine :-(

These two expressions are not equivalent - missing 'minus' sign in the second one perhaps?

Even if you fix that. I'm not certain that you can ever "prefer" -1/(1-theta) to 1/(theta-1) - after all what difference does it make!!!

when using rsolve(),it is always a good idea to include "initial values" if you have them. Consider the Fibonacci series

F(n)=F(n-1)+F(n-2)

No way that anyone can calculate a value for F(n). However, if you specify F(0)=1, F(1)=1, then calculating F(n) for n>1 becomes trivial

First 116 117 118 119 120 121 122 Last Page 118 of 207