Public
Edited
Jan 21, 2024
1 fork
Insert cell
Insert cell
viewof mathNew = Inputs.textarea({label: "New", rows:5, value:`tempUnits = [['degC', 'degF', 'K', 'degR']];
t0 = 9 degC to tempUnits;
t1 = 10 degC to transpose(tempUnits);
result = flatten(t0 < t1)
resultFix = flatten(t0 to K< t1 to K)`})
Insert cell
{
pNew.clear()
pNew.evaluate(mathNew)
return {
result : pNew.get('result').valueOf(),
fixed : pNew.get('resultFix').valueOf(),
ok :pNew.evaluate('mean(result)')
}
}
Insert cell
viewof mathOld = Inputs.textarea({label: "Old", rows:6, value:`tempUnits = [['degC', 'degF', 'K', 'degR'], ['degC', 'degF', 'K', 'degR'], ['degC', 'degF', 'K', 'degR'], ['degC', 'degF', 'K', 'degR']];
t0 = 9 degC to tempUnits;
t1 = 10 degC to transpose(tempUnits);
result = flatten(t0 < t1)`})
Insert cell
{
pOld.clear()
pOld.evaluate(mathOld)
return pOld.get('result').valueOf()
}
Insert cell
pOld.evaluate(`
282.15 K < 283.15 K # true
282.15 K < 10 degC # false
282.15 K < 509.67 degR # true
282.15 K < 50 degF # false

9 degC < 283.15 K # true
9 degC < 10 degC # true
9 degC < 509.67 degR # true
9 degC < 50 degF # true

507.87 degR < 283.15 K # true
507.87 degR < 10 degC # false
507.87 degR < 509.67 degR # true
507.87 degR < 50 degF # false

48.2 degF < 283.15 K # true
48.2 degF < 10 degC # false
48.2 degF < 509.67 degR # true
48.2 degF < 50 degF # true
`).entries
Insert cell
math.format(pNew.evaluate('1 degC + 10 degC'))
Insert cell
math.format(pOld.evaluate('10 degC + 1 K'))
Insert cell
pOld.evaluate('0.1 kg/s * 4.2 J/K/g * 5 K').toString()
Insert cell
pOld.evaluate('0.1 kg/s * 4.2 J/K/g * (5 K)').toString()
Insert cell
math.format(pOld.evaluate('10 degC + 1 degC'))
Insert cell
pNew = math.parser()
Insert cell
pOld = math2.parser()
Insert cell
math = require("mathjs@12.3.0")
Insert cell
math2 = require("mathjs@10.4.1")
Insert cell
pOld.evaluate(`32 degF to degC`).toString()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more