Der MPR als wissenschaftlicher Rechner: Der EVAL-Befehl

Moderator: MVogt

Post Reply
User avatar
Theo_Gottwald
Posts: 367
Joined: 03. Oct 2009, 08:57
Location: Herrenstr.11 * 76706 Dettenheim
Contact:

Der MPR als wissenschaftlicher Rechner: Der EVAL-Befehl

Post by Theo_Gottwald » 06. Sep 2019, 10:56

Mit dem kommenden Update funktioniert nun auch der EVAL-Befehl wie er soll.
Damit wird der MPR zum wissenschaftlichen Taschenrechner!

Der EVAL-Befehl hat eine ganze Menge Features, die die der "normale" CAL\-Befehl nicht bietet. Dazu gehören:
  • Möglich sind alle Operatoren wie: + - * / \ ^ ! ( ) < = > <> >= <=
  • Mit erweiterter Genauigkeit werden 18 Stellen Genauigkeit berechnet. Fakultäten "!" werden bis 1754 berechnet ohne Überlauf.
  • Beliebige Verwendung von Klammern und geschachtelten Klammern
  • Korrekte Berechnung von Punkt vor Strich
  • Ganzzahl-Division mit \
  • Exponent "^" und Faktorial "!" Berechnungen
  • Modulo (MOD)
  • relational operatoren (<, <=, =, >=, >, <> ) - hier ist das Ergebnis immer 0 (falsch) oder -1 (wahr)
  • Möglichkeit Entscheidungen zu kodieren mit den relationalen Operatoren
  • NOT, ISFALSE and ISTRUE
  • AND, Or und XOR sowie EQV und IMP - als Binäre Operatoren (zum Maskieren von Ergebnissen)

Dazu die Konstanten:
PI# - Constant (3.14159..)
E# - Constant (2.71828..)
Beispiel:

Code: Select all

VAR\$$NUM=100
GRN\m_eval|PI#+E#|>$$RES
' Result is 5.85987448204884
MBX\Result: $$RES
@

und viele mathematische Funktionen die der CAL\-Befehl nicht kennt.
"ARCSINH() - Arc (Inverse) Hyperbolic Sine"
"ARCCOSH() - Arc (Inverse) Hyperbolic Cosine"
"ARCTANH() - Arc (Inverse) Hyperbolic Tangent"
"ARCSECH() - Arc (Inverse) Hyperbolic Secant"
"ARCCSCH() - Arc (Inverse) Hyperbolic Cosecant"
"ARCCOTH() - Arc (Inverse) Hyperbolic Cotangent"
"ARCSIN() - Arc (Inverse) Sine"
"ARCCOS() - Arc (Inverse) Cosine"
"ARCSEC() - Arc (Inverse) Secant"
"ARCCSC() - Arc (Inverse) Cosecant"
"ARCCOT() - Arc (Inverse) Cotangent"
"SINH() - Hyperbolic Sine","TANH() - Hyperbolic Tangent"
"SECH() - Hyperbolic Secant"
"CSCH() - Hyperbolic Cosecant"
"COTH() - Hyperbolic Cotangent"

"SEC() - Secant"
"CSC() - Cosecant"
"COT() - Cotangent"
"SIN() - Sine","COS() - Cosine"
"TAN() - Tangent"
"ATN() - Arc (Inverse) Tangent"

"LN() - Natural Log (base E)"
"EXP2() - Exponentiation of 2 or Antilog 2"
"EXP10() - Exponentiation of 10 or Antilog 10"
"EXP() - Exponentiation of E or Antilog E"

"SQR() - Square Root","LOG10() - Common Log (base 10)"

"ABS() - Absolute Value"

"LOG2() - Log (base 2)"
"LOG() - Natural Log (base E)"

Logische Operatoren
"AND - Logical AND"
"XOR - Logical XOR (Exclusive OR)"
"OR - Logical OR"

"MOD - MOD (Modulo)"
"IMP - Logical IMP (Implication)"
"EQV - Logical EQV (Equivalence)"

"NOT - NOT","ISTRUE - Logical Truth"
"ISFALSE - Logical Falsity"

Rundungen:
"CEIL() - Ceiling"
"FRAC() - Fractional Part"
"FIX() - Truncate To Integer"
"SGN() - Sign"
Natürlich können auch die normalen MPR-Variablen verwendet werden:

Code: Select all

