More copilot formulas, they lack description

This commit is contained in:
Álvaro González 2026-02-22 18:06:20 +01:00
parent 4356782a12
commit 6aefb47839
13 changed files with 145 additions and 0 deletions

View file

@ -0,0 +1,3 @@
[
{"name":"Temperature converter","description":"Example of simple formula, just unit conversion","input":[{"name":"Input","unit":"Kelvin"}],"output":{"name":"Output","unit":"Kelvin"},"d4rtCode":"Output = Input;","tags":["converter","temperature"]}
]

View file

@ -0,0 +1,5 @@
[
{"name":"Coulomb's Law","input":[{"name":"q1","unit":"coulomb"},{"name":"q2","unit":"coulomb"},{"name":"r","unit":"meter"}],"output":{"name":"F","unit":"newton"},"d4rtCode":"F = (8.9875517923e9 * q1 * q2) / pow(r, 2);","tags":["physics","electricity","electrostatics"]},
{"name":"Ohm's Law","input":[{"name":"I","unit":"ampere"},{"name":"R","unit":"ohm"}],"output":{"name":"V","unit":"volt"},"d4rtCode":"V = I * R;","tags":["physics","electricity","electronics"]},
{"name":"Electric Power","input":[{"name":"V","unit":"volt"},{"name":"I","unit":"ampere"}],"output":{"name":"P","unit":"watt"},"d4rtCode":"P = V * I;","tags":["physics","electricity","electronics"]}
]

View file

@ -0,0 +1,6 @@
[
{"name":"Kinetic Energy","input":[{"name":"m","unit":"kilogram"},{"name":"v","unit":"meters per second"}],"output":{"name":"KE","unit":"joule"},"d4rtCode":"KE = 0.5 * m * pow(v, 2);","tags":["physics","energy","mechanics"]},
{"name":"Work","input":[{"name":"F","unit":"newton"},{"name":"d","unit":"meter"},{"name":"theta","unit":"degree"}],"output":{"name":"W","unit":"joule"},"d4rtCode":"var thetaRad = theta * (pi / 180); W = F * d * cos(thetaRad);","tags":["physics","energy","mechanics"]},
{"name":"Power","input":[{"name":"W","unit":"joule"},{"name":"t","unit":"second"}],"output":{"name":"P","unit":"watt"},"d4rtCode":"P = W / t;","tags":["physics","energy","mechanics"]},
{"name":"Mass-Energy Equivalence","input":[{"name":"m","unit":"kilogram"}],"output":{"name":"E","unit":"joule"},"d4rtCode":"E = m * pow(299792458, 2);","tags":["physics","relativity","energy"]}
]

View file

@ -0,0 +1,5 @@
[
{"name":"Density","input":[{"name":"m","unit":"kilogram"},{"name":"V","unit":"cubic meter"}],"output":{"name":"rho","unit":"kilogram per cubic meter"},"d4rtCode":"rho = m / V;","tags":["physics","mechanics","material"]},
{"name":"Pressure","input":[{"name":"F","unit":"newton"},{"name":"A","unit":"square meter"}],"output":{"name":"P","unit":"pascal"},"d4rtCode":"P = F / A;","tags":["physics","mechanics","fluid"]},
{"name":"Buoyant Force","input":[{"name":"rho","unit":"kilogram per cubic meter"},{"name":"g","unit":"meters per square second"},{"name":"V","unit":"cubic meter"}],"output":{"name":"Fb","unit":"newton"},"d4rtCode":"Fb = rho * g * V;","tags":["physics","fluid","mechanics"]}
]

View file

