tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are replies submitted by tomleslie

@acer 

Interesting.

My (default) settings are that

  1. Tools->Options/Display/Typesetting level shows "Extended"
  2. interface(typesetting) returns "extended"

If I set Typesetting on the Tools menu to "Maple Standard", then I get the (OP-desired) answer which you gave in your original repsonse.

If I leave Typesetting on the Tools menu as "Extended", and use the command interface(typesetting=standard) in a worksheet, then Maple "locks up".

Windows Task Manager claims that the Maple process is "waiting for a response from you", although no "pop-up" or any other "response" method appears to be available.

@acer 

You appear to get a different "output format" from me when using interface(displayprecision=2) - any idea why?

You have 23333.33 - I get 2.33*104

See the attached

restart;
interface(version);

`Standard Worksheet Interface, Maple 2021.2, Windows 7, November 23 2021 Build ID 1576349`

(1)

K := evalf(Matrix(3,[1/3,-20/3,-20/3,200/3,70000/3,1.44]));

Matrix(3, 3, {(1, 1) = .3333333333, (1, 2) = -6.666666667, (1, 3) = -6.666666667, (2, 1) = 66.66666667, (2, 2) = 23333.33333, (2, 3) = 1.44, (3, 1) = 0., (3, 2) = 0., (3, 3) = 0.})

(2)

interface(displayprecision=2):
K;
interface(displayprecision=-1):

Matrix(3, 3, {(1, 1) = .33, (1, 2) = -6.67, (1, 3) = -6.67, (2, 1) = 66.67, (2, 2) = 23333.33, (2, 3) = 1.44, (3, 1) = 0., (3, 2) = 0., (3, 3) = 0.})

(3)

 

Download precProb.mw

"mimic" a stack using a DEQueue() with the associated commands push_front() and pop_front(), although this approach may(?) be "overkill" for a "simple" stack.

If you want the spannning tree for a graph then the GraphTheory:-SpanningTree() command should be used (unless you want to write your own for learning/fun purposes )

@Kitonum 

It is a "version" issue. OP's sheet works in Maple 2018, but produces the error

Error, (in depends) too many levels of recursion

