andmail

40 Reputation

6 Badges

11 years, 275 days

MaplePrimes Activity


These are replies submitted by andmail

@Axel Vogt Thank you again!

Bisection method is much more faster!

Function fnKepler1()

Dim t#, xl#, xu#, xold#, xr#, ea#, b As Boolean

        'tolerance
        t = 0.000000000001
        
        ea = 1
        xl = t
        xu = 1
               
        Do While ea > t
        
            xr = (xl + xu) / 2
            
            ea = Abs(xr - xold)
            
            b = xr < K1(xr)
            
            If b Then
                xl = xr
            Else
                xu = xr
            End If
            
            xold = xr
            
            Loop
        
        fnKepler1 = xr
    
End Function

Function K1(x)
With WorksheetFunction
    K1 = Sin(2 * .Pi * x)
End With
End Function

Thank you!

Here is my VBA code:

Sub Kepler()
Dim c#, xtmp#, x#, Delta#, tol#

    'constant
    c = 2

    'tolerance
    tol = 0.0001

    'variable start value
    x = tol * 2

    Do While x <= 1

        xtmp = Sin(c * x)

        Delta = Abs(xtmp - x)

        If Delta < tol Then Exit Do

        x = x + tol

        Loop

End Sub

Thank you.

Hope Maple will fix the bug.

Press right mouse button inside narrow window to get a normal size of code-edit window

@Rouben Rostamian  Thank you for your help!

I created 2 functions to get the input list of lists from the detail() function:
 

_local(D)

with(geometry)

b := 2

h := 1

square(sq1, [point(A, 0, 0), point(B, b, 0), point(C, b, h), point(D, 0, h)])

polygonArea := proc (L) local i, n; n := nops(L); add(-L[i+1][1]*L[i][2]+L[i+1][2]*L[i][1], i = 1 .. n-1)+L[n][1]*L[1][2]-L[n][2]*L[1][1]; return %*(1/2) end proc; polygonVertices := proc (obj) local t, f, attr; global `geom2d/given`; attr := [attributes(obj)]; if 0 < nops(attr) then attr := attr[1] else return FAIL end if; if type(attr, 'table') then t := attr[`geom2d/form`]; f := attr[`geom2d/given`]; if member(t, {'polygon2d', 'square2d', 'triangle2d', 'RegularPolygon2d', 'RegularStarPolygon2d'}) then f else FAIL end if else FAIL end if end proc; polygonPoints := proc (obj) local i, f; if type(obj, 'list') then for i to nops(obj) do f[i] := [geometry:-HorizontalCoord(obj[i]), geometry:-VerticalCoord(obj[i])] end do; convert(f, list) else FAIL end if end proc

``

polygonArea(polygonPoints(polygonVertices(sq1)))

2

(1)

draw([sq1, A(printtext = true), B(printtext = true), C(printtext = true), D(printtext = true)])

 

NULL

``

``


 

Download GeometryAreaTest2.mw

 

@Kitonum thank you for your reply.

I use the centroid() function for my rectangular squares in my work. It returns the correct result. It would be great if Maple will upgrade the squares to rectangles (I mean the area() function) :)

@tomleslie 

My libname path should look like this: 

libname := ( libname,
"D:/Temp/MTest/libTest2.mla"
);

libname := "C:\Program Files\Maple 2015\lib", ".", "D:/Temp/MTest/libTest2.mla"

Now there is no errors any more. Thank you once again!

@tomleslie 

You're absolutly right!

I was using with(Units[Standard]) in startup code.

In Maple Help I found this: 

The with(Units[Standard]) command does not allow the use of the short form of the Units package commands that customize the dimensions, units, and systems of units. It is necessary to enter the with(Units) command. For a list of the commands in the Units package, see Units.

Perhaps it is a mistake?

Using with(Units) does not cause this error, but another error appeares


with(Units):

#
# Reset the libname variable to include the library
# created earlier. Obviously OP will have to change
# file path/name to correspond to that supplied above
#
  libname :=  "D:\\TEMP\\MTest\\libTest2.mla";

"D:\TEMP\MTest\libTest2.mla"

(1)

#
# Check that variables now exist and can be used in sums
#
# Everything seems to be working!!
#
  A__1;
  A1;
  5*A__1+3*A1;

2*Units:-Unit('m')

 

Units:-Unit('m')

 

13*Units:-Unit('m')

(2)

B:=A__1*A1

2*Units:-Unit('m')^2

(3)

B

Error, (in Units:-Unit) unrecognized conversion

 


Download unitsLibs_read.mw

 

Thank you for quick reply

but...

Maple 17 x64. Very strange, isn't it?

Thank you for quick reply

but...

Maple 17 x64. Very strange, isn't it?

Page 1 of 1