The attached code file provides an easy basic interface to the Wolfram Alpha API. Inspired by the wolframalpha module available for Python.
source("wa_lib.R")This requires an app ID. Sign into your wolfram account to generate one.
app_id <- ""
wa <- WolframClient(app_id)result <- wa$query("pi")## Querying wolfram alpha...
library(knitr)
kable(result$get_plaintext(), format = "html")| pod | id | plaintext |
|---|---|---|
| Input | Input | pi |
| Decimal approximation | DecimalApproximation | 3.1415926535897932384626433832795028841971693993751058... |
| Property | Property | pi is a transcendental number |
| Number line | NumberLine | |
| Continued fraction | ContinuedFraction | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, ...] |
| Alternative representations | AlternativeRepresentations:MathematicalFunctionIdentityData | pi = 180 ° |
| Alternative representations | AlternativeRepresentations:MathematicalFunctionIdentityData | pi = -i log(-1) |
| Alternative representations | AlternativeRepresentations:MathematicalFunctionIdentityData | pi = cos^(-1)(-1) |
| Series representations | SeriesRepresentations:MathematicalFunctionIdentityData | pi = 4 sum_(k=0)^infinity (-1)^k/(2 k+1) |
| Series representations | SeriesRepresentations:MathematicalFunctionIdentityData | pi = -2+2 sum_(k=1)^infinity 2^k/(binomial(2 k, k)) |
| Series representations | SeriesRepresentations:MathematicalFunctionIdentityData | pi = sum_(k=0)^infinity (50 k-6)/(2^k binomial(3 k, k)) |
| Integral representations | IntegralRepresentations:MathematicalFunctionIdentityData | pi = 2 integral_0^infinity 1/(t^2+1) dt |
| Integral representations | IntegralRepresentations:MathematicalFunctionIdentityData | pi = 4 integral_0^1 sqrt(1-t^2) dt |
| Integral representations | IntegralRepresentations:MathematicalFunctionIdentityData | pi = 2 integral_0^infinity (sin(t))/t dt |
result <- wa$query("ion equivalents of zinc chloride")## Querying wolfram alpha...
kable(result$get_plaintext(), format = "html")| pod | id | plaintext |
|---|---|---|
| Input interpretation | Input | zinc chloride | ion equivalents |
| Result | IonProperties:ChemicalData | Zn^(2+) (zinc) | 1 Cl^(-) (chloride) | 2 |