| |
|
|
p.specht
| Interessanter point is not always integrally simply, for defined Funktionskurven whom rose at a place X To detect. if the namely at all meaningfully is, remaining sometimes nevertheless nothing other over as mere numerische modes To use. These having but too your Tücken, z.B. with Nullstellen or (+/-Infinity)-Polstellen. hereinafter get The worst entrapments abgefangen, but warranty is the still always no, that the with others Funktionstypen too works. means is it testing, checken, try - for what the nachstehende Progi helpful his could.
Window Title "Test: Numerische Differentiation (rose "+\
"in x to the Differenzenmethode)"
' *************************************************
' (CL) CopyLeft 2013-09 by P. woodpecker, Wien
' without jedwede Gewähr!
' *************************************************
proc FNY : parameters x!
return -1*10^-35' here comment, function hereinafter program:
return sin(x!)
endproc
' *************************************************
' *** Differenzenmethode, here optimiert for ***
' *** Winkelfunktionen in the area sew (+1..-1) ***
' *************************************************
proc Ableitung :parameters x!
var nenn!=x!*(1.000005-0.999995)
case nenn!=0:return 0
return (fny(x!*1.000005)-fny(x!*0.999995))/nenn!
endproc
Window Style 24:font 2:randomize
Window 0,0-%maxx,%maxy-40
var xh&=width(%hwnd)\2:var yh&=height(%hwnd)\2
if fny(1)=-1*10^-35
print "\n Abzuleitende function Please in Proc FNY(x) einprogrammieren!"
sound 770,100:sound 440,300
waitinput 10000
end
endif
declare xa!,xm!,xe!,xd!,y$,x!,y!
declare xl&,yl&,xn&,yn&
declare xo&,yo&,xm&,ym&
declare xp&,yp&,xq&,yq&
Print "\n present ex X-Start = ";:input xa!
print " To X-End = ";:input xe!
if xe!=0:xe!=8:xa!=-8:endif'== pure Laziness ====
print " Fehlerfunktion present? ";:input y$
case y$="":y$="Ja"
y$=upper$(left$(y$,1)):case y$="Y":y$="J"
'only Schleppwerte the unterschiedlichen Line-command:
xl&=0:yl&=yh& : xo&=0:yo&=yh& : xq&=0:yq&=yh&
x!=xa!
xd!=(xe!-xa!)/(2*xh&)
case xd!=0:xd!=1*10^-35
repeat
usepen 0,2,rgb(255,0,0)
y!=fny(x!)
xn&=(x!-xa!)/xd!
yn&=yh&-100*y!
line xl&,yl& - xn&,yn&
xl&=xn&:yl&=yn&
usepen 0,1,rgb(0,0,155)
y!=Ableitung(x!)
xm&=(x!-xa!)/xd!
ym&=yh& - 100*y!
line xo&,yo& - xm&,ym&
xo&=xm&:yo&=ym&
if y$="J"
usepen 0,1,rgb(0,255,0)
y!=Ableitung(x!)-cos(x!)
xq&=(x!-xa!)/xd!
yq&=yh& - 10^12*y!
line xp&,yp& - xq&,yq&
xp&=xq&:yp&=yq&
endif
x!=x!+xd!' STEP
until x!>xe!
waitinput
end
P.s.: on the most dangerous attend Divisionen through zero, same behind it are negatives Wurzelargumente one beliebter Exception- or quite Aufhängegrund. negatives Logarithmen make The thing too tensive, solid followed of To high greifenden Potenzfunktionen.. |
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 05/10/21 ▲ |
|
|
|