num_solve {exams.forge}R Documentation

Target Variable Value

Description

Given a set of equations and some variables, num_solve tries to compute the value of the target variable. The equations y=f(x) are transformed to f(x)-y and the functions try to compute the roots of the equations using [stats::uniroot()]. If the computation fails, then, numeric(0) is returned, otherwise the "original" value. If target=='' then all computed values and steps are returned. The attribute compute contains a data frame.

toLatex.equation_solve returns a LaTeX representation of the solution way found by num_solve().

Usage

num_solve(target, eqs, tol = 1e-06)

## S3 method for class 'equation_solve'
toLatex(object, ...)

sequation(target, eqs, tol = 1e-06)

Arguments

target

character: name of the variable value to compute

eqs

an equations object

tol

numeric: maximal tolerance for stats::uniroot()

object

object of a class for which a toBibtex or toLatex method exists.

...

further arguments

Value

(for num_solve) Returns numeric(0), numeric(1), or a list of all (computed) values.

(For toLatex.equation_solve) A character vector.

Examples

# The equations describe the formulae for an confidence interval of the mean
e <- equations(o~x+c*s/sqrt(n), "v_o=\\bar{x}+c\\cdot\\frac{s^2}{n}", 
               u~x-c*s/sqrt(n), "v_u=\\bar{x}-c\\cdot\\frac{s^2}{n}", 
               e~c*s/sqrt(n),   "e  =c\\cdot\\frac{s^2}{\\sqrt{n}}",
               l~2*e,           "l  =2\\cdot e"                   
               )
e <- variables(e, 
               x=0,    "\\bar{x}",
               c=2.58, dbl(2), 
               s=1,    pos(5), "s^2",
               n=25,   pos(5),
               l=pos(5), 
               e=pos(5),
               u="v_u", o="v_o")
print(e)
# Find the confidence interval length
ns <- num_solve('l', e)
# Compute everything that is possible
 ns <- num_solve('', e)
toLatex(ns)


[Package exams.forge version 1.0.10 Index]