@ -0,0 +1,111 @@
[
// Geometry formulas extracted from formulas.d4rt
// Area of Circle
{
"name": "Area of Circle",
"description": r'''\nArea enclosed by a circle\n\n$$A = \pi r^2$$\n\nWhere:\n- $A$: Area (square meters)\n- $r$: Radius (meters)\n- $\pi$: Pi ($\approx 3.14159$)\n\nThe area is proportional to the square of the radius.''',
"input": [
{"name": "r", "unit": "meter"} // Radius
],
"output": {"name": "A", "unit": "square meter"}, // Area
"d4rtCode": "A = pi * pow(r, 2);",
"tags": ["geometry", "circle", "area"]
},
// Circumference of Circle
{
"name": "Circumference of Circle",
"description": r'''\nPerimeter (distance around) a circle\n\n$$C = 2\pi r$$\n\nWhere:\n- $C$: Circumference (meters)\n- $r$: Radius (meters)\n- $\pi$: Pi ($\approx 3.14159$)\n\nThe circumference is proportional to the radius.''',
"input": [
{"name": "r", "unit": "meter"} // Radius
],
"output": {"name": "C", "unit": "meter"}, // Circumference
"d4rtCode": "C = 2 * pi * r;",
"tags": ["geometry", "circle", "perimeter"]
},
// Area of Triangle
{
"name": "Area of Triangle",
"description": r'''\nArea enclosed by a triangle\n\n$$A = \frac{1}{2}bh$$\n\nWhere:\n- $A$: Area (square meters)\n- $b$: Base length (meters)\n- $h$: Height perpendicular to base (meters)\n\nThis formula works for any triangle.''',
"input": [
{"name": "b", "unit": "meter"}, // Base
{"name": "h", "unit": "meter"} // Height
],
"output": {"name": "A", "unit": "square meter"}, // Area
"d4rtCode": "A = 0.5 * b * h;",
"tags": ["geometry", "triangle", "area"]
},
// Area of Rectangle
{
"name": "Area of Rectangle",
"description": r'''\nArea enclosed by a rectangle\n\n$$A = lw$$\n\nWhere:\n- $A$: Area (square meters)\n- $l$: Length (meters)\n- $w$: Width (meters)\n\nThe area is the product of length and width.''',
"input": [
{"name": "l", "unit": "meter"}, // Length
{"name": "w", "unit": "meter"} // Width
],
"output": {"name": "A", "unit": "square meter"}, // Area
"d4rtCode": "A = l * w;",
"tags": ["geometry", "rectangle", "area"]
},
// Area of Trapezoid
{
"name": "Area of Trapezoid",
"description": r'''\nArea enclosed by a trapezoid\n\n$$A = \frac{1}{2}(a+b)h$$\n\nWhere:\n- $A$: Area (square meters)\n- $a, b$: Lengths of parallel sides (meters)\n- $h$: Height (perpendicular distance between parallel sides, meters)\n\nThe area is the average of parallel sides times height.''',
"input": [
{"name": "a", "unit": "meter"}, // Parallel side 1
{"name": "b", "unit": "meter"}, // Parallel side 2
{"name": "h", "unit": "meter"} // Height
],
"output": {"name": "A", "unit": "square meter"}, // Area
"d4rtCode": "A = 0.5 * (a + b) * h;",
"tags": ["geometry", "trapezoid", "area"]
},
// Area of Regular Polygon
{
"name": "Area of Regular Polygon",
"description": r'''\nArea of a regular polygon with n sides\n\n$$A = \frac{1}{4}ns^2\cot(\frac{\pi}{n})$$\n\nWhere:\n- $A$: Area (square meters)\n- $n$: Number of sides\n- $s$: Side length (meters)\n- $\pi$: Pi ($\approx 3.14159$)\n\nThis formula works for any regular polygon (equal sides and angles).''',
"input": [
{"name": "n", "unit": "scalar"}, // Number of sides
{"name": "s", "unit": "meter"} // Side length
],
"output": {"name": "A", "unit": "square meter"}, // Area
"d4rtCode": "A = 0.25 * n * pow(s, 2) * (cos(pi/n) / sin(pi/n));",
"tags": ["geometry", "polygon", "area"]
},
// Sum of Interior Angles of Polygon
{
"name": "Sum of Interior Angles",
"description": r'''\nSum of interior angles of a polygon\n\n$$S = (n - 2) \times 180°$$\n\nWhere:\n- $S$: Sum of interior angles (degrees)\n- $n$: Number of sides\n\nThis formula works for any simple polygon.''',
"input": [
{"name": "n", "unit": "scalar"} // Number of sides
],
"output": {"name": "S", "unit": "degree"}, // Sum of angles
"d4rtCode": "S = (n - 2) * 180;",
"tags": ["geometry", "polygon", "angles"]
},
// Heron's Formula (Area of Triangle)
{
"name": "Heron's Formula",
"description": r'''\nArea of a triangle using only side lengths\n\n$$A = \sqrt{s(s-a)(s-b)(s-c)}$$\n\nWhere:\n- $A$: Area (square meters)\n- $a, b, c$: Side lengths (meters)\n- $s$: Semi-perimeter $= \frac{a+b+c}{2}$\n\nThis formula is useful when height is unknown.\n\n**Note:** The side lengths must satisfy the triangle inequality: the sum of any two sides must be greater than the third side (a+b>c, a+c>b, b+c>a). If this condition is not met, the formula returns NaN.''',
"input": [
{"name": "a", "unit": "meter"}, // Side 1
{"name": "b", "unit": "meter"}, // Side 2
{"name": "c", "unit": "meter"} // Side 3
],
"output": {"name": "A", "unit": "square meter"}, // Area
"d4rtCode": """
if( a + b < c || a+c < b || b+c < a ){
signal( "There is not a valid triangle with those longitudes" );
}
var s = (a + b + c) / 2;
A = sqrt(s * (s - a) * (s - b) * (s - c));
""",
"tags": ["geometry", "triangle", "area"]
}
]