VAR\$$NUM=100
GRN\m_eval|ARCSINH($$NUM)|>$$RES
' Result ist  5.29834236561059
MBX\Result:$$RES
@
Es gibt dazu eine Menge an Konstanten die der Rechner schon kennt und die Formeln leserlicher machen:
"Foot_TO_meter" = "*1/ 3.28084"
"Meter_TO_foot" , "* 3.28084"
"Inch_TO_centimeter" , "* 2.54"
"Centimeter_TO_inch" , "*1 / 2.54"
"Kilometer_TO_mile" , "*1 / 1.609344"
"Mile_TO_kilometer" , "* 1.609344"
"Inch_TO_foot" , "*1 / 12"
"Foot_TO_inch" , "* 12"
"Yard_TO_meter" , "*1 / 1.093613"
"Meter_TO_yard" , "* 1.093613"
"Fathom_TO_meter" , "* 1.8288"
"Meter_TO_fathom" , "*1 / 1.8288"
"Mile_TO_light-year" , "*1 / 5880000000000"
"Light-year_TO_mile" , "* 5880000000000"
"Parsec_TO_light-year" , "* 3.261643"
"Light-year_TO_parsec" , "*1 / 3.261643"
"Square_ft_TO_square_m" , "*1 / 10.76391"
"Square_m_TO_square_ft" , "* 10.76391"
"Square_in_TO_square_cm" , "* 6.4516"
"Square_cm_TO_square_in" , "*1 / 6.4516"
"Hectare_TO_acre" , "* 2.471054"
"Acre_TO_hectare" , "*1 / 2.471054"
"Pound_TO_kilogram" , "*1 / 2.204623"
"Kilogram_TO_pound" , "* 2.204623"
"Ton_(metric)_TO_Kilogram" , "* 1000"
"Kilogram_TO_ton_(metric)" , "*1 / 1000"
"Ton_(US)_TO_Kilogram" , "* 907.18474"
"Kilogram_TO_ton_(US)" , "*1 / 907.18474"
"Ton_(UK)_TO_Kilogram" , "* 1016.046909"
"Kilogram_TO_ton_(UK)" , "*1 / 1016.046909"
"Ounce_(avoirdupois)_TO_gram" , "* 28.349551"
"Gram_TO_ounce_(avoirdupois)" , "*1 / 28.349551"
"Ounce_(troy)_TO_gram" , "* 31.103508"
"Gram_TO_ounce_(troy)" , "*1 / 31.103508"
"Fahrenheit_TO_Celsius" , "*1 / 1.8 - 32 / 1.8"
"Celsius_TO_Fahrenheit" , "* 1.8 + 32"
"Celsius_TO_Kelvin" , "*1 + 273.16"
"Kelvin_TO_Celsius" , "*1 - 273.16"
"Gallon_(US_dry)_TO_liter" , "* 4.404884"
"Liter_TO_gallon_(US_dry)" , "*1 / 4.404884"
"Gallon_(US_liquid)_TO_liter" , "* 3.785412"
"Liter_TO_gallon_(US_liquid)" , "*1 / 3.785412"
"Quart_(US_dry)_TO_gallon_(US_dry)" , "*1 / 4"
"Gallon_(US_dry)_TO_quart_(US_dry)" , "* 4"
"Pint_TO_liter_(US_dry)" , "* 0.55061"
"Liter_TO_pint_(US_dry)" , "*1 / 0.55061"
"Pint_TO_liter_(US_liquid)" , "* 0.473176"
"Liter_TO_pint_(US_liquid)" , "*1 / 0.473176"
"Cubic_ft_TO_cubic_m" , "*1 / 35.314667"
"Cubic_m_TO_cubic_ft" , "* 35.314667"
"Horsepower_(elec.)_TO_watt" , "* 745.7"
"Watt_TO_horsepower_(elec.)" , "*1 / 745.7"
"Horsepower_(metric)_TO_watt" , "* 735.499"
"Watt_TO_horsepower_(metric)" , "*1 / 735.499"
"BTU/hour_TO_watt" , "* 0.293071"
"Watt_TO_BTU/hour" , "*1 / 0.293071"
"Kilowatt_TO_watt" , "* 1000"
"Watt_TO_kilowatt" , "*1 / 1000"
"Kph_TO_mph" , "*1 / 1.609344"
"Mph_TO_kph" , "* 1.609344"
"Knot_TO_mph" , "* 1.150778"
"Mph_TO_knot" , "*1 / 1.150778"
"Meter/sec_TO_ft/sec" , "* 3.28084"
"Ft/sec_TO_meter/sec" , "*1 / 3.28084"
"Second_TO_minute" , "*1 / 60"
"Minute_TO_second" , "* 60"
"Minute_TO_hour" , "*1 / 60"
"Hour_TO_minute" , "* 60"
"Minute_TO_day" , "*1 / 1440"
"Day_TO_minute" , "* 1440"
"Day_TO_hour" , "* 24"
"Hour_TO_day" , "*1 / 24"
"Psi_TO_pascal" , "* 6894.757"
"Pascal_TO_psi" , "*1 / 6894.757"
"Psi_TO_atmosphere" , "* 0.068046"
"Atmosphere_TO_psi" , "*1 / 0.068046"
"Psi_TO_kg/sqcm" , "* 0.070307"
"Kg/sqcm_TO_psi" , "*1 / 0.070307"
"Degrees_TO_radians" , "* 1.74532925199432958E-2
"Radians_TO_degrees" , "*1 / 1.74532925199432958E-2
Hier ein Beispiel für die Anwendung einer solchen vordefinierten Konstante:

