Basisanwendungen | Basic Applications

Inhalt | content


"Taschen"rechner | Calculator

- Beispiel 1 | Example 1

= #JxnPortable\docs\applet_examples\Calculator1.jxn

! <- DE: Kommentare beginnen mit '!'
! <- EN: comments start with '!'

! DE: einfache Arithmetik
! EN: simple arithmetic
3 + 5
 = 8 (int)
10.7 - 25 / 8
 = 7.574999999999999 (double)
! DE: Zeilen, die mit " = " beginnen, enthalten Rechenergebnisse: = Wert (Datentyp)
! EN: lines starting with " = " show the generated results: = value (data type)

! DE: Arithmetik mit Variablen
! EN: arithmetic with variables
a = 3
 = 3 (int)
b = 5.5
 = 5.5 (double)
a ( b - 2^a )
 = -7.5 (double)
! DE: jxn verwendet '^' als Exponentiationsoperator
! EN: jxn (other than Java) uses '^' as exponentiation operator


DE: Bitte geben Sie eigene Berechnungen z.B.  3+5  in die Eingabezeile ein und drücken Sie die Eingabetaste [ ↵ ].  
EN: Please enter your calculations e.g.  3+5  into the input field and press the enter [ ↵ ] key.

- Beispiel 2 | Example 2

= #JxnPortable\docs\applet_examples\Calculator2.jxn

! arithmetic with mathematical functions:
phi = PI / 3
 = 1.0471975511965976 (double)
sn = sin( phi )
 = 0.8660254037844386 (double)
cs = cos( phi )
 = 0.5000000000000001 (double)
sn^2 + cs^2
 = 1.0 (double)

! arithmetic with complex values:
z = 3 + j 4
 = 3.0 + j 4.0 = 5.0 <) 53.13010235415598° (JxnComplexAlgebra)
z + conj(z)
 = 6.0 + j 0.0 = 6.0 <) 0.0° (JxnComplexAlgebra)
j * sqrt( 5 * z )
 = -2.23606797749979 + j 4.47213595499958 = 5.0 <) 116.56505117707799° (JxnComplexAlgebra)
DE: Bitte geben Sie eigene Berechnungen in die Eingabezeile ein.  
EN: Please enter your calculations into the input field. Try methods from → java.lang.Math and JxnComplexAlgebra.

- Beispiel 3 | Example 3

= #JxnPortable\docs\applet_examples\Calculator3.jxn

z = 3 + j 4
 = 3.0 + j 4.0 = 5.0 <) 53.13010235415598° (JxnComplexAlgebra)
!
! simplified entry of expressions:
! '*' operator may be omitted, single parameter function brackets '(' single parameter ')' may be omitted
!
! equivalent expressions:
sqrt( 5 * z ) * j
 = -2.23606797749979 + j 4.47213595499958 = 5.0 <) 116.56505117707799° (JxnComplexAlgebra)
sqrt 5 z * j
 = -2.23606797749979 + j 4.47213595499958 = 5.0 <) 116.56505117707799° (JxnComplexAlgebra)
sqrt( 5 z ) j
 = -2.23606797749979 + j 4.47213595499958 = 5.0 <) 116.56505117707799° (JxnComplexAlgebra)
( sqrt 5 z ) j
 = -2.23606797749979 + j 4.47213595499958 = 5.0 <) 116.56505117707799° (JxnComplexAlgebra)
j sqrt 5 z
 = -2.23606797749979 + j 4.47213595499958 = 5.0 <) 116.56505117707799° (JxnComplexAlgebra)
j * sqrt( 5 * z )
 = -2.23606797749979 + j 4.47213595499958 = 5.0 <) 116.56505117707799° (JxnComplexAlgebra)
!
! but:
sqrt 5 z j
 = 1.5811388300841898 + j 4.743416490252569 = 5.0 <) 71.56505117707799° (JxnComplexAlgebra)
sqrt( 5 * z * j )
 = 1.5811388300841898 + j 4.743416490252569 = 5.0 <) 71.56505117707799° (JxnComplexAlgebra)
DE: Bitte geben Sie eigene Berechnungen in die Eingabezeile ein. Siehe auch Benutzerhinweise und SimplifiedSyntaxTable.
EN: Please enter your calculations into the input field. Also see User Notes and SimplifiedSyntaxTable.

Funktionsplotter | function plotter

= #JxnPortable\docs\applet_examples\FunctionPlotter.jxn

! example 1: plot( x, y(x) )
!            with y(x) = x^3 + 2 * x^2 - 48 * x
x ! is predefined as:
 = {-10.0, -9.95, ... 10.0}[401] (JxnRealArrayAlgebra)