View file

View file

@ -0,0 +1,3 @@
[
{"name":"Hooke's Law","input":[{"name":"k","unit":"newton per meter"},{"name":"x","unit":"meter"}],"output":{"name":"F","unit":"newton"},"d4rtCode":"F = -k * x;","tags":["physics","elasticity","oscillations"]}
]

View file

@ -0,0 +1,3 @@
[
{"name":"Apgar Score","input":[{"name":"HeartRate","values":["Absent","< 100 bpm>","> 100 bpm"]},{"name":"Breathing","values":["Absent","Weak, irregular","Strong, robust cry"]},{"name":"MuscleTone","values":["None","Some","Flexed arms/leg, resists extension"]},{"name":"Reflexes","values":["No response","Grimace on aggressive stimulation","Cry on stimulation"]},{"name":"SkinColor","values":["Blue or pale","Blue extremities, pink body","Pink"]}],"output":{"name":"Result","unit":"string"},"d4rtCode":"var total = indexOf(\"HeartRate\") + indexOf(\"Breathing\") + indexOf(\"MuscleTone\") + indexOf(\"Reflexes\") + indexOf(\"SkinColor\"); late var interpretation; if( total < 4 ) { interpretation = 'Critical condition'; } else if( total < 7 ){ interpretation = 'Needs assistance'; } else { interpretation = 'Normal'; } Result = 'Score: \$total - \$interpretation';","tags":["medical","pediatrics","assessment"]}
]

View file

@ -0,0 +1,3 @@
[
{"name":"Compare price per mass","description":"Compares two products by their price per mass and returns which is cheaper, including price per kg for each product.","input":[{"name":"price1","unit":"currency"},{"name":"mass1","unit":"kilogram"},{"name":"price2","unit":"currency"},{"name":"mass2","unit":"kilogram"}],"output":{"name":"Result","unit":"string"},"d4rtCode":"var p1 = price1 / mass1; var p2 = price2 / mass2; if (p1 < p2) { Result = 'first product is cheaper at \$\{p1.toStringAsFixed(2)\} currency/kg vs \$\{p2.toStringAsFixed(2)\} currency/kg'; } else if (p2 < p1) { Result = 'second product is cheaper at \$\{p2.toStringAsFixed(2)\} currency/kg vs \$\{p1.toStringAsFixed(2)\} currency/kg'; } else { Result = 'both products have the same price per mass at \$\{p1.toStringAsFixed(2)\} currency/kg'; }","tags":["comparison","shopping","economics"]}
]

View file

@ -0,0 +1,3 @@
[
{"name":"Snell's Law","input":[{"name":"n1","unit":"scalar"},{"name":"n2","unit":"scalar"},{"name":"theta1","unit":"degree"}],"output":{"name":"theta2","unit":"degree"},"d4rtCode":"var theta1Rad = theta1 * (pi / 180); var sinTheta2 = (n1 * sin(theta1Rad)) / n2; theta2 = asin(sinTheta2) * (180 / pi);","tags":["physics","optics","light"]}
]

View file

@ -0,0 +1,3 @@
[
{"name":"Ideal Gas Law","input":[{"name":"n","unit":"mole"},{"name":"T","unit":"kelvin"},{"name":"V","unit":"cubic meter"}],"output":{"name":"P","unit":"pascal"},"d4rtCode":"P = (n * 8.314462618 * T) / V;","tags":["physics","thermodynamics","gas"]}
]

View file