Abt. Linkempfehlungen zu 'Modellbildung und System-Simulation'
-------------------------------------------------------------------------
1. J-P. Moreau's Homepage für Numerisch-mathematische Algorithmen (Engl.,
super!!!)
http://jean-pierre.moreau.pagesperso-orange.fr/ (Schade daß ich das erst heute gefunden habe!)
2. Google Code Developers bietet umfangreiche Sourcen in vielen Sprachen
https://code.google.com/
Visual Basic-Beispiel: LZ4 superfast lossless Compression Algorithmus
https://code.google.com/p/lz4/
3. Walter Hupfelds GPL-Software "MODSIM: Modellbildung und Simulation dynamischer Systeme". Software: Modellbildungswerkzeuge
Google-Code Projekt Dynasis dazu: https://code.google.com/p/dynasys/
Theorie: http://modsim.hupfeld-software.de/pmwiki/pmwiki.php
Gruss
Algorithmen Teil VII: Das andere Müllspiel!
-
p. specht -
21. September 2013 um 23:54 -
Geschlossen
-
-
- Gerade eben
- Anzeige
Hallo!
Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.
- ✔️ Schnelle Ladezeiten (optimiert für WordPress, WoltLab & Co.)
- ✔️ Deutsche Server & DSGVO-konform
- ✔️ Persönlicher Support (kein 0815-Ticket-System)
-
Abt. Einen Näherungsbruch finden
=====================
Die Zahl Pi kann mit 22/7 auf knapp drei Kommastellen genau gemerkt werden - für Berechnungen in Haus und Hof reicht das völlig. Mit 333/106-stel könnten auch Brückenbauer schon etwas anfangen. Und mit 140/99-stel für Wurzel-aus-2 ist man für praktische Zwecke auch bereits sehr gut bedient.Ein Programm, daß für beliebige Kommazahlen im "normalen" Wertebereich (also ohne allzu starke Stellenexponenten 10^...) prüft, ob man sie sich mit Brüchen nicht leichter merken könnte, ist deshalb vielleicht nicht uninteressant. Meine Alpha Version (ohne jedwede Gewähr) findet sich nachstehend.
GrussP.S.: Im letzten EDIT kamen bekannte mathematische Konstanten als Def dazu. Nach Eingabe der Nenner-Stellenzahl wird die vom User selbst einzuprogrammierende Zahl mittels "#" in der Input-Zeile als Wert aufgerufen.
Code
Alles anzeigenWindowTitle "N Ä H E R U N G S B R U C H S U C H E N - ALPHA-VERSION!!!!!" '(CL) CopyLeft 2014-05 by P.Specht, Wien. Keine wie auch immer geartete Gewähr! Def !Pi 3.1415926535897932384626433832795 Def !PiDiv180 0.01745329251994329576923690768489 Def !Div180Pi 57.295779513082320876798154814105 Def !Euler 2.7182818284590452353602874713527 Def !Root2 1.4142135623730950488016887242097 Def !Root3 1.7320508075688772935274463415059 Def !RootPi 1.7724538509055160272981674833411 Def !Root5 2.2360679774997896964091736687313 Def !GoldenRatio 1.6180339887498948482045868343656 Def !Ln10 2.3025850929940456840179914546844 Def !Ln2 0.69314718055994530941723212145818 Def !Lb10 3.3219280948873623478703194294894 Def !LbE 3.921651713656448480581438480269 Def !LLE 1.4426950408889634073599246810019 Def !Log2 0.30102999566398119521373889472449 Def !LogE 0.43429448190325182765112891891661 Def !EulerMasc 0.5772156649015328606065120900824024310 Def !Lemniskat 2.62205755429211981046 Def !Sirpinski 2.58498175957925321706 Def !PrimZwill 0.66016181584686957392 Def !SumRezipPrimZwill 1.902160583209 Def !Feigbm1 4.66920160910299067185 Def !Feigbm2 2.50290787509589282228 Def !Fibon 0.29762917531599816807398825978458 Def !RezipFibon 3.3598856662431775531720113029189 Def !ErdGrav 9.80665 Def !Div60 0.01666666666666666666666666666667 Def !Div360 0.00277777777777777777777777777778 Def !Div3600 0.000277777777777777777777777777778 Def !Div24 0.04166666666666666666666666666667 Def !DivPi 0.31830988618379067153776752674503 Def !SecPerDay 86400 Def !DayPerSec 0.000011574074074074074074074074074074 Def !Div1a 0.999999999999999999999999999999 Def !Div2a 0.444444444444444444444444444444 Def !Div2 0.5 Def !Div3 0.33333333333333333333333333333333 Def !Div4 0.25 Def !Div5 0.2 Def !Div6 0.16666666666666666666666666666667 Def !Div7 0.14285714285714285714285714285714 Def !Div8 0.125 Def !Div9 0.11111111111111111111111111111111 Def !Div10 0.1 Def !Div11 0.09090909090909090909090909090909 Def !Div12 0.08333333333333333333333333333333 Def !Div13 0.07692307692307692307692307692308 Def !Div14 0.07142857142857142857142857142857 Def !Div15 0.06666666666666666666666666666667 Def !Div16 0.0625 Def !Div17 0.05882352941176470588235294117647 Def !Div18 0.05555555555555555555555555555556 Def !Div19 0.05263157894736842105263157894737 Def !Div20 0.05 Def !DivHdt 0.01 Def !DivTsd 0.001 Def !DivZTsd 0.0001 Def !DivHTsd 0.00001 Def !DivMio 0.000001 Def !DivMrd 0.000000001 windowstyle 24:window 0,0-%maxx/2,%maxy-40:set("decimals",17):font 2 declare c$,st&,z!,tol!,err!,z&,n&,v!,w!,err_!,n_&,z_&,x&,y&,sn&,tm& nochmal: cls:print "\n\n Wieviele STELLEN darf der NENNER maximal haben (max.~6): "; input c$:case c$>"":st&=abs(val(c$)):case st&=0:st&=1:case st&>9:st&=9 ein: print "\n Wie lautet ihre KOMMAZAHL ? (*=Pi,°=sqrt(2),#=Konstante): "; input c$:case c$>"":v!=val(c$) case c$="*":v!=pi():case c$="°":v!=sqrt(2) case c$="°":v!=sqrt(2) '-------------------------------------------------------------------------- case lower$(c$)="#":v!=0.001001001001001001001001001001 '-------------------------------------------------------------------------- if v!=0:print " Scherz, oder? ":sound 200,100:locate 4,1:goto "ein":endif CLS print "\n Sollwert: ";sn&*v!;"\n":err_!=10^53:n&=1:sn&=1 if v!<0:v!=abs(v!):sn&=-1:endif if v!>=1:z&=10^(lg(v!)) elseif v!<1:n&=int(10^(-1*lg(v!))) endif while n&<(10^st&) w!=z&/n&:err!=v!-w! if abs(err!)<err_!:err_!=abs(err!):z_&=z&:n_&=n& print " ";int(sn&*z&);" / ";n&;" = ";w!;tab(48);"Abs.Fehler = ";abs(err!);" " endif if err!>0:inc z& elseif err!<0:dec z&:inc n& else :BREAK endif if (&gettickcount-tm&)>2000 case %csrlin>42:cls'locate 4,1 x&=%csrlin:y&=%pos:locate 2,1 print " Sollwert: ";sn&*v!;" Zwischenstand: ";int(sn&*z&);" / ";n&," "; locate x&,y&:tm&=&gettickcount waitinput 1 endif endwhile print mkstr$("-",77):beep print " Ihr gesuchter Wert ";sn&*v!;" wird bei max. ";st&;"-stelligem Nenner " print " durch den Bruch ";int(sn&*z_&);" / ";n_&; if err_!<>0:print " bestmöglich angenähert!" else :print " exakt dargestellt!" endif print mkstr$("-",77) print "\n Nochmal? [n,N =Ende]: ";:input c$ casenot left$(trim$(lower$(c$)),1)="n":goto "nochmal" END -
Abt. Gutmütige Differentialgleichungssysteme genau lösen
====================================
kann man z.B. mit dem Runge Kutta Fehlberg -Algorithmus (RKF45). Das Verfahren nutzt Schrittweitensteuerung nach dem Deutschen Mathematiker Erwin Fehlberg [Fehlberg 1970], und schafft durch Nutzung von XProfan's Double-Precision Arithmetik eine Genauigkeit von immerhin fünf Kommastellen, was bei expliziten Verfahren absolut nicht selbstverständlich ist!
Bei sog. "steifen" (= widerspenstigen) Problemen wird die Sache allerdings sehr sehr langsam, dazu gibt es dann bessere Verfahren, etwa nach dem Prädiktor-Korrektor-Prinzip. Dazu vielleicht ein andermal.ZitatMeine Damen und Herren, ich darf hier ein von Algol nach Fortran über QBasic nach C++ nach Pascal nach XProfan 11.2a übersetzts Gustostück der Numerischen Mathematik präsentieren, mit dem z.B. ein in den ersten 20 Sekunden realistisches Doppelpendel-Verhalten berechnet werden könnte (Leider nicht in Echtzeit, und nach 20 Sekunden etwa schlägt die Chaostheorie mit ihrem Schmetterlingseffekt voll zu
).
GrussEs folgen drei weitere Teile dieses Beitrags, für die wie immer gilt: Keine Gewähr!
-
TEIL 1:
Code
Alles anzeigenRUNGE KUTTA der Ordnung 4 mit Schrittweitensteuerung der Ordnung 5 nach FEHLBERG" '*********************************************************************** '* (DEMO ONLY!) 2014-05 Transcribed to XProfan 11 by P.Specht, Vienna * '* ALL COPYRIGHTS BY THE RESPECTIVE OWNERS! RECHTE DRITTER BEACHTEN! * '*********************************************************************** '* Integrate a System of Ordinary Differential Equations By the * '* Runge-Kutta-Fehlberg method (double precision) * '* ------------------------------------------------------------------- * '* REFERENCE: H A Watts and L F Shampine, * '* Sandia Laboratories, * '* Albuquerque, New Mexico. * '* ------------------------------------------------------------------- * '* SAMPLE RUN: * '* * '* PROGRAM TRKF45 * '* Demonstrate the RKF45 ODE integrator. * '* * '* TEST01 * '* Solve a scalar equation: * '* * '* Y' = 0.25 * Y * ( 1 - Y / 20 ) * '* * '* T Y Y_Exact Error * '* * '* 0.00000 1.00000 1.00000 0.0000000 * '* 4.00000 2.50321 2.50322 -0.0000087 * '* 8.00000 5.60007 5.60009 -0.0000193 * '* 12.00000 10.27774 10.27773 -0.0000069 * '* 16.00000 14.83682 14.83683 -0.0000038 * '* 20.00000 17.73017 17.73017 -0.0000084 * '* * '* TEST02 * '* Solve a vector equation: * '* * '* Y'(1) = Y(2) * '* Y'(2) = - Y(1) * '* * '* T Y1 Y2 * '* * '* 0.00000 1.00000 0.00000 * '* 0.52360 0.86603 -0.50000 * '* 1.04720 0.50000 -0.86603 * '* 1.57080 0.00000 -1.00000 * '* 2.09440 -0.50000 -0.86603 * '* 2.61799 -0.86603 -0.50000 * '* 3.14159 -1.00000 -0.00000 * '* 3.66519 -0.86603 0.50000 * '* 4.18879 -0.50000 0.86603 * '* 4.71239 -0.00000 1.00001 * '* 5.23599 0.50000 0.86604 * '* 5.75959 0.86604 0.50001 * '* 6.28319 1.00002 0.00000 * '* * '* TEST03 * '* Solve a vector equation: * '* * '* Y'(1) = Y(2) * '* Y'(2) = Y(3) * '* Y'(3) = Y(4) * '* Y'(4) = Y(5) * '* Y'(5) = (45 * Y(3) * Y(4) * Y(5) - 40 * Y(4)^3) / (9 * Y(3)^2) * '* * '* T Y1 Y2 Y3 Y4 Y5 * '* * '* 0.00000 1.00000 1.00000 1.00000 1.00000 1.00000 * '* 0.13636 1.14610 1.14609 1.14587 1.14068 1.05604 * '* 0.27273 1.31354 1.31340 1.31128 1.28532 1.05248 * '* 0.40909 1.50538 1.50460 1.49612 1.42333 0.95209 * '* 0.54545 1.72508 1.72223 1.69844 1.53859 0.71111 * '* 0.68182 1.97638 1.96840 1.91370 1.60897 0.28809 * '* 0.81818 2.26328 2.24438 2.13400 1.60781 -0.33918 * '* 0.95455 2.58984 2.55011 2.34770 1.50801 -1.15027 * '* 1.09091 2.96003 2.88369 2.53985 1.28946 -2.06094 * '* 1.22727 3.37739 3.24105 2.69376 0.94820 -2.92046 * '* 1.36364 3.84475 3.61589 2.79372 0.50379 -3.54302 * '* 1.50000 4.36396 4.00000 2.82843 -0.00000 -3.77124 * '* ------------------------------------------------------------------- * '* * '* Basic Release 1.1 by J-P Moreau, Paris. * '* (www.jpmoreau.fr) * '* Release 1.1: added test #3. * '*********************************************************************** '* Source: Homepg. of J-P. Moreau: DIFFERENTIAL EQUATIONS IN BASIC.htm * '* ------------------------------------------------------------------- * '* All Copyrights (C) 2014- are attributed to their respective Owners * '*********************************************************************** Windowstyle 24:randomize:font 2 Window 0,0-%maxx,%maxy-40:cls co() var xx&=width(%hwnd)\2:var yy&=height(%hwnd)\2 set("decimals",17):set("numwidth",24) proc co return rgb(200+rnd(56),200+rnd(56),200+rnd(56)) endproc Declare R$,num&,neqn&,F$,G$,yexact!,istep&,t!,remin!,maxnfe&,eps! declare mflag&,jflag&,kflag&,savr!,save!,rer!,dt!,init&,kop&,a!,b! declare h!,i&,k&,nfe&,toln!,tol!,ypk!,tmp!,ep!,IA&,IB&,ISign&,sign! declare kop!,IOUTPUT&,scale!,ae!,IHFAILD&,hmin!,ch! declare eedet!,eeoet!,et!,ee!,eecet!,xmax!,esttol!,s! var abserr! = 0.000001 var relerr! = 0.000001 var iflag& = 1 var tstart! = 0.0 var tstop! = 20.0 var nstep& = 5 var tout! = 0 var tt! = tout! var NEQ& = 5 ' Maximum number of equations def !Pi Pi() var EPSILON! = val("2.22E-16") ' Small number Declare y![NEQ&], yp![NEQ&] 'auxiliary variables used by 400 Declare yy![NEQ&], yyp![NEQ&] 'work space used by successive calls to 1000 and 2000 Declare f1![NEQ&], f2![NEQ&], f3![NEQ&], f4![NEQ&], f5![NEQ&] F$ = "%g" '"####0.0########" G$ = "%g" '"####0.0##############" CLS co() PRINT "\n PROGRAM RKF45 AND TRKF45 FOR TESTING RKF45 \n\n" PRINT " Demonstrates the RKF45 ODE integrator\n" 'call test01 S600 Print "\n Press any key to continue... ",:beep:Waitinput:cls co() 'call test02 S700 Print "\n Press any key to continue... ",:beep:Waitinput:cls co() 'call test03 S800 Print "\n Press ENTER to end the PGM. ",:beep:Input R$ END 'of Main Pgm S400: '{ User defined system of Differential Equations ' Subroutine S400f :parameters tt!, yy!, yyp! '-------------------------------------------------------------------- ' Fn evaluates the derivative for the ODE (TESTS #1 and #2). '-------------------------------------------------------------------- IF num& = 1 ' Test-No. yyp![1] = 0.25 * yy![1] * (1.0 - yy![1]/20.0) ELSEIF num& = 2 yyp![1] = yy![2] yyp![2] = -1*yy![1] ELSE yyp![1] = yy![2] yyp![2] = yy![3] yyp![3] = yy![4] yyp![4] = yy![5] yyp![5] = (45*yy![3]*yy![4]*yy![5] - 40*yy![4]*sqr(yy![4])) / (9*sqr(yy![3])) ENDIF RETURN
weitere Teile folgen. -
TEIL 2:
Code
Alles anzeigenS500: '-------------------------------------------------------------------- ' function yexact(tt) ' YEXACT evaluates the exact solution of the ODE (For TEST #1). '-------------------------------------------------------------------- yexact! = 20/(1+19*EXP(-0.25*tt!)) RETURN '} proc S600 '-------------------------------------------------------------------- ' TEST01 solves a scalar ODE in double precision. '-------------------------------------------------------------------- num& = 1 'example #1 neqn& = 1 'one equation PRINT " TEST01 \n\n" PRINT " Solve a scalar equation:" PRINT PRINT " Y' = 0.25 * Y * ( 1 - Y / 20 )\n\n" PRINT abserr! = .000001 relerr! = .000001 iflag& = 1 tstart! = 0.0 tstop! = 20.0 nstep& = 5 tout! = 0 y![1] = 1 PRINT " T Y Y_Exact Error " PRINT tt! = tout!: GOSUB "S500" 'calculate yexact(tout) PRINT " ";format$(F$, tout!), PRINT tab(26);format$(F$,y![1]), PRINT tab(52);format$(F$,yexact!), PRINT tab(77);format$(G$,y![1] - yexact!) Whileloop nstep& : istep&=&Loop t! = ((nstep& - istep& + 1) * tstart! + (istep& - 1) * tstop!) / nstep& tout! = ((nstep& - istep&) * tstart! + (istep&) * tstop!) / nstep& 'Bracket error in French source corrected! 'call rkfs (neqn,y,t,tout,relerr,abserr,iflag,yp,h,f1..f5,savr,save,nfe,kop,init,jflag,kflag) GOSUB "S2000" tt! = tout! GOSUB "S500" ' calculate yexact(tout) PRINT " ";format$(F$, tout!), PRINT tab(26);format$(F$, y![1]), PRINT tab(52);format$(F$, yexact!), PRINT tab(77);format$(G$, y![1] - yexact!) endwhile endproc Proc S700 '-------------------------------------------------------------------- ' TEST02 solves a vector ODE (Ordinary Differential Equation) '-------------------------------------------------------------------- num& = 2 'Example #2 neqn& = 2 '2 equations PRINT PRINT " TEST02\n" PRINT " Solve a vector equation:" PRINT PRINT " Y'(1) = Y(2)" PRINT " Y'(2) = - Y(1)\n\n" abserr! = 0.000001 relerr! = 0.000001 iflag& = 1 tstart! = 0 tstop! = 2*PI() nstep& = 12 tout! = 0 y![1] = 1 y![2] = 0 PRINT PRINT " T Y1 Y2 " PRINT PRINT " ";format$(F$, tout!), PRINT tab(26);format$(F$, y![1]), PRINT tab(52);format$(F$, y![2]) Whileloop nstep& istep&=&Loop t! = ((nstep& - istep& + 1) * tstart! + (istep& - 1) * tstop!) / nstep& tout! = ((nstep& - istep&) * tstart! + (istep& * tstop!)) / nstep& ') GOSUB "S2000" 'call rkfs (neqn,y,t,tout,relerr,abserr,iflag,yp,h,f1..f5,savr,save, 'nfe,kop,init,jflag,kflag) PRINT " ";format$(F$, tout!), PRINT tab(26);format$(F$,y![1]), PRINT tab(52);format$(F$,y![2]) endwhile EndProc Proc S800 '-------------------------------------------------------------------- ' TEST03 solves a vector ODE. '-------------------------------------------------------------------- num& = 3 'Example #3 neqn& = 5 '5 equations PRINT "\n TEST03 \n" PRINT " Solve a vector equation: \n" PRINT " Y'(1) = Y(2)" PRINT " Y'(2) = Y(3)" PRINT " Y'(3) = Y(4)" PRINT " Y'(4) = Y(5)" PRINT " Y'(5) = (45 * Y(3) * Y(4) * Y(5) - 40 * Y(4)^3) / (9 * Y(3)^2) \n" abserr! = .000001 relerr! = .000001 iflag& = 1 tstart! = 0 tstop! = 1.5 nstep& = 11 tout! = 0 y![1] = 1 y![2] = 1 y![3] = 1 y![4] = 1 y![5] = 1 PRINT "\n T Y1 Y2 Y3 Y4 Y5 \n" PRINT " ";format$(F$,tout!); PRINT tab(26);format$(F$,y![1]); PRINT tab(52);format$(F$,y![2]); PRINT tab(77);format$(F$,y![3]); PRINT tab(104);format$(F$,y![4]); PRINT tab(130);format$(F$,y![5]) Whileloop nstep& istep&=&Loop t! = ((nstep& - istep& + 1) * tstart! + (istep& - 1) * tstop!) / nstep& tout! = ((nstep& - istep&) * tstart! + (istep& * tstop!) / nstep&) GOSUB "S2000" 'call rkfs (neqn,y,t,tout,relerr,abserr,iflag,yp,h,f1..f5,savr,save,nfe,kop,init,jflag,kflag) PRINT " ";format$(F$,tout!); PRINT tab(26);format$(F$,y![1]); PRINT tab(52);format$(F$,y![2]); PRINT tab(77);format$(F$,y![3]); PRINT tab(104);format$(F$,y![4]); PRINT tab(130);format$(F$,y![5]) Endwhile EndProc
Weiterer Teil folgt! -
TEIL 3 (Letzter Teil) von 3:
Code
Alles anzeigen'{* Differential Equations By the Runge-Kutta-Fehlberg method (double precision) S1000: 'Subroutine fehl(neqn, y, t, h, yp, f1, f2, f3, f4, f5, s) ch! = h! / 4 whileloop neqn&:i&=&Loop f5![i&] = y![i&] + ch! * yp![i&] endwhile tt! = t! + ch! whileloop neqn&:i&=&Loop yy![i&] = f5![i&] endwhile GOSUB "S400" 'call f(t+ch, f5, f1) whileloop neqn&:i&=&Loop f1![i&] = yyp![i&] endwhile ch! = 3*h!/32 whileloop neqn&:i&=&Loop f5![i&] = y![i&] + ch! * (yp![i&] + 3 * f1![i&]) endwhile tt! = t!+3*h!/8 whileloop neqn&:i&=&Loop yy![i&] = f5![i&] endwhile GOSUB "S400" ' call f(t+3*h/8, f5, f2) whileloop neqn&:i&=&Loop f2![i&] = yyp![i&] endwhile ch! = h!/2197 whileloop neqn&:i&=&Loop f5![i&] = y![i&] + ch! * (1932 * yp![i&] + (7296 * f2![i&] - 7200 * f1![i&])) endwhile tt! = t!+12*h!/13 whileloop neqn&:i&=&Loop yy![i&] = f5![i&] endwhile GOSUB "S400" 'call f(t+12#*h/13#, f5, f3) whileloop neqn&:i&=&Loop f3![i&] = yyp![i&] endwhile ch! = h!/4104 whileloop neqn&:i&=&Loop f5![i&] = y![i&] + ch! * ((8341 * yp![i&] - 845 * f3![i&]) + (29440 * f2![i&] - 32832 * f1![i&])) endwhile tt! = t! + h! whileloop neqn&:i&=&Loop yy![i&] = f5![i&] endwhile GOSUB "S400" 'call f(t+h, f5, f4) whileloop neqn&:i&=&Loop f4![i&] = yyp![i&] endwhile ch! = h!/20520 whileloop neqn&:i&=&Loop tmp! = (41040 * f1![i&] - 28352 * f2![i&]) f1![i&] = y![i&] + ch! * ((-6080 * yp![i&] + (9295 * f3![i&] - 5643 * f4![i&])) + tmp!) endwhile tt! = t!+h!/2 whileloop neqn&:i&=&Loop yy![i&] = f1![i&] endwhile GOSUB "S400" 'call f(t+h/2#, f1, f5) whileloop neqn&:i&=&Loop f5![i&] = yyp![i&] endwhile ch! = h! / 7618050 whileloop neqn&:i&=&Loop tmp! = (3953664 * f2![i&] + 277020 * f5![i&]) f1![i&] = y![i&] + ch! * ((902880 * yp![i&] + (3855735 * f3![i&] - 1371249 * f4![i&])) + tmp!) endwhile RETURN S1200: IF ib& < 0 : ISign& = -ABS(ia&) ELSE : ISign& = ABS(ia&) ENDIF RETURN S1210: IF b!<0 :Sign! = -1*ABS(a!) ELSE :Sign! = ABS(a!) ENDIF RETURN S1300: IF a!>=b!:XMax! = a! ELSE :XMax! = b! ENDIF RETURN S1310: IF a!<=b!:XMIN! = a! ELSE :XMIN! = b! ENDIF RETURN '} S2000: '{Subroutine rkfs(neqn, y, t, tout, relerr, abserr, iflag, yp, h, f1, f2, f3, f4,f5, ' savr, save, nfe, kop, init, jflag, kflag) '*************************************************************************************** ' RKFS implements the Runge-Kutta-Fehlberg method (double precision). '*************************************************************************************** ' Labels: 25,40,45,50,60,65,80,100,200,260 remin! = .000000000001 maxnfe& = 3000 eps! = EPSILON! IF neqn& < 1:iflag& = 8:RETURN ENDIF IF relerr! < 0:iflag& = 8:RETURN ENDIF IF abserr! < 0:iflag& = 8:RETURN ENDIF mflag& = ABS(iflag&) IF (ABS(iflag&) < 1) OR (ABS(iflag&) > 8) iflag& = 8 RETURN ENDIF case mflag& = 1 : GOTO "G50" IF (t! = tout!) AND (kflag& <> 3) iflag& = 8 RETURN ENDIF Case mflag& <> 2 : GOTO "G25" Case kflag& = 3 : GOTO "G45" Case init& = 0 : GOTO "G45" Case kflag& = 4 : GOTO "G40" Case (kflag& = 5) AND (abserr! = 0): END Case (kflag& = 6) AND (relerr! <= savr!) AND (abserr! <= save!): END GOTO "G50" ' iflag = 3,4,5,6,7 or 8 G25: Case iflag& = 3 : GOTO "G45" Case iflag& = 4 : GOTO "G40" Case (iflag& = 5) AND (abserr > 0) : GOTO "G45" END G40: nfe& = 0 Case mflag& = 2 : GOTO "G50" G45: iflag& = jflag& Case kflag& = 3 : mflag& = ABS(iflag&) G50: jflag& = iflag& kflag& = 0 savr! = relerr! save! = abserr! rer! = 2 * EPSILON! + remin! IF relerr! < rer! relerr! = rer! iflag& = 3 kflag& = 3 RETURN ENDIF dt! = tout! - t! Case mflag& = 1 : GOTO "G60" Case init& = 0 : GOTO "G65" GOTO "G80" G60: init& = 0 kop& = 0 a! = t! whileloop neqn&:i&=&Loop yy![i&] = y![i&] endwhile GOSUB "S400" 'call f(a, y, yp) whileloop neqn&:i&=&Loop yp![i&] = yyp![i&] endwhile nfe& = 1 IF t! = tout! : iflag& = 2 : RETURN ENDIF G65: init& = 1 h! = ABS(dt!) toln! = 0 whileloop neqn&:k&=&Loop tol! = relerr! * ABS(y![k&]) + abserr! IF tol! > 0 toln! = tol! ypk! = ABS(yp![k&]) IF (ypk!*h!^5) > tol! h! = (tol! / ypk!)^0.2 ENDIF ENDIF endwhile case toln! <= 0 : h! = 0 IF ABS(t!) > ABS(dt!) : tmp! = ABS(t!) ELSE : tmp! = ABS(dt!) ENDIF IF h! < (26 * ep! * tmp!) : h! = 26 * eps! * tmp! ENDIF ia& = 2: ib& = iflag&: GOSUB "S1200" jflag& = ISign& G80: a! = h!: b! = dt!: GOSUB "S1210" h! = Sign! Case ABS(h!) >= (2*ABS(dt!)): kop& = kop& + 1 IF kop! = 100 kop! = 0 iflag& = 7 RETURN ENDIF IF ABS(dt!) <= (26 * eps! * ABS(t!)) WhileLoop neqn&:i&=&Loop y![i&] = y![i&] + dt! * yp![i&] Endwhile a! = tout! WhileLoop neqn&:i&=&Loop yy(i) = y(i) endwhile GOSUB "S400" 'call f(a, y, yp) WhileLoop neqn&:i&=&Loop yp![i&] = yyp![i&] endwhile nfe& = nfe& + 1 t! = tout! iflag! = 2 RETURN ENDIF ioutput& = 0 scale! = 2 / relerr! ae! = scale! * abserr! G100: ihfaild& = 0 hmin! = 26 * eps! * ABS(t!) dt! = tout! - t! Case ABS(dt!) >= (2 * ABS(h!)) : GOTO "G200" IF ABS(dt!) <= ABS(h!) ioutput& = 1 h! = dt! GOTO "G200" ENDIF h! = 0.5 * dt! 'reduce step G200: IF nfe& > maxnfe& iflag& = 4 kflag& = 4 RETURN ENDIF GOSUB "S1000" 'call fehl(neqn, y, t, h, yp, f1, f2, f3, f4, f5, f1) nfe& = nfe& + 5 eeoet! = 0 Whileloop neqn&:k&=&Loop et! = ABS(y![k&]) + ABS(f1![k&]) + ae! IF et! <= 0 iflag& = 5 RETURN ENDIF tmp! = (22528 * f2![k&] - 27360 * f5![k&]) ee! = ABS((-2090 * yp![k&] + (21970 * f3![k&] - 15048 * f4![k&])) + tmp!) a! = eecet!: b! = ee! / et!: GOSUB "S1300" eecet! = XMax! endwhile esttol! = ABS(h!) * eeoet! * scale! / 752400 Case esttol! <= 1 : GOTO "G260" ihfaild& = 1 ioutput& = 0 IF esttol! < 59049 s! = 0.9 / (esttol!^0.2) ELSE s! = 0.1 ENDIF h! = s! * h! IF ABS(h!) < hmin! iflag& = 6 kflag& = 6 RETURN ELSE GOTO "G200" ENDIF G260: t! = t! + h! whileloop neqn&:i&=&Loop y![i&] = f1![i&] endwhile a! = t! whileloop neqn&:i&=&Loop yy![i&] = y![i&] endwhile GOSUB "S400" ' call f(a, y, yp) whileloop neqn&:i&=&Loop yp![i&] = yyp![i&] endwhile nfe& = nfe& + 1 IF esttol! > .0001889568 s! = 0.9/esttol^0.2 ELSE s! = 5 ENDIF IF ihfaild& <> 0 a! = s!: b! = 1: GOSUB "S1310": s! = XMIN! ENDIF a! = s! * ABS(h!): b! = hmin!: GOSUB "S1300" a! = XMax!: b! = h!: GOSUB "S1210": h! = Sign! IF ioutput& <> 0 t! = tout! iflag& = 2 ENDIF Case iflag& > 0 : GOTO "G100" iflag& = -2 RETURN '}P.S.: Die 3 Teile müssen natürlich in ein einziges Programm zusammengeführt werden!
-
Abt. Kurvige Dame
============
Weil Google sie heute gerade mit einem Doodle ehrte: Hier die XProfan-Kurven der Maria Gaetana Agnesi, der Nachwelt zur Freude.
GrussP.S.: In der Physik auch Cauchy-Lorentz-Verteilung genannt, die u.a. die Form von Spektrallinien beschreibt...
Code
Alles anzeigenwindowtitle "Versiera de Agnesi" '(CL) CopyLeft 2014-05 by P.Specht, Wien 'Q: http://de.wikipedia.org/wiki/Versiera_der_Agnesi randomize:font 2:var co&=rgb(200+rnd(56),200+rnd(56),200+rnd(56)) windowstyle 24:window 0,0-%maxx,%maxy-40:cls co& var xh&=width(%hwnd)\2:var yh&=height(%hwnd)*3\4 proc agnesi :parameters x&,r! return r!*sqr(r!)/(sqr(x&)+sqr(r!)) endproc declare L&:var r!=300 usepen 0,1,0:line 0,yh& - 2*xh&,yh&:line xh&,0 - xh&,2*yh& WHILELOOP 500,-150,-5:r!=&Loop usepen 0,1,rgb(0,180,0):usebrush 0,0:ellipse xh&-r!/2,yh& - xh&+r!/2,yh&-r! usepen 0,1,255:moveto -xh&,agnesi(-xh&,r!) whileloop -xh&,xh&,15:l&=&loop lineto xh&+&Loop,yh&-agnesi(L&,r!) endwhile ENDWHILE waitinput End -
Abt. Goldener Schnitt mal anders
=====================CodeWindowtitle "Goldener Schnitt als Fixpunkt der Umgekehrten Proportionalität von Nachkommastellen" font 2:set("decimals",17):cls:declare g!,k!,d!,e!:g!=1:k!=0 repeat e!=g!-1-1/g! g!=g!-0.5*e! * 0.2 '=Faktor zur Verlangsamung der Berechnung (zum Zusehen) locate 1,1:print g!;" Abs.Fehler: ";e!; until nearly(e!,0,14) print "\n----------------------------------------------------------------------" print 0.5+0.5*sqrt(5);" ... zum Vergleich gemäß Lehrbuchformel." beep:waitinput -
Abt. Die bewiesene "Fermat'sche Vermutung" widerlegen
====================================
... wird nicht gelingen. WENN aber Computerianer glauben, doch Gegenbeispiele zu finden, dann muß man sich über die Grenzen der verwendeten Rechengenauigkeit verstärkt Gedanken machen. Hier bewährt sich z.B., daß XProfan DoublePrecision-Variable verwendet und viele Versionen den Zahlenbereich 10^-306...10^+306 aufweisen. So manches bisher ins Treffen geführte Zahlenbeispiel kann auf diese Weise rasch widerlegt werden. Statt dessen werden aber irgendwann Beispiele auftauchen, bei denen auch Double Precision nichts mehr nützt ("Specht'sche Vermutung"
). Ob nun jemand von UNS die irgendwann findet, das verwendete Programm könnte so ähnlich wie das folgende aussehen.
GrussCode
Alles anzeigenWindowTitle "Auf der Suche nach Fermat-Near-Misses" ' (CL) CopyLeft 2014-05 by P. Specht, Wien ' Sei a^n + b^n = c^n . Wenn a,b,c,n alle aus |N-{0} ==> n<=2 (! ... bewiesen von Andrew Wiles) ' Computer finden aber solche Zahlen! Diese widerlegen jedoch nicht dem Fermat'schen Gesetz, ' zeigen nur mangelnde Rechengenauigkeit der MatheSoftware. Berühmt: 3987^12 + 4365^12 = 4472^12 ' ....aber eben nicht genau! Gibt es noch weitere Beispiele? Mit 1 Null weniger: Ja! '3518^3 + 3097^3 = 4184.000000019039360000^3 '3753^3 + 4528^3 = 5262.000000012036250000^3 '3987^12+ 4365^12 = 4472.000000007057680000^12 '4433^14+ 4519^14 = 4706.000000039867700000^14 Windowstyle 10:font 1:set("decimals",18):randomize Window 0,0-%maxx,%maxy-40:cls rgb(150,150,100) Declare i!,j!,k!,r!,r$:print:clearclip WhileLoop 3,17:k!=&Loop WhileLoop 2000,5000:j!=&Loop WhileLoop 2000,5000:i!=&Loop r!=(i!^k!+j!^k!)^(1/k!):r$=str$(r!) if instr(".0000000",r$) case (r!=j!) or (r!=i!):continue 'Addition ausserhalb Stellenbereich = Trivialfehler print int(i!),"^";int(k!),"+",int(j!),"^";int(k!);" =",\ r!,"^";int(k!),tab(53);i!^k!;" + ";j!^k!;" = ";(i!^k!+j!^k!) putclip str$(int(i!))+"^"+str$(int(k!))+"+"+str$(int(j!))+\ "^"+str$(int(k!))+" ="+str$(r!)+"^"+str$(int(k!))+"\n" if %csrlin>50:beep:waitinput 15000:cls rgb(150,150,100):print:endif endif endwhile case rnd()<0.14:windowTitle "Suche von Fermat-Near-Misses bei "+str$(int(j!))+"^"+str$(int(k!)) endwhile sound 2000,200 :waitinput 20000:cls rgb(150,150,100):print endwhile sound 1000,300:print "\n\n Fertig; Resultate stehen in der Zwischenablage." waitinput : waitinput : end -
Abt. Neues von Animusic
================
Erstaunlich, wie viele Nachahmer es inzwischen gibt. Selbst Original-Animusic Tracks werden neu "bebildert", hier ein Beispiel: Resonant Chamber. Manchmal allerdings muss man sich durch die ersten faden Minuten erst mal durchhören, bis es interessant wird: Galactic Academy ist so ein Beispiel. Manche Stücke kommen zwar musikalisch an die professionelle Variante heran, bei der Physik-Engine hapert es aber deutlich: PANDA TESLA als Beispiel; manches schafft die Distanz zum Plagiat aber dann doch nicht: PANDA The Train scheint mir nur unter dem Titel "Erstlingswerk" verdaubar. Aller Anfang ist eben schwer und beweist, wie ausgefeilt die Physik-Enginges bei Unternehmen der ersten Stunden inzwischen ist: Starship Groove, quasi von Meister Wayne Lyttle persönlich.
GrussP.S.: Physik-Engines werden insgesamt immer wirklichkeitsnäher und komplexer. Auch das Music Animation-Genre profitiert stark von der Gaming-Szene. Kleiner Wermutstropfen: Durch übertriebene Perfektion verliert sich manchmal der "Charme der ersten Stunde". Erstaunlich, wie schnell man sich da sattsieht und -hört