pf1 = plot( x, x^3 + 2 x^2 - 48 x ).setXYLabels( "x", "y" )
pf1.setPlotFrameTitle( "example 1: y = x^3 + 2 x^2 - 48 x" )

! example 2a: plot( t, x(t), y(t) )  ! 2 curves
! example 2b: plot( x(t), y(t) )  ! parametric representation 
!             with x(t) = exp( -4 * t ) * cos( 10 * PI * t ); y(t) = ...
t ! is predefined as:
 = {0.0, 0.002, ... 1.0}[501] (JxnRealArrayAlgebra)
xt = exp -4 t * cos 10 PI t
yt = exp -4 t * sin 10 PI t
plot( t,  xt, yt ).setPlotFrameTitle( "example 2a: plot( t, xt, yt )"  ).setXYLabels( "t", "x(t), y(t)" )
plot( xt, yt, 1. ).setPlotFrameTitle( "example 2b: plot( xt, yt, 1. )" ).setXYLabels( "x(t)", "y(t)" )


DE: Durch Anklicken einer Formel wird diese in die Eingabezeile übernommen, kann dort abgeändert und mit der Eingabetaste [ ↵ ] ausgeführt werden (Benutzerhinweise).  
EN: Clicking an expression transfers the line into the input field where ist can be modified and executed again pressing the enter [ ↵ ] key (User Notes).

Komplexe Zeiger | Complex Phasors

= #JxnPortable\docs\applet_examples\ComplexPhasors.jxn

a = 2 + j 3
b = 4 + j 2
pf1 = plot( a, "a", B ).apnd( b, "b", R ).add( a+b, "a+b", M ).setXYLabels( "re", "im" )
pf1.add( a, -b, "-b", G ).add( a-b, "a-b", C ).setPlotFrameTitle( "Complex Phasors" )

Z = 1200 + j 900
U = 1000 + 0j
I = U / Z
S = U conj I
pf2 = plot90( U, "U", B ).add( 1000 I, "I", R ).add( S, "S", G ).setXYLabels( "im", "re" )
pf2.setPlotFrameTitle( "U/V,  I/mA,  S/VA,  Z = ( 1200 + j 900 )\#937" )


DE: Bitte vergleichen Sie die Zeiger im Diagramm "Complex Phasors" mit den unterschiedlichen add(…) und apnd(…) Methoden in den mit pf1 beginnenden Zeilen.  
EN: Please compare the phasors in the diagram "Complex Phasors" with the different add(…) and apnd(…) methods in the command lines starting with pf1 .

Slider Animation

- Beispiel 1 | Example 1

= #JxnPortable\docs\applet_examples\SliderAnimation1.jxn

slider = @JxnSliderPanel($this);
!
!               name start   min   max
a = slider.add( "a",   1.,   -1.,   1. )
b = slider.add( "b",  -1.,  -10.,  10. )
c = slider.add( "c", -50., -100., 100. )
!
pf = plot( x, a ( x - b )^2 + c ).setAutoScale(1)
!
! optional dynamic title:
pf.setPlotFrameTitle( " y = " + format(a,2) + " ( x" + format(b,-2) + " )^2" + format(c,-2) )
pf.setXYLabels( "x", "y" )


DE: Ändern Sie mit dem Schieberegler die Variablen a, b und c.  
EN: Use the slider to change the variables a, b, and c.

- Beispiel 2 | Example 2

 see Wikipedia: → Lissajous-Figur  |  → Lissajous curve
= #JxnPortable\docs\applet_examples\SliderAnimation2_LissajousCurve.jxn

#ifndef slider
slider = @JxnSliderPanel($this);
#endif
!
!                 name start min  max  
f1  = slider.add( "f1",  5.,  0., 10. )
f2  = slider.add( "f2",  7.,  0., 10. )
phi = slider.add( "phi", 0., -1.,  1. )
!
x = cos( 2 PI   f1 t )
y = cos( 2 PI ( f2 t + phi ) )
!
plot( t, x, y ).setXYLabels( "t", "x, y" ).setPlotFrameTitle( "red: x(t), blue: y(t)" )
plot( x, y ).setXYLabels( "x", "y" ).setPlotFrameTitle( "Lissajous curve" )


DE: Menü JxnSession: File > Edit...   => JxnEditor: Edit > input only  => Quelle ändern ...   => Run > replace & close   (siehe Beschreibung der Menü Befehle).
EN: Menu JxnSession: File > Edit...   => JxnEditor: Edit > input only  => modify source ...   => Run > replace & close   (see details on menu items).