Exp: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
|||
Zeile 24: | Zeile 24: | ||
<span class="mw-customtoggle-myDivision">[Anzeigen]</span> | <span class="mw-customtoggle-myDivision">[Anzeigen]</span> | ||
<syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | <syntaxhighlight lang="java" class="mw-collapsible mw-collapsed" id="mw-customcollapsible-myDivision"> | ||
@ | @BeforeClass | ||
public void beforeTest() { | public static void beforeTest() { | ||
fillInVariableMap.put(2, OMConverter.toObject("<OMOBJ><OMI>10</OMI></OMOBJ>")); | |||
exerciseVariableMap.put("b", OMConverter.toObject("<OMOBJ><OMI>10</OMI></OMOBJ>")); | |||
} | } | ||
@Test | @Test | ||
public void | public void testExp1() { | ||
assertEquals(1, Evaluator.getNumberResult("exp(0)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testExp2() { | ||
assertEquals(2.71828182845, Evaluator.getNumberResult("exp(1)", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testExp3() { | ||
assertEquals(0, Evaluator.getNumberResult("exp(-1000)", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testExp4() { | ||
assertEquals(0.9048374180359595, Evaluator.getNumberResult("exp(-0.1)", exerciseVariableMap, fillInVariableMap), | |||
0.0001); | |||
} | } | ||
@Test | @Test | ||
public void | public void testExpWithInput1() { | ||
assertEquals(1, Evaluator.getNumberResult("exp([pos=1])", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test | |||
public void testExpWithInput2() { | |||
assertEquals(22026.465794806718, | |||
Evaluator.getNumberResult("exp([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testExpWithVariables1() { | |||
assertEquals(1, Evaluator.getNumberResult("exp([var=a])", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | |||
public void testExpWithVariables2() { | |||
assertEquals(22026.465794806718, | |||
Evaluator.getNumberResult("exp([var=b])", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | |||
@Test | @Test | ||
public void | public void testExpWithExpressions() { | ||
assertEquals(1, Evaluator.getNumberResult("exp(exp(-1000))", exerciseVariableMap, fillInVariableMap), 0.0001); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidArgumentTypeException.class) | ||
public void | public void testExpWithWrongInputCharacter() { | ||
Evaluator.getNumberResult("exp(a)", exerciseVariableMap, fillInVariableMap); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void | public void testExpWithTwoArguments() { | ||
Evaluator.getNumberResult("exp(0, 1)", exerciseVariableMap, fillInVariableMap); | |||
} | } | ||
@Test(expected= | @Test(expected = FunctionInvalidNumberOfArgumentsException.class) | ||
public void | public void testExpWithThreeArguments() { | ||
Evaluator.getNumberResult("exp(1, 2.71, 2)", exerciseVariableMap, fillInVariableMap); | |||
} | } | ||
@Test(expected=UndefinedFillInVariableException.class) | @Test(expected = UndefinedExerciseVariableException.class) | ||
public void testExpWithMissingInput(){ | public void testExpWithMissingExerciseVariable() { | ||
Evaluator.getNumberResult("exp([var=j])", exerciseVariableMap, fillInVariableMap); | |||
} | } | ||
@Test(expected = UndefinedFillInVariableException.class) | |||
public void testExpWithMissingInput() { | |||
Evaluator.getNumberResult("getDenominator([pos=42])", exerciseVariableMap, fillInVariableMap); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Version vom 18. September 2017, 11:18 Uhr
Beschreibung
Die Funktion exp repräsentiert die Exponentialfunktion, sie gibt den Wert <math>e^x</math> an der Stelle x an. Die Funktion erwartet eine Zahl und gibt eine Zahl zurück.
Syntax
exp(float x)
Parameter
- x - der x-Wert der Exponentialfunktion
Return Value
- Gibt eine rationale Zahl zurück
Beispiele
Standardfälle
exp('1') --> returns 2.71828182845 exp('-0.1') --> returns 0.9048374180359595
Benutzung mit Variablen
exp('[pos=1]') exp('[var=a]')
JUnit Tests
[Anzeigen]
@BeforeClass
public static void beforeTest() {
fillInVariableMap.put(2, OMConverter.toObject("<OMOBJ><OMI>10</OMI></OMOBJ>"));
exerciseVariableMap.put("b", OMConverter.toObject("<OMOBJ><OMI>10</OMI></OMOBJ>"));
}
@Test
public void testExp1() {
assertEquals(1, Evaluator.getNumberResult("exp(0)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testExp2() {
assertEquals(2.71828182845, Evaluator.getNumberResult("exp(1)", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testExp3() {
assertEquals(0, Evaluator.getNumberResult("exp(-1000)", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testExp4() {
assertEquals(0.9048374180359595, Evaluator.getNumberResult("exp(-0.1)", exerciseVariableMap, fillInVariableMap),
0.0001);
}
@Test
public void testExpWithInput1() {
assertEquals(1, Evaluator.getNumberResult("exp([pos=1])", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testExpWithInput2() {
assertEquals(22026.465794806718,
Evaluator.getNumberResult("exp([pos=2])", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testExpWithVariables1() {
assertEquals(1, Evaluator.getNumberResult("exp([var=a])", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testExpWithVariables2() {
assertEquals(22026.465794806718,
Evaluator.getNumberResult("exp([var=b])", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test
public void testExpWithExpressions() {
assertEquals(1, Evaluator.getNumberResult("exp(exp(-1000))", exerciseVariableMap, fillInVariableMap), 0.0001);
}
@Test(expected = FunctionInvalidArgumentTypeException.class)
public void testExpWithWrongInputCharacter() {
Evaluator.getNumberResult("exp(a)", exerciseVariableMap, fillInVariableMap);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testExpWithTwoArguments() {
Evaluator.getNumberResult("exp(0, 1)", exerciseVariableMap, fillInVariableMap);
}
@Test(expected = FunctionInvalidNumberOfArgumentsException.class)
public void testExpWithThreeArguments() {
Evaluator.getNumberResult("exp(1, 2.71, 2)", exerciseVariableMap, fillInVariableMap);
}
@Test(expected = UndefinedExerciseVariableException.class)
public void testExpWithMissingExerciseVariable() {
Evaluator.getNumberResult("exp([var=j])", exerciseVariableMap, fillInVariableMap);
}
@Test(expected = UndefinedFillInVariableException.class)
public void testExpWithMissingInput() {
Evaluator.getNumberResult("getDenominator([pos=42])", exerciseVariableMap, fillInVariableMap);
}
Hinweise
- Aufgrund von der Rechengenauigkeit des Computers, wird in jedem Fall eine rationale Zahl zurückgegeben. Sollte der tatsächliche Funktionswert irrational sein, wird entsprechend gerundet.