-
Abt. SIMPLEX-ALGORITHMUS
==================
Der grundlegendste aller Optimierungsalgorithmen des gesamten Operations Research-Bereiches (früher auch "Lineare Programmierung" genannt). Die hier vorgestellte Variante maximiert die lineare Zielfunktion (Kniff: Durch negative Zielvariablen könnte auch minimiert werden), sie berücksichtigt automatisch alle Nichtnegativitäts-Bedingungen und beherrscht neben den standardmäßig üblichen <= (Kleiner-gleich)-Restriktionen gleichzeitig auch >= (Größer-gleich)- und sogar == (Identisch-gleich)-Nebenbedingungen. Letztere helfen insbesondere bei sog. "Was wäre, wenn ..."-Analysen. Bitte aus den 3 Teilen zusammensetzen!
GrussP.S.: Es wurde vermieden, die Array-Basis A(1,1) in XProfans A![0,0] zu konvertieren, was aber noch gewisse Restrisiken beinhaltet; auch deshalb handelt es sich um eine Demo-Alpha-Version ohne jede Gewähr!
Code
Alles anzeigen'**************************************************************** WindowTitle "LINEAR PROGRAMMING: THE SIMPLEX METHOD" '* '* ------------------------------------------------------------ * '* XProfan: Early Alpha Version! Use solely on your own risk! * '* Keine wie auch immer geartete Gewähr!No Warranty whatsoever! * '* Nutzung auf alleinige Gefahr des Anwenders / der Anwenderin! * '* ------------------------------------------------------------ * '* SAMPLE RUN: * '* * '* Maxim. Z = x1 + x2 + 3*x3 -0.5*x4 with conditions: * '* x1 + 2*x3 <= 740 * '* 2*x2 - 7*x4 <= 0 * '* x2 - x3 + 2*x4 >= 0.5 * '* x1 + x2 + x3 + x4 = 9 * '* and *of course* all x's >= 0 * '* * '* Number of variables in E.F.: 4 * '* Number of <= inequalities..: 2 * '* Number of >= inequalities..: 1 * '* Number of = equalities.....: 1 * '* * '* Input Economic Function: * '* Coefficient # 1: 1 * '* Coefficient # 2: 1 * '* Coefficient # 3: 3 * '* Coefficient # 4: -0.5 * '* Constant term..: 0 * '* * '* Input constraint # 1: * '* Coefficient # 1: 1 * '* Coefficient # 2: 0 * '* Coefficient # 3: 2 * '* Coefficient # 4: 0 * '* Constant term..: 740 * '* Input constraint # 2: * '* Coefficient # 1: 0 * '* Coefficient # 2: 2 * '* Coefficient # 3: 0 * '* Coefficient # 4: -7 * '* Constant term..: 0 * '* Input constraint # 3: * '* Coefficient # 1: 0 * '* Coefficient # 2: 1 * '* Coefficient # 3: -1 * '* Coefficient # 4: 2 * '* Constant term..: 0.5 * '* Input constraint # 4: * '* Coefficient # 1: 1 * '* Coefficient # 2: 1 * '* Coefficient # 3: 1 * '* Coefficient # 4: 1 * '* Constant term..: 9 * '* ------------------------------------------------------------ * '* ... resulting in the following Array with ArrayBase at [1,1] * '* ------------------------------------------------------------ * '* A[1,i]= Const x1 x2 x3 x4 * '* 0: ---1------2-------3-------4-------5--- * '* 1: 0.00 1.00 1.00 3.00 -0.50 * '* 740.00 -1.00 0.00 -2.00 0.00 * '* 0.00 0.00 -2.00 0.00 7.00 * '* 0.50 0.00 -1.00 1.00 -2.00 * '* 9.00 -1.00 -1.00 -1.00 -1.00 * '* ------------------------------------------------------------ * '* RESULT: * '* ------------------------------------------------------------ * '* Maximum of Economic Function = 17.025 * '* X1 = 0.000 * '* X2 = 3.325 * '* X3 = 4.725 * '* X4 = 0.950 * '* ------------------------------------------------------------ * '* Reference: "Numerical Recipes By W.H. Press, B. P. Flannery, * '* S.A. Teukolsky and W.T. Vetterling, Cambridge * '* University Press, 1986". * '* ------------------------------------------------------------ * '* BASIC Release 1.0 By J-P Moreau, Paris * '* (www.jpmoreau.fr) * '* ------------------------------------------------------------ * '* Adapted (Demo-only) to XProfan Version 11.2a by * '* P.Specht, Vienna/Austria * '* www.paules-pc-forum.de/ppf/ * '* board9-programmierung/board104-xprofan/ * '**************************************************************** '**************************************************************** '* Program Test Simplex * '****************************************************************
Weiter gehts unten mit Teil 2. -
Code
Alles anzeigenWindowStyle 24:font 1:randomize:set("decimals",17) var co&=rgb(200+rnd(56),200+rnd(56),200+rnd(56)) Window 0,0-%maxx,%maxy-40:CLS co& declare i&,j&,k&,MMAX&,NMAX&,M&,M1&,M2&,M3&,F$,F1$,mm&,kp&,bmax! declare icase&,n&,EPS!,R!,nl1&,nl2&,ir&,q1!,iafb&,kk&,ii&,iabf& declare test!,ip&,q!,i1&,k1&,PIV!,kh&,iis&,M12&,ente& MMAX& = 25 : NMAX& = 25 declare A![MMAX&,NMAX&],iposv&[MMAX&],izrov&[NMAX&] '* ------------------------------------------------------------ * IF 0 ' 0 = Input, 1 = Use Testdata N& = 4 ' Anzahl der Variablen in der zu maximierenden Gewinnfunktion m1&= 2 ' Anzahl der <= Nebenbedingungen m2&= 1 ' Anzahl der >= Nebenbedingungen m3&= 1 ' Anzahl der == Nebenbedingungen A![1,1]= 0.00 : A![1,2]= 1.00 : A![1,3]= 1.00 : A![1,4]= 3.00 : A![1,5]=-0.50 A![2,1]=740.00 : A![2,2]=-1.00 : A![2,3]= 0.00 : A![2,4]=-2.00 : A![2,5]= 0.00 A![3,1]= 0.00 : A![3,2]= 0.00 : A![3,3]=-2.00 : A![3,4]= 0.00 : A![3,5]= 7.00 A![4,1]= 0.50 : A![4,2]= 0.00 : A![4,3]=-1.00 : A![4,4]= 1.00 : A![4,5]=-2.00 A![5,1]= 9.00 : A![5,2]=-1.00 : A![5,3]=-1.00 : A![5,4]=-1.00 : A![5,5]=-1.00 M& = M1& + M2& + M3& ELSE '* ------------------------------------------------------------ * PRINT PRINT " Number of variables in E.F.: "; : INPUT N& PRINT " Number of <= inequalities..: "; : INPUT M1& PRINT " Number of >= inequalities..: "; : INPUT M2& PRINT " Number of = equalities.....: "; : INPUT M3& PRINT M& = M1& + M2& + M3& 'Total number of constraints F$ = " ########0.0###############;-########0.0###############; 0.0" '"%g" F1$ = " ########0.0###############;-########0.0###############; 0.0" '"%g" ' Schlupfvariablen & Clear whileloop M&+2:i&=&Loop whileloop N&+1:j&=&Loop A![i&,j&]=0.0 endwhile endwhile PRINT " Input Economic Function: " whileloop 2,n&+1:i&=&Loop PRINT " Coefficient #"; int(i&-1); ": ";:INPUT A![1,i&] endwhile PRINT " Constant term : ";:INPUT A![1,1] PRINT ' input constraints whileloop m&:i&=&Loop PRINT " Input constraint #"; i&; ":" whileloop 2,n&+1:j&=&Loop PRINT " Coefficient #"; int(j& - 1); ": ";:INPUT R! A![i&+1,j&] = -1*R! endwhile PRINT " Constant term: ";:INPUT A![i&+1,1] endwhile PRINT ENDIF CLS co& PRINT " Input Table: ":print whileloop m&+1:i&=&Loop whileloop n&+1:j&=&Loop print tab((j&-1)*27);A![i&,j&]; endwhile PRINT endwhile GOSUB "S1000" 'call simplx(A,M,N,M1,M2,M3,ICASE,IZROV,IPOSV) IF icase& = 0 'result ok. PRINT PRINT " Maximum of E.F. = "; PRINT format$(F1$, A![1,1]) ente&=0 whileloop n&:i&=&Loop whileloop m&:j&=&Loop IF iposv&[j&] = i& PRINT " X";i&;" = ";format$(F1$,A![j&+1,1]) ente&=1:break ENDIF endwhile ifnot ente& PRINT " X";i&;" = ";format$(F1$,0.0) ente&=0 endif endwhile ELSE PRINT " No solution (error code = "; icase&; ")." ENDIF waitinput END 'of main program '**************************************************************** '* Simplex Algorithm * '**************************************************************** S1000: ' Subroutine simplx(A[1..,1.. ], m, n, m1, m2, m3, icase, izrov, iposv) '----------------------------------------------------------------------------------------- ' USES 2000 simp1, 2100 simp2, 2200 simp3. ' Simplex method for linear programming. Input parameters A, m, n, m1, m2, and m3, and ' output parameters A, icase, izrov, and iposv are described above (see reference). ' Constants: MMAX is the maximum number of constraints expected; NMAX is the maximum number ' of variables expected; EPS is the absolute precision, which should be adjusted to the ' scale of your variables. '----------------------------------------------------------------------------------------- Declare l1&[MMAX&],l2&[MMAX&],l3&[MMAX&] EPS!=0.000001 IF M& <> (M1& + M2& + M3&) PRINT " Bad input constraint counts in simplx." RETURN ENDIF nl1& = N& whileloop n&:k&=&Loop l1&[k&] = k& 'Initialize index list of columns admissible for exchange. izrov&[k&] = k& 'Initially make all variables right-hand. endwhile nl2& = M& whileloop m&:i&=&Loop IF A![i&+1,1] < 0.0 PRINT " Bad input tableau in simplx, Constants bi must be nonnegative." RETURN ENDIF l2&[i&] = i& iposv&[i&] = N& + i& '------------------------------------------------------------------------------------------------- ' Initial left-hand variables. m1 type constraints are represented by having their slack variable ' initially left-hand, with no artificial variable. m2 type constraints have their slack ' variable initially left-hand, with a minus sign, and their artificial variable handled implicitly ' during their first exchange. m3 type constraints have their artificial variable initially ' left-hand. '------------------------------------------------------------------------------------------------- endwhile whileloop m2&:i&=&Loop l3&[i&] = 1 endwhile ir& = 0 case (M2& + M3&) = 0 : GOTO "G30" 'The origin is a feasible starting solution. Go to phase two. ir& = 1 ' Compute the auxiliary objective function: whileloop n&+1:k&=&Loop q1!=0.0 whileloop M1&+1,M&:i&=&Loop q1!=q1!+A![i&+1,k&] endwhile A![M&+2,k&]= -1*q1! endwhileWeiter nachstehend beim Teil 3 von 3:
-
Code
Alles anzeigenG10: iabf&=0 : mm&=M&+1 GOSUB "S2000" 'call simp1(a,m+1,l1,nl1,0,kp,bmax) Find max. coeff. of auxiliary objective fn. IF (bmax! <= EPS!) AND (A![M&+2,1] < (-1*EPS!)) icase& = -1 'Auxiliary objective function is still negative and can’t be improved, RETURN 'hence no feasible solution exists. ELSEIF (bmax! <= EPS!) AND (A![M&+2,1] <= EPS!) ' Auxiliary objective function is zero and can’t be improved; we have a feasible starting vector. ' Clean out the artificial variables corresponding to any remaining equality constraints by ' go to 1’s and then move on to phase two by go to 30. m12& = M1& + M2& + 1 IF m12& <= M& 'THEN whileloop m12&,m&:ip&=&Loop IF iposv&[ip&] = ip& + N& 'Found an artificial variable for an equality constraint. iabf& = 1: mm& = ip& GOSUB "S2000" 'call simp1(a,ip,l1,nl1,1,kp,bmax) case bmax! > EPS!:GOTO "G1" 'Exchange with column corresponding to maximum ENDIF 'pivot element in row. endwhile ENDIF ir& = 0 m12& = m12& - 1 case (M1&+1) > m12& :GOTO "G30" ' Change sign of row for any m2 constraints whileloop m1&+1,M1&+M2& IF l3&[i& - M1&] = 1 'THEN 'still present from the initial basis. whileloop n&+1:k&=&Loop A![i&+1,k&] = -1.0*A![i&+1,k&] endwhile ENDIF endwhile GOTO "G30" 'Go to phase two. ENDIF GOSUB "S2100" 'call simp2(a,m,n,l2,nl2,ip,kp,q1) Locate a pivot element (phase one). IF ip& = 0 'THEN 'Maximum of auxiliary objective function is icase& = -1 'unbounded, so no feasible solution exists. RETURN ENDIF G1: i1&=M&+1:k1&=N& GOSUB "S2200" 'call simp3(a,m+1,n,ip,kp) ' Exchange a left- and a right-hand variable (phase one), then update lists. IF iposv&[ip&] >= (N&+M1&+M2&+1) ' THEN 'Exchanged out an artificial variable for an 'equality constraint. Make sure it stays 'out by removing it from the l1 list. whileloop nl1&:k&=&Loop case l1&[k&] = kp& : GOTO "G2" endwhile G2: nl1& = nl1& - 1 whileloop k&, nl1& : iis&=&Loop l1&[iis&] = l1&[iis&+1] endwhile ELSE case iposv&[ip&]<(N&+M1&+1):GOTO "G20" kh& = iposv&[ip&]-M1&-N& case l3&[kh&] = 0 : GOTO "G20" 'Exchanged out an m2 type constraint. l3&[kh&] = 0 'If it’s the first time, correct the pivot column or the 'minus sign and the implicit artificial variable. ENDIF A![M&+2,kp&+1]=A![M&+2,kp&+1]+1.0 whileloop m&+2:i&=&Loop A![i&,kp&+1] = -1.0*A![i&,kp&+1] endwhile G20: iis& = izrov&[kp&] 'Update lists of left- and right-hand variables. izrov&[kp&] = iposv&[ip&] iposv&[ip&] = iis& case ir& <> 0 : GOTO "G10" 'if still in phase one, go back to 10. ' End of phase one code for finding an initial feasible solution. Now, in phase two, optimize it. G30: iabf& = 0 : mm& = 0 GOSUB "S2000" 'call simp1(a,0,l1,nl1,0,kp,bmax) Test the z-row for doneness. IF bmax! <= EPS! 'Done. Solution found. Return with the good news. icase& = 0 RETURN ENDIF GOSUB "S2100" 'call simp2(a,m,n,l2,nl2,ip,kp,q1) Locate a pivot element (phase two). IF ip& = 0 'THEN 'Objective function is unbounded. Report and return. icase& = 1 RETURN ENDIF i1& = M& : k1& = N& GOSUB "S2200" 'call simp3(a,m,n,ip,kp) Exchange a left- and a right-hand variable (phase two), GOTO "G20" 'update lists of left- and right-hand variables and 'return for another iteration. RETURN 'The preceding subroutine makes use of the following utility subroutines: S2000: ' Subroutine simp1(a, mm, l1, nl1, iabf, kp, bmax) ' Determines the maximum of those elements whose index is contained in the supplied list ' l1, either with or without taking the absolute value, as flagged by iabf. kp& = l1&[1] bmax! = A![mm&+1,kp&+1] case nl1&<2:RETURN whileloop 2,nl1&:k&=&Loop IF iabf& = 0 'THEN test! = A![mm&+1,l1&[k&]+1]-bmax! ELSE test! = ABS(A![mm&+1,l1&[k&]+1]) - ABS(bmax!) ENDIF IF test! > 0 'THEN bmax! = A![mm&+1,l1&[k&]+1] kp& = l1&[k&] ENDIF endwhile RETURN S2100: 'Subroutine simp2(a, m, n, l2, nl2, ip, kp, q1) EPS! = 0.000001 ' Locate a pivot element, taking degeneracy into account. ip& = 0 case nl2& < 1 : RETURN whileloop nl2&:i&=&Loop case A![i&+1,kp&+1] < (-1*EPS!) : GOTO "G2102" endwhile RETURN 'No possible pivots. Return with message. G2102: q1! = -1*A![l2&[i&]+1,1]/A![l2&[i&]+1,kp&+1] ip& = l2&[i&] case (i&+1) > nl2&:RETURN WhileLoop i&+1,nl2&:i&=&Loop ii& = l2&[i&] IF A![ii&+1,kp&+1] < (-1*EPS!) q! = -1*A![ii&+1,1] / A![ii&+1,kp&+1] IF q! < q1! 'THEN ip& = ii& q1! = q! ELSEIF q! = q1! 'THEN 'We have a degeneracy. whileloop n& : k&=1 qp! = -1*A![ip&+1,k&+1] / A![ip&+1,kp&+1] q0! = -1*A![ii&+1,k&+1] / A![ii&+1,kp&+1] case q0! <> qp! : BREAK 'GOTO "G2106" endwhile G2106: case q0! < qp! : ip& = ii& ENDIF ENDIF endwhile RETURN S2200: ' Subroutine simp3(a, i1,k1,ip,kp) ' Matrix operations to exchange a left-hand and right-hand variable. piv! = 1 / A![ip&+1,kp&+1] IF i1&>=0 whileloop i1&+1:ii&=&Loop IF (ii&-1) <> ip& A![ii&,kp&+1] = A![ii&,kp&+1]*piv! whileloop k1&+1:kk&=&Loop IF (kk&-1) <> kp& A![ii&,kk&]=A![ii&,kk&]-A![ip&+1,kk&]*A![ii&,kp&+1] ENDIF endwhile ENDIF endwhile ENDIF whileloop k1&+1:kk&=&Loop case (kk&-1)<>kp&: A![ip&+1,kk&]= -1*A![ip&+1,kk&]*piv! endwhile A![ip&+1,kp&+1] = piv! RETURN ' end of file tsimplex.prf -
PPS.: Kernalgorithmus im vorigen Beitrag, veröffentlicht u.v.a. in:
Numerical Recipes Example Book (C++), herausgegeben von William T. Vetterling
Numerical Recipes in FORTRAN Example Book: The Art of Scientific Computing, Bände 1-2
oder im Netz z.B. HIER. -
Abt. Goldsound Jan-Mai 2014
==================
Aus Tradition hier ein weiteres Update zur inzwischen sattsam bekannten Nonsens-Programmserie "Klang des Goldes" - Im Grunde eine fade Sache, dümpelt doch der Goldkurs seit Januar 2014 so um € 950 +/- 35 rum. Gott-sei-Dank!: Der aus Angst ausgelöste Run aufs Gold 2012/13 scheint jedenfalls vorbei, Angebot ist jedenfalls genug da (... wozu auch der Abtransport der ukarinischen Goldreserven nach den USA beigetragen haben dürfte). Wie immer gilt: Alles ohne jedwede Gewähr!
GrussP.S.: Wenn doch größere Tonhöhenänderungen zu hören sind, bitte keine Panik!: Zur Dramatisierung wurde die Basis auf 800 verschoben, sodaß auch kleine Änderungen gut hörbar sind.
Code
Alles anzeigenWindowTitle "GoldSound EUR/Feinunze 2.Jan.-30.Mai 2014" Windowstyle 24:window 300,300-300,43:randomize:var a$=\ "888.838,897.436,903.012,907.520,909.558,914.209,907.924,901.182,"+\ "902.502,897.596,900.610,903.464,906.533,909.672,911.885,914.152,"+\ "913.096,915.107,908.557,909.961,908.607,910.391,912.634,920.946,"+\ "925.878,926.001,922.005,914.733,915.571,915.192,912.876,924.191,"+\ "920.437,925.899,927.820,922.295,919.123,916.197,917.886,925.262,"+\ "922.194,914.881,920.538,927.697,922.582,933.915,927.187,925.494,"+\ "930.353,928.571,930.637,923.083,928.724,926.600,933.856,936.835,"+\ "938.094,939.469,942.836,950.188,943.648,948.270,955.598,964.348,"+\ "967.601,968.554,957.586,959.987,959.091,960.084,959.222,959.296,"+\ "963.629,961.944,968.539,973.630,969.484,973.252,975.326,973.644,"+\ "974.806,973.440,961.650,961.580,975.579,980.100,973.899,970.445,"+\ "971.939,974.064,971.565,971.791,971.222,962.550,961.552,969.068,"+\ "973.566,970.830,977.469,983.654,982.303,982.309,986.463,995.186,"+\ "992.372,989.591,979.370,975.921,967.162,962.036,962.641,963.619,"+\ "970.209,967.695,960.337,951.474,951.821,952.226,952.743,945.339,"+\ "942.092,941.655,944.149,941.431,939.861,936.594,932.449,930.388,"+\ "930.907,937.795,935.094,936.270,943.747,946.829,946.931,945.140,"+\ "955.140,949.119,949.920,942.478,953.188,952.329,948.617,949.568,"+\ "958.047,958.882,950.431,939.422,938.584,941.615,937.477,938.855,"+\ "935.191,931.483,927.384,928.917,928.525,934.786,934.882,939.938,"+\ "938.446,936.824,930.019,938.902,934.674,929.788,924.152,921.774,"+\ "927.262,927.098,939.609,937.388,942.081,931.168,926.026,928.437,"+\ "933.246,936.639,938.953,943.379,939.908,944.489,948.326,951.903,"+\ "953.731,949.978,943.173,941.944,948.666,949.256,943.458,945.551,"+\ "942.653,942.281,945.926,950.725,948.605,947.403,940.478,935.323,"+\ "928.828,929.044,921.043,922.794,921.043,918.270,921.043,918.270" declare co&,b$[]:b$[]=explode(a$,","):clear a$:var n&=sizeof(b$[])-1:font 2 whileLoop 0,n&:waitinput 100:co&=(val(b$[&Loop])-775)*1.1:co&=rgb(co&,co&,co&) cls co&:print b$[&Loop];:sound (val(b$[&Loop])-800)*5,54:endwhile:waitinput 15000 -
Abt. Eine widerspenstige (aka "steife") Differentialgleichung lösen =========================================
Hängen zeitabhängige Größen von absoluten Augenblickswerten und Änderungsgeschwindigkeiten anderer Größen (oder z.B. Beschleunigungswerten) gegenseitig ab, dann beschreibt man das Systemverhalten in der Mathematik durch sog. Differentialgleichungen.Wenn die analytische (formelmäßige) Lösung so einer Differentialgleichung nicht gelingen will - z.B. weil die Mathematik des beginnenden 21. Jahrhunderts noch nicht so weit ist, oder gar prinzipielle Gründe vorliegen - so bleibt nur der Ansatz, wenigstens numerische Lösungen zur Verhaltensanalyse solcher Systeme zu finden.
Dabei muss einem klar sein, daß schon kleinste Fehler (wie sie z.B. aus der Digitalisierung analoger Daten stammen) a la long zu riesigen Unterschieden zwischen Prognose und Realität führen können. Und manche Problemstellungen sind diesbezüglich ganz besonders fehlerempfindlich, was die numerische Lösung in der Praxis zu torpedieren droht.
Interessanter Weise zeigen nun gerade die einfachsten (geradezu "primitiven") Lösungsverfahren in solchen Fällen halbwegs gutmütiges Verhalten. Im Fachjargon spricht man von "Steifen Anfangswertproblemen", bei denen sog. "Implizite Mehrschrittverfahren" aus Sicht der numerischen Stabilität die relative beste Vorhersagbarkeit erlauben.
Eines der frühesten, aber in solchen Fällen immer noch gerne verwendeten Verfahren stammt vom englischen Astronomen John Couch Adams (1819-1892) und dem amerikanischen Astronomen und Mathematiker Forest Ray Moulton (1872-1952).
Im nachstehenden Programm wird die Genauigkeit des Adams-Moulton-Verfahrens geprüft, in dem die numerische Lösung mit der hier doch möglichen analytischen Formellösung verglichen wird. Eine für reale Anwendungen sicher ausreichende Genauigkeit auf 5 bis 6 Kommstellen ist damit bei DoublePrecision in vernünftiger Zeit erreichbar.
GrussP.S.: Es existieren weitere Lösungsverfahren, etwa die "linearisierenden Prädiktor-Korrektor-Verfahren". Aber dazu ein andermal.
Code
Alles anzeigenWindowTitle "ADAMS-MOULTON, an implicit method for "+\ "STIFF ORDINARY DIFFERENTIAL EQUATIONS " WindowStyle 24:Window 0,0-%maxx,%maxy-40:font 2:randomize var co&=rgb(200+rnd(56),200+rnd(56),200+rnd(56)):Cls Co&:set("decimals",17) var fmt$=" -#0.000000000000000; #0.000000000000000; 0.0 " '******************************************************************** '* Solve Y' = F(X,Y) with initial conditions * '* using the Adams-Moulton Method * '{ -----------------------------------------------------------------* '* EXAMPLE: 'Integrate...' * '* * '* Y' = -Y + X/(1+X)^2 for X=[0,1] with Initial Condition Y0=1 * * '* * '* RESULT: * '* X Y Y_True Abs(Y - Y_True) * '* ------------------------------------------------------ * '* 0.000000E+00 0.100000E+01 0.100000E+01 0.000000E+00 * '* 0.500000E-01 0.952381E+00 0.952381E+00 0.716977E-09 * '* 0.100000E+00 0.909091E+00 0.909091E+00 0.190987E-08 * '* 0.150000E+00 0.869569E+00 0.869565E+00 0.368444E-05 1 * '* 0.200000E+00 0.833340E+00 0.833333E+00 0.644065E-05 1 * '* 0.250000E+00 0.800009E+00 0.800000E+00 0.850220E-05 1 * '* 0.300000E+00 0.769241E+00 0.769231E+00 0.100264E-04 1 * '* 0.350000E+00 0.740752E+00 0.740741E+00 0.111325E-04 1 * '* 0.400000E+00 0.714298E+00 0.714286E+00 0.119113E-04 1 * '* 0.450000E+00 0.689668E+00 0.689655E+00 0.124333E-04 1 * '* 0.500000E+00 0.666679E+00 0.666667E+00 0.127530E-04 1 * '* 0.550000E+00 0.645174E+00 0.645161E+00 0.129133E-04 1 * '* 0.600000E+00 0.625013E+00 0.625000E+00 0.129478E-04 1 * '* 0.650000E+00 0.606073E+00 0.606061E+00 0.128835E-04 1 * '* 0.700000E+00 0.588248E+00 0.588235E+00 0.127418E-04 1 * '* 0.750000E+00 0.571441E+00 0.571429E+00 0.125397E-04 1 * '* 0.800000E+00 0.555568E+00 0.555556E+00 0.122910E-04 1 * '* 0.850000E+00 0.540553E+00 0.540541E+00 0.120070E-04 1 * '* 0.900000E+00 0.526327E+00 0.526316E+00 0.116966E-04 1 * '* 0.950000E+00 0.512832E+00 0.512821E+00 0.113670E-04 1 * '* 0.100000E+01 0.500011E+00 0.500000E+00 0.110243E-04 1 * '* ---------------------------------------------------------------- * '* REFERENCE: "Méthode de calcul numérique- Tome 2 - Programmes en * '* Basic et en Pascal By Claude Nowakowski, Edition du * '* P.S.I., 1984". * '* ---------------------------------------------------------------- * '* F90 Release By J-P Moreau, Paris. * '* (www.jpmoreau.fr) * '* ---------------------------------------------------------------- * '* Converted to XProfan11.2a/Demo only!/by P.Specht, Vienna/Austria * '* No warranties whatsoever! Keine wie auch immer geartete Gewähr! * '* Merci, Mons. Docteur J-P Moreau! Vous etes formidable! * '}******************************************************************* Proc MyFunction : parameters XX!,YY! C! = -YY!+XX!/sqr(1.0+XX!) ' sqr, not sqrt ! return C! endproc '********************************************************************* Proc AlgebraicIntegral : parameters XX! F!=1/(1+XX!) :return F! endproc '********************************************************************* Declare x![3],y![3],H!,EC!,ER!,F!,C!,C1!,C2!,C3!,C4!,XX!,YY!,YC!,YP!,K&,L& H! = (1-0)/50 ' Integration step X![0]=0.0 : Y![0]=1.0 ' Initial conditions EC! = 0.0000001 ' Precision 'PRINT " " PRINT " X Y Y_True |Y-Y True| L " 'PRINT " -------------------------------------------------------------------------------------" print format$(fmt$,X![0]),format$(fmt$,Y![0]),format$(fmt$,F!),format$(fmt$,ER!)," ";L&;" " ' Start with Runge-Kutta first (for two initial values) WhileLoop 0,1:k&=&Loop XX!= X![K&] : YY! = Y![K&]: C1!=MyFunction(XX!,YY!) XX!= X![K&]+0.5*H! : YY!=Y![K&] + 0.5*H! * C1! : C2!=MyFunction(XX!,YY!) YY!= Y![K&]+0.5*H! * C2! : C3!=MyFunction(XX!,YY!) X![K&+1] = X![K&] + H! XX!= X![K&+1]: YY!=Y![K&] + H!*C3! : C4!=MyFunction(XX!,YY!) Y![K&+1] = Y![K&] + H!*(C1!+2*C2!+2*C3!+C4!)/6 '*0.16666666666666667 XX!= X![K&+1]: AlgebraicIntegral(XX!,F!): ER! = ABS(F! - Y![K&+1]) print format$(fmt$,X![K&+1]),format$(fmt$,Y![K&+1]),format$(fmt$,F!),format$(fmt$,ER!)," ";L&;" " endwhile 100: K& = 2 XX! = X![K&]: YY! = Y![K&] : c1!=MyFunction(XX!,YY!) XX! = X![K&-1]: YY! = Y![K&-1]: c2!=MyFunction(XX!,YY!) XX! = X![K&-2]: YY! = Y![K&-2]: c3!=MyFunction(XX!,YY!) X![K&+1] = X![K&] + H! YP! = Y![K&] + H! / 12 * (23.0*C1! - 16.0*C2! + 5.0*C3!) L& = 0 200: XX! = X![K&+1]: YY! = YP! : c1!=MyFunction(XX!,YY!) XX! = X![K&]: YY! = Y![K&]: c2!=MyFunction(XX!,YY!) XX! = X![K&-1]: YY!= Y![K&-1]: c3!=MyFunction(XX!,YY!) YC! = Y![K&] + H! / 12.0 * (5.0 * C1! + 8.0 * C2! - C3!) IF ABS(YP!-YC!)>EC! YP!=YC! : L&=L&+1: GOTO "200" ENDIF Y![K&+1] = YC!: XX! = X![K& + 1]: F!=AlgebraicIntegral(XX!): ER! = ABS(F! - Y![K&+1]) print format$(fmt$,X![K&+1]),format$(fmt$,Y![K&+1]),\ format$(fmt$,F!),format$(fmt$,ER!)," ";L&;" " whileLoop 0,2:k&=&Loop X![K&] = X![K&+1]: Y![K&] = Y![K&+1] endwhile Case X![2]<1.0:GOTO "100" Waitinput 10^5 'ms End 'adamsmoulton.prf -
Abt. Traktrix
========
Zieht man einen widerwilligen Dackel (nach dem dieser gewisse Notwendigkeiten verrichtet hat) mittels einer Leine fester Länge durch Weitergehen vom Laternenpfahl weg, dann rutscht dessen Schwerpunkt entlang einer sogenannten Hundskurve, auch Zugkurve genannt oder - vornehmer - "Traktrix"!
Deren Gleichung wurde (gleich in mehrerlei Form) bereits 1693 vom Niederländischen Astronom und Mathematiker Christiaan Huygens gefunden. Ihre Bedeutung liegt im Umstand, daß bestimmte mechanische Vorrichtungen wie Kolbentriebe und Pleuelgestänge solche Kurven beschreiben.Unterschieden wird die "Eigentliche Traktrix" (x- und y-Achse mit gleicher Teilung, Symmetrie des Graphen) von anderen Varianten, z.B. der rotierten Traktrix, der verschobenen Traktrix, der realen Traktrix in allgemeiner Lage oder asymetrischen Varianten (z.B. wenn der obgenannte Hundebesitzer eine Leine mit Federspule verwendet). Anbei erst mal ein Progrämmchen (Version 2) zur unspektakulären Berechnung und Darstellung mehrerer "Eigentlichen Traktrixen".
GrussCode
Alles anzeigenWindowTitle "Eigentliche Traktrix" WindowStyle 24:randomize:font 2:set("decimals",18) var co&=co():Window 0,0-%maxx,%maxy-40:cls co& var xh&=width(%hwnd)\2:var yh&=height(%hwnd)\2 proc co :return rgb(200+rnd(56),200+rnd(56),200+rnd(56)) endproc proc Achsen :parameters x&,y& usepen 0,1,0:line 0,(yh&-y&) - 2*xh&,yh&-y&:line xh&+x&,0 - xh&+x&,2*yh& endproc proc EigTraktrix :parameters d!,x!,sn! declare sq!:d!=abs(d!):sn!=if(sn!<0,-1,1) if abs(x!)<=d! sq!=sqrt(sqr(d!)-sqr(x!)) else x!=0 endif ifnot nearly(x!,0,10) return sn!*d!*ln( abs( (d!+sq!)/x! ) ) - sn!*sq! else return sn!*yh&*zoom! endif endproc declare x!,y!,d!,zoom! zoom!=1 d!=100 Achsen 0,0 whileloop 10,300,5:d!=&Loop usepen 0,3,rgb(rnd(255),rnd(255),rnd(255)) whileLoop -xh&/zoom!,xh&/zoom!:x!=&Loop y!=EigTraktrix(d!,x!,1) line xh&+x!*zoom!,(yh&-y!*zoom!) - xh&+x!*zoom!+1,yh&-y!*zoom! y!=EigTraktrix(d!,x!,-1) line xh&+x!*zoom!,(yh&-y!*zoom!) - xh&+x!*zoom!+1,yh&-y!*zoom! endwhile endwhile waitinput -
Abt. Padé-Approximation der Sinus-Funktion
============================
Eine der numerisch besten Approximationsfunktionen stammt von Henri Padé, dem es erstmals gelang, transzendente Funktionen wie sinh, arcosh u.dgl. nicht wie Taylor durch höhere Ableitungen oder wie Fourier durch Sin/Cos-Oberwellensynthese zu beschreiben, sondern durch ein Zählerpolynom dividiert durch ein Nennerpolynom. Somit konnten sowohl Nullstellen als auch Polstellen (Unendlichkeiten) näherungsweise exakt dargestellt werden.Auf die Sinus-Funktion angewandt, ergaben sich je nach Polynom-Grad unterschiedlich genaue Approximationen. Viel Sinn hat die Sache in Zeiten von 10-Byte FPU precision und DoublePrecision XMM-SIMD Parallelarchitekturen eher nicht...
GrussCode
Alles anzeigenWindowTitle "Padé-Approximation der Sinus-Funktion mit verschiedenen Genauigkeiten" Cls:Declare x!,y!:set("decimals",18) appendmenubar 100,"Grad Pade(Rad) Sin(Rad) Abs.Fehler:" whileloop -180,180:x!=&Loop*pi()/180 ' Auf 5 Stellen genau im Bereich -60°..+60°: y!= -(620*sqr(x!)*x!-5880*x!)/(11*sqr(sqr(x!))+360*sqr(x!)+5880) ' Auf 7 Stellen genau für -90°..90° ' y!=(532182*sqr(sqr(x!))*x!-23819040*sqr(x!)*x!+183284640*x!)/ \ ' (1331*sqr(sqr(x!))*sqr(x!)+126210*sqr(sqr(x!))+6728400*sqr(x!)+183284640) ' Auf 6 Stellen genau im Bereich -180°..+180°: ' y!= -(4469552712*sqr(sqr(x!))*sqr(x!)*x!-538531796880*sqr(sqr(x!))*x!+ \ ' 17478564143040*sqr(x!)*x!-124345562140800*x!)/ \ ' (1768969*sqr(sqr(sqr(x!)))+366075360*sqr(sqr(x!))*sqr(x!)+ \ ' 43268148000*sqr(sqr(x!))+3245696213760*sqr(x!)+124345562140800) print &loop,y!,sin(x!),y!-sin(x!) if %csrlin>25:waitinput:cls:endif endwhile waitinput -
Link: Raumquanten-Theorie
=================
Nach einer relativ neuen Sichtweise auf die Geometrie des Raumes leben wir alle in einem 11-dimensionalen Fraktal. Starkes Indiz: Es ergeben sich so auf natürlich-topologische Weise 31 fundamentale Naturkonstanten (Ach ja: ...und wir sehen meist unseren Eltern bzw. Großeltern ähnlich
).Hier der LINK.
Gruss -
Abt. Raumquanten die II.te:
==================
Nachdem der Inhaber der obgenannten Seite offen davon spricht, diese Theorie während seiner 8jährigen Gewängnisstrafe wegen Entwendung und Verkauf von Orignal-Apollo11-Mondgestein ausgearbeitet zu haben, hat mich der formelle Wahrheitsgehalt der Aussage, daß Fundamentalkonstanten richtig errechnet werden, dazu veranlaßt ein kleines Testprogramm zu schreiben. Selbiges anbei (bei Konstante 11 und 15 etc gibt es z.B. doch relativ große Fehler, aber grosso modo klappt die Errechnung).
GrussP.S.: Die Einarbeitung der bisher bei NIST genannten jüngsten Werte der gemessenen Konstanten ist geplant.
Code
Alles anzeigenWindowtitle " "+upper$("F u n d a m e n t a l k o n s t a n t e n n a c h B o h m" ) WindowStyle 24:Window %maxx\4,0-%maxx\2,%maxy-40:CLS Set("decimals",17):font 2 '(CL) Copyleft 2014-06 by P.Specht, Wien (AT) 'zur Überprüfung einiger Aussagen der qst (Quantum Space Theory), KEINE GEWÄHR! print "\nDavid Joseph Bohm (1917-1992), US-amerikanischer Quantenphysiker," print "Konkurrent von Bohr und Einstein betreffen die Weltformel (ToE)\n" 'https://www.google.at/?gws_rd=ssl#q=david+bohm '--------------------------------------------------------------------------------- Var Pi!=val("3.141592653589793238463") Var X! =val("0.085424543135") Var lP!=val("1.616199e-35") Var mP!=val("2.17651e-8") Var tP!=val("5.39106e-44") Var qP!=val("1.875545946e-18") Var TmpP!=val("1.416833e32") Var NA!=val("6.02214179e23") Var me!=val("9.10938215e-31") Var mpr!=val("1.672621637e-27") '--------------------------------------------------------------------------------- Var _c! = lP!/tP! Var _h! = lP!*lP! *mP!/tP! Var _G! = lP!*lP!*lP!/(mP! *tP!*tP!) Var _a! = X!*X! Var _e! = X!*qP! Var _k! = lP!*lP!*mP!/(tP!*tP!*TmpP!) Var _µ0! = 4*pi()*lP!*mP!/(qP!*qP!) Var _e0! = tP!*tP! *qP!*qP!/(4*pi()*lP!*lP!*lP!*mP!) Var _kC! = lP!*lP!*lP!*mP!/(tP!*tP! * qP!*qP!) Var _s! = pi()*pi()*mP!/(60*tP!*tP!*tP! *TmpP!*TmpP!*TmpP!*TmpP!) Var _RK! = 2*pi()*lP!*lP!*mP!/(X!*X!*tP!*qP!*qP!) Var _KJ! = X!*tP!*qP!/(pi()*lP!*lP!*mP!) Var _F0! = pi()*lP!*lP!*mP!/(X!*tP!*qP!) Var _Z0! = 4*pi()*lP!*lP!*mp!/(tP!*qP!*qP!) Var _G0! = X!*X!*tP!*qP!*qP!/(pi()*lP!*lP!*mP!) Var _HC! = X!*X!*tP!*qP!*qP!/(2*pi()*lP!*lP!*mP!) Var _c1! = 4*pi()*pi()*lP!*lP!*lP!*lP!*mP!/(tP!*tP!*tP!) Var _c1L!= 4*pi()*lP!*lP!*lP!*lP!*mP!/(tP!*tP!*tP!) Var _c2! = 2*pi()*lP!*TmpP! Var _R! = lP!*lP!*mP!*NA!/(tP!*tP!*TmpP!) Var _F! = X!*NA!*qP! Var _re! = X!*X!*lP!*mP!/me! Var _LambdaC! = 2*pi()*lP!*mP!/me! Var _a0! = lP!*mP!/(X!*X!*me!) Var _Eh! = X!*X!*X!*X!*lP!*lP!*me!/(tP!*tP!) Var _R8! = X!*X!*X!*X!*me!/(4*pi()*lP!*mP!) Var _µB! = X!*lP!*lP!*mP!*qP!/(2*tP!*me!) Var _µN! = X!*lP!*lP!*mP!*qP!/(2*tP!*mpr!) Var _OmegaC! = me!/(tP!*mP!) Var _Smi! = me!*me!/(X!*mP!*tP!*qP!) Var _aG! = me!*me!/(mP!*mP!) declare vv![50] var i&=-1 inc i&:vv![i&]=pi() inc i&:vv![i&]=0.085424543135 inc i&:vv![i&]=val("1.616199e-35") inc i&:vv![i&]=val("2.17651e-8") inc i&:vv![i&]=val("5.39106e-44") inc i&:vv![i&]=val("1.875545946e-18") inc i&:vv![i&]=val("1.416833e32") inc i&:vv![i&]=val("6.02214179e23") inc i&:vv![i&]=val("9.10938215e-31") inc i&:vv![i&]=val("1.672621637e-27") inc i&:vv![i&]=_c! inc i&:vv![i&]=_h! inc i&:vv![i&]=_G! inc i&:vv![i&]=_a! inc i&:vv![i&]=_e! inc i&:vv![i&]=_k! inc i&:vv![i&]=_µ0! inc i&:vv![i&]=_e0! inc i&:vv![i&]=_kC! inc i&:vv![i&]=_s! inc i&:vv![i&]=_RK! inc i&:vv![i&]=_KJ! inc i&:vv![i&]=_F0! inc i&:vv![i&]=_Z0! inc i&:vv![i&]=_G0! inc i&:vv![i&]=_HC! inc i&:vv![i&]=_c1! inc i&:vv![i&]=_c1L! inc i&:vv![i&]=_c2! inc i&:vv![i&]=_R! inc i&:vv![i&]=_F! inc i&:vv![i&]=_re! inc i&:vv![i&]=_LambdaC! inc i&:vv![i&]=_a0! inc i&:vv![i&]=_Eh! inc i&:vv![i&]=_R8! inc i&:vv![i&]=_µB! inc i&:vv![i&]=_µN! inc i&:vv![i&]=_OmegaC! inc i&:vv![i&]=_Smi! inc i&:vv![i&]=_aG! font 2:Print "Bohm's Fundamentalwerte:":font 0 print format$("%g",Pi!),tab(25);format$("%g",X!),tab(50);format$("%g",lP!) print format$("%g",mP!),tab(25);format$("%g",tP!),tab(50);format$("%g",qP!) print format$("%g",TmpP!),tab(25);format$("%g",me!),tab(50);format$("%g",mpr!) print format$("%g",NA!):font 0 var w$=\ "Kreisverhältnis,Pi,3.141592653589e0,(_),1,1#"+\ "Zhe,X,0.085424543135e0,(14),1,1#"+\ "Planck length,lP,1.616199e-35,(97),m,1#"+\ "Planck mass,mP,2.17651e-8,(13),kg,1#"+\ "Planck time,tP,5.39106e-44,(32),s,1#"+\ "Planck charge,qP,1.875545946e-18,(41),C,1#"+\ "Planck temperature,TmpP,1.416833e32,(85),K,1 #"+\ "Avogadro number,NA,6.02214179e23,(30),1/mol,_#"+\ "Mass of the electron,me,9.10938215e-31,(45),kg,_#"+\ "Mass of the proton,mpr,1.672621637e-27,(83),kg,_#"+\ "Speed of light,c,2.99792458e8,(_),m/s,lP/tP#"+\ "Planck-Konstante,h,1.054571726e-34,(47),m².kg/s,lP².mP/tP#"+\ "gravitational-Konstante,G,6.67384e-11,(80),m³/(kg.s²),lP³/(mP.tP²)#"+\ "Feinstruktur-Konstante,a,7.2973525698e-3,(24),X²#"+\ "Elementary charge,e,1.602176565e-19,(35),C,X.qP#"+\ "Boltzmann-Konstante,k,1.3806488e-23,(13),m².kg/(s².K),lP².mP/(tP².TP)#"+\ "Magnetische Vakuumpermeabilität,µ0,1.25663706143592e-6,_,m.kg/C²,4.pi.lP.mP/qP²#"+\ "Elektrizitäts-Konstante,e0,8.854187817e-12,(_),s².C²/(m³.kg),tP².qP²/(4.pi.lP³.mP)#"+\ "Coulomb-Konstante,kC,8.98755178736821e9,(_),m³.kg/(s².C²),lP³.mP/(tP².qP²)#"+\ "Stefan-Boltzmann-Konstante,s,5.670373e-8,(21),kg/(s³.K^4),p².mP/(60.tP³.TP^4)#"+\ "Von Klitzing-Konstante,RK,2.58128074434e4,(84),m².kg/(s.C²),2.pi.lP².mP/(X².tP.qP²)#"+\ "Josephson-Konstante,KJ,4.83597870e14,(11),s.C/(m².kg), X.tP.qP/(pi.lP².mP)#"+\ "Magnetische Flusskonstante,F0,2.067833758e-15,(46),m².kg/(s.C),pi.lP².mP/(X.tP.qP)#"+\ "Characteristische Impedanz,Z0,3.7673031346177e2,(_),m².kg/(s.C²),4.pi.lP².mp/(tP.qP²)#"+\ "Konductanzquantum,G0,7.7480917346e-5,(25),s.C²/(m².kg), X².tP.qP²/(pi.lP².mP)#"+\ "Quantized Hall conductance,HC,3.87404614e-5,(17),C²/(m².kg), X².tP.qP²/(2.pi.lP².mP)#"+\ "first radiation constant,c1,3.74177153e-16,(17),m^4.kg/s³, 4.pi².lP^4.mP/tP³#"+\ "spectral radiance-Konstante ,c1L,1.191042869e-16,(53),m^4.kg/s³,4.pi.lP^4.mP/tP³#"+\ "second radiation-Konstante,c2,1.4387770e-2,(13),m.K,2.pi.lP.TP#"+\ "Molare Gaskonstante(*),R,8.3144621,(75),m².kg.mol/(s².K),lP².mP .NA /(tP².TP)#"+\ "Faraday-Konstante,F,9.64853365e4,(21),C/mol,X .NA. qP#"+\ "Classical electron radius,re,2.8179403267e-15,(27),m, X².lP.mP/me#"+\ "Compton wavelength,LambdaC,2.4263102389e-12,(16),m,2.pi.lP.mP/me#"+\ "Bohr radius,a0,5.2917721092e-11,(17),m,lP.mP/(X².me)#"+\ "Hartree energy,Eh,4.35974434e-18,(19),m².kg/s², X^4.lP².me/tP²#"+\ "Rydberg-Konstante,R8,1.0973731568539e7,(55),1/m, X^4.me/(4.pi.lP.mP)#"+\ "Bohr magneton,µB,9.27400968e-24,(20),m².C/s,X.lP².mP.qP/(2.tP.me)#"+\ "Nuclear magneton,µN,5.05078353e-27,(11),m².C/s, X.lP².mP.qP/(2.tP.mpr)#"+\ "Compton angular frequency,OmegaC,7.763441e20,(_),1/s,me/(tP.mP)#"+\ "Schwinger magnetic induction,Smi,4.419e9,(_),kg/(s.C),me²/(X.mP.tP.qP)#"+\ "Gravitational coupling,aG,1.7518e-45,(21),1,me²/mP²" declare w&,W$[]:w$[]=explode(w$,"#"):w&=sizeOf(w$[])-1:declare ww$[w&,6-1] whileloop 0,w&:i&=&Loop:whileloop 1,6 ww$[i&,&Loop-1]=substr$(w$[i&],&Loop,",") endwhile:endwhile:clear w$[] font 2:print "\n Lange Liste eingelesen. Höchster Zeilenindex: ";w& repeat font 0:print "\n Welche Zeile überprüfen?: "; input i&:case i&>w&:continue:font 2 whileloop 0,5 print " ";ww$[i&,&Loop];if(&Loop<5," ",""); endwhile print "\n Berechnet: ";format$("%g",vv![i&])," Differenz: ";format$("%g",vv![i&]-val(ww$[i&,2])) print " Relativer Fehler: ";format$("%g",(vv![i&]-val(ww$[i&,2]))/val(ww$[i&,2]) ) font 0 if (vv![i&]-val(ww$[i&,2]))/val(ww$[i&,2]) > val("10e-12") usebrush 0,0:usepen 0,8,255 rectangle 0,0-width(%hwnd),height(%hwnd) else usebrush 0,0:usepen 0,8,rgb(0,255,0) rectangle 0,0-width(%hwnd),height(%hwnd) endif if %csrlin>45:waitinput:cls:endif until 0 -
Jetzt mitmachen!
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!