Code: Select all

VAR\$$NUM=100
GRN\m_eval|$$NUM*Meter_TO_foot|>$$RES
' Result is 328.084
MBX\Result: $$RES
Ebenso gibt es diese "Conversions", die wissenschaftliche Berechnungen vereinfachen und lesbarer machen.
"Acceleration_of_gravity_(m/sec²)" , "9.80665"
"Dry_air_density_at_STP_(kg/m³)" , "1.293"
"Light_speed_in_a_vacuum_(m/sec)" , "299792458"
"Solar_constant_(watts/m²)" , "1340"
"Sound_speed_at_STP_(m/sec)" , "331.4"
"Standard_atmosphere_(nt/m²)" , "101300"
"Earth_equatorial_radius_(m)" , "6378000"
"Earth_escape_velcity_(m/sec)" , "11186"
"Earth_magnetic_dipole_moment_(amp-m²)" , "6.400E21"
"Earth_mass_(kg)" , "5.983E24"
"Earth_mean_angular_rotational_speed_(rads/sec)" , ".0000729"
"Earth_mean_density_(kg/m³)" , "5522"
"Earth_mean_orbital_speed_(m/sec)" , "29770"
"Earth_polar_radius_(m)" , "6357000"
"Earth_volume_(m³)" , "1.087E21"
"Alpha_particle_mass_(kg)" , "6.64465598E-27"
"Electron_charge-mass_ratio_(coul/kg)" , "175881961000"
"Electron_rest_mass_(kg)" , "9.10938188E-31"
"Muon_rest_mass_(kg)" , "1.88353109E-28"
"Neutron_rest_mass_(kg)" , "1.67492716E-27"
"Proton_rest_mass_(kg)" , "1.67262158E-27"
"Atomic_mass_constant_(kg)" , "1.66053873E-27"
"Avogadro_constant_(1/mole)" , "6.02214199E23"
"Boltzmann_constant_(joule/K)" , "1.3806503E-23"
"Elementary_charge_(coul)" , "1.602176462E-19"
"Faraday_constant_(coul/mole)" , "96485.3415"
"Gravitational_constant_(nt-m²/kg²)" , ".000000000066726"
"Permeability_constant_(henry/m)" , "1.25663706143E-6"
"Permittivity_constant_(farad/m)" , "8.85418781762E-12"
"Planck_constant_(joule-sec)" , "6.62606876E-34"
"Rydberg_constant_(1/m)" , "10973731.568549"
"Stefan-Boltzmann_constant_(watt/m²K4)" , ".000000056704"
"Universal_gas_constant_(joule/K-mole)" , "8.314472"
"Wien_displacement_constant_(m-K)" , ".00290"
Hier ein Beispiel für die Anwendung einer solchen vordefinierten Konversion:

Code: Select all

VAR\$$NUM=100
GRN\m_eval|Light_speed_in_a_vacuum_(m/sec)*5|>$$RES
' Result ist: 1498962290
MBX\Result: $$RES
@
Die Winkeleingabe kann in Grad oder Bogenmaß erfolgen, abhängig davon, ob Sie das "#" als zusätzliches Flag angeben.
Die trigonometrische Ausgabe unter Verwendung der ARC-Funktionen erfolgt jedoch immer im Bogenmaß.
Sie können Winkel in Bogenmaß umwandeln und umgekehrt.

Beispiel:

Code: Select all

VAR\$$FOR=SIN(1)*Inch_TO_centimeter
' Die Angabe des |# bewirkt Winkelerechnungen in "Degree" statt "Radian"
GRN\m_eval|$$FOR|#
VAR\$$RES=$v1$
MBX\$$RES

VAR\$$FOR=(5*Inch_TO_centimeter)*Acceleration_of_gravity_(m/sec²)
GRN\m_eval|$$FOR|#>$$RES
MBX\$$RES
Kodieren von Entscheidungen mit EVAL.

Regular unterstützt der MPR zwar IVV\ (IF THEN) bietet hier aber keine Optionen für "AND" oder "OR" etc. an.
Mittel EVAL lassen sich nun beliebig komplexe Abfragen definieren.

Code: Select all

VAR\$$NUA=100
VAR\$$NUB=50
' Wenn Wert 1> Wert2 UND Wert1>50 DANN ist das Ergebnis "-1" sonst ist das Ergebnis 0
GRN\m_eval|$$NUA>$$NUB AND($$NUA>50)|>$$RES
IVV\$$RES!0
  MBX\Bedingung ist erfüllt
EVV\

Post Reply

Return to “Package Robot”

Who is online

Users browsing this forum: No registered users and 1 guest