in Maple 2019, Maple 2020 and Maple 2021 ;-(

@Delali Accolley 

for a couple of options

asOpt2.mw

@Nikol 

because your original question states

However, there is a problem. the resulting function f (x,y) of the surface is calculated for a long time and it is not possible to use it in NonLinearfit. My NonLinearFit does not give a result. I try to use this function as  A * f(x,y) where A is parameter

and your latest response states

This works well :
master := Lowess(<$ (5 .. 256)>, convert(qw(1, 52 - 45 .. 258), Vector), fitorder = 2, bandwidth = 0.2);
NonlinearFit(B*master(t/a), <($10..235)>, wer, t, initialvalues = [a=1], output = [parametervalues]):

So which of the two is it: "My NonLinearFit does not give a result" or "This works well" ?

Post a worksheet!

  1. Pleasse upload a worksheet using the bg green up-arrow in the Mapleprimes toolbar
  2. State more clearly your requirement. Using Lowess smoothing to fit 3-D data is essentially a numerical smoothing operation -t will not return a "closed-form symbolic" function. Using NonLinearFit() requires you to provide a parameterised a "closed-form symbolic" function and will return parameter values for the best fit. These are two very different requirements; whihc one do you want?

@pik1432 

When you write i[`1d`]  in Maple you are creating a TABLE with (so far) one indexed entry, whose index is the name '1d'.

Why are you creating a TABLE with indexable entries?

If you want to create a simple variable, whihc happens to "display" with a subscript then the correct way to do it in Maple is to use i__1d - same number of characters to type, so what is the problem with using it?

Most of the time, the distinction between a table with oine indexable entry and a simple variable won't come back to bite you in Maple - but occasionally it will!. So look forward to debugging these problems.

that the approach in my answer is the "poor man's" version of the debugger command stoperrpr(all) as originally suggested by Joe Riel.

What I suggest only allows you to examine the current "state" of the system, not to do anything more sophisticated such as reassign values and attempt to continue

@abdulganiy 

how to modify it - but I can explain exactly where your problem is. Consider the comments added to the code snippet below

	for i from 1 to 2 do
		for j from 0 to 1 by 1/5 do
		  #
		  # Notice that although values of exy and exz will be calculated
		  # for j=0, 1/5, 2/5/ 3/5 and 4/5, each of these will be
		  # overwritten - so why are they being calculated at all?
		  # On exit from this loop values of exy and exz will be those
		  # calculated when j=1.
		  #
		  # Note also that since nothing in this loop depends on the index
		  # 'i', the same values will be generated for i=1 and i=2
		  # which is unlikely to be desired behaviour
		  #
	         exy:=eval(-2*ln(cos(t[j]))):
		 exz:=eval(2*tan(t[j])):
		end do:
	   #
	   # This print statement will produce the saem value of exy and exz
	   # for both i=1 and i=2, for the resons explined in the second paragraph
	   # of the comment above
	   #
		printf("%5.2f%15.9f%15.9f%15.9f%15.9f %11.3g%11.3g%9.5g%9.5g\n", 
		h*c,res[i],res[i+2],exy,exz,abs(res[i]-exy),abs(res[i+2]-exz),
		-log[10](abs(res[i]-exy)),-log[10](abs(res[i+2]-exz))):

 

so I can't fix it - but you should consider carefully the annotations I have made in the attached code snippet

	for i from 1 to 2 do
		for j from 0 to 1 by 1/5 do
                  #
                  # Note that on exit from this loop, only values
                  # for j=1 will be used. Calculations for j=0, 
                  # j=1/5, j=2/5, j=3/5, j=4/5 will all be
                  # overwritten - so why calculate them? THIS
                  # MAKES NO SENSE
                  #
                  # Note also that nothing in this inner loop
                  # depends on the outer loop index 'i', so this inner
                  # loop will return THE SAME VALUES for i=1 and i=2
                  #
		    exy:=eval(-2*ln(cos(t[j]))):
		    exz:=eval(2*tan(t[j])):
		end do:
             #
             # This print statement will produce THE SAME VALUES of exy and exz
             # for both i=1 and i=2 - see the second paragraph of the comment above
             #
		printf("%5.2f%15.9f%15.9f%15.9f%15.9f %11.3g%11.3g%9.5g%9.5g\n", 
		h*c,res[i],res[i+2],exy,exz,abs(res[i]-exy),abs(res[i+2]-exz),
		-log[10](abs(res[i]-exy)),-log[10](abs(res[i+2]-exz))):

		err[c] := abs(evalf(res[i]-exy)):
		exy_lst[c] := 	exy:
		numerical_y1[c] := res[i]:
		c:=c+1:
	end do:

 

the following piece of code from your worksheet is a bit "strange"

	for j from 0 to 1 by 1/5 do
		exy:=eval(-2*ln(cos(t[j]))):
		exz:=eval(2*tan(t[j])):
		end do:

since on exit from exy and exz will only ever contain the last values computed, ie

eval(-2*ln(cos(t[1]))), and
eval(2*tan(t[1])):

(since I have no idea what values you consider to be" correct").

You might want to check why consecutive values in columns Ex.y and Ex.z always come in "pairs" Consider the following which I extracted from the printed output.

       Ex.y                     Ex.z    
    0.000100002    0.020000667
    0.000100002    0.020000667
    0.000400027    0.040005334
    0.000400027    0.040005334
    0.000900135    0.060018006
    0.000900135    0.060018006
    0.001600427    0.080042694
    0.001600427    0.080042694

@adel-00 

You still have the wroing number of boundary and initial conditions

Your system needs four boundary conditions and two initial conditoins

Anything else will fail

@sand15 

There is an "interesting" problem here - and it still exists in Maple 2021!

It seems to be related to the issue of how many unknowns there are in the expression to which the

convert(expression, Heaviside)

command is applied. The help page for this command states

When the input depends on more than one variable, the form positive(var) must be used to specify the variable.

So when you want to perform the conversion

convert(expression_depending_on_(x(t),d,a), Heaviside)

where x(t), d, a are all variables - then one needs to "specify the variable". However if one tries

convert(expression_depending_on_(x(t),d,a), Heaviside, positive(x(t)))

one gets the error message

Error, (in convert/Heaviside/positive) 'positive' argument must be 'positive' or 'positive'(name)

presumably because x(t) is not regarded as a "name".

The net effect of this is that (probably?)

convert(eval(expr, data), Heaviside);
eval(convert(expr, Heaviside), data);

the first command should work because the expression contains only a single variable, 'x(t)' when the Heaviside conversion is done. However the second command should not work, since the expression contains three variables when the Heaviside conversion is done.

I can only suggest that you stick with the command convert(eval(expr, data), Heaviside)

See the attached, for a more concise demonstration of the issue

  restart:
  interface(version);
  data:=[d=1.5, a=0.5]:
  expr:=piecewise(And(x(t) >= d-a, x(t) <= d+a), 1, 0);
  convert(eval(expr, data), Heaviside);
  eval(convert(expr, Heaviside), data);

`Standard Worksheet Interface, Maple 2021.2, Windows 7, November 23 2021 Build ID 1576349`

 

piecewise(And(d-a <= x(t), x(t) <= d+a), 1, 0)

 

Heaviside(1.0-x(t))*Heaviside(x(t)-2.0)-Heaviside(1.0-x(t))-Heaviside(x(t)-2.0)+1

 

-Heaviside(x(t)-1.0)+Heaviside(2.0-x(t))-Heaviside(1.0-x(t))+1

(1)

 

Download HI2.mw

First 23 24 25 26 27 28 29 Last Page 25 of 207