English
Source / code snippets

Gradientenabstieg: Newton-Raphson in 2 Dimensionen

 

p.specht

the Newton-Raphson-take action functions too with functions in 2 Dimensionen, speak: z =Z(x,y). unfortunately is the take action insofern sooner demanding, as The undertow. partiellen Ableitungen the known function (to x and to y) ditto famous his should. with not too complicated Formeln ought to the but weg. lying though only numbers / Datensätze, z.B. with Messwerten over 2 Dimensionen to, then recommend itself others, mere numerische take action, z.B. Nelder-Mead udgl.

Info: The here einprogrammierten functions get chosen, around the Auswirkungen the heiklen electoral the Startpunktes the Result darzustellen.
Window Title "Gradientenabstieg (Newtonverfahren in 2 Dimensionen)"
AppendMenuBar 100,"Geg.: Z(x,y)=(x+sin(y))*exp(-sqr(x)*-sqr(y)) Ges.: place the local Minimus"
Window 0,0-%maxx,%maxy-40:font 2
declare z!,x!,y!,xh&,yh&,f!,g!,s!
xh&=width(%hwnd)\2:yh&=height(%hwnd)\2
g!=1.5:s!=0.1:f!=220

proc Z :parameters x!,y!

    return (x!+sin(y!))*exp(-sqr(x!)-sqr(y!))

endproc

proc dZdx :parameters x!,y!

    return exp(-sqr(y!)-sqr(x!))*(1-2*x!*(x!+sin(y!)))

endproc

proc dZdy :parameters x!,y!

    return exp(-sqr(y!)-sqr(x!))*(cos(y!)-2*y!*(x!+sin(y!)))

endproc

' ------ Z-area present ----
cls
x!=-g!:Repeat
y!=-g!:While y!<=g!
z!=Z(x!,y!)
usepen 0,7+7*z!,rgb(0,0,400*z!)
line xh&+x!*f!+z!*7,(yh&-y!*f!-z!*11) - xh&+x!*f!,yh&-y!*f!
y!=y!+s!:endwhile
x!=x!+s!:until x!>=g!
'-------------------------------------------------------
' Gradientenabstieg
'-------------------------------------------------------
declare gstep!,xx!,yy!,xxo!,yyo!,dx!,dy!,dz!,eps!,n&,xxx!,yyy!
gstep!=0.15

whileloop   50,-50,-5:yyy!=&Loop/50

    whileloop -50,50,5 :xxx!=&Loop/30

        xx!=xxx!
        yy!=yyy!'Startpunkt
        n&=0

        REPEAT

            dx!=dZdx(xx!,yy!)
            dy!=dZdy(xx!,yy!)
            xxo!=xx!:yyo!=yy!
            xx!=xx!-dx!*gstep!
            yy!=yy!-dy!*gstep!
            usepen 0,4,rgb(255,0,0)
            line xh&+xx!*f!,(yh&-yy!*f!)-xh&+xx!*f!,yh&-yy!*f!
            locate 2,2:print xx!,yy!,Z(xx!,yy!),n&;"   "
            inc n&

        UNTIL ((xx!=xxo!) and (yy!=yyo!)) or (n&>=250)

    WEND

WEND

beep
waitinput
End
 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/28/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.300 Views

Untitledvor 0 min.
p.specht11/21/21
R.Schneider11/20/21
Uwe Lang11/20/21
Manfred Barei11/19/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie