From 1bcf829525a6da32994b75d85bce396e9a71a368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Gonz=C3=A1lez?= Date: Tue, 24 Feb 2026 10:21:07 +0100 Subject: [PATCH] more formulas --- TODO.md | 4 + .../formulas/conversions_and_constants.d4rt | 15 +- assets/formulas/electromagnetism.d4rt | 75 +- assets/formulas/energy_and_power.d4rt | 70 +- assets/formulas/fluids_and_pressure.d4rt | 52 +- assets/formulas/formulas.d4rt | 773 +++--------------- assets/formulas/geometry.d4rt | 145 +++- assets/formulas/gravity.d4rt | 0 assets/formulas/kinematics_and_dynamics.d4rt | 0 assets/formulas/materials_elasticity.d4rt | 20 +- assets/formulas/medical_and_bio.d4rt | 32 +- assets/formulas/misc_math.d4rt | 25 +- assets/formulas/optics.d4rt | 29 +- assets/formulas/thermodynamics.d4rt | 17 +- lib/defaults/default_corpus.dart | 8 +- pubspec.lock | 32 +- 16 files changed, 527 insertions(+), 770 deletions(-) delete mode 100644 assets/formulas/gravity.d4rt delete mode 100644 assets/formulas/kinematics_and_dynamics.d4rt diff --git a/TODO.md b/TODO.md index 1107f1e..ca55009 100644 --- a/TODO.md +++ b/TODO.md @@ -32,4 +32,8 @@ - [X] Add a Share button to the formula list. It will export the array string literal of the formula with the units from Corpus.withDependencies(). - [X] Replace flutter-markdown with flutter-markdown-plus - [X] Heron's formula: investigate why a=3, b=40, c=5 yields NaN. Root cause: input values don't form a valid triangle (violate triangle inequality: 3+5=8 is not > 40). Added documentation note to the formula description. +- [R] Refactor ./assets/formulas d4rt files: + - [R] Pretty print files as dart literals (like JSON, but allow raw strings r"""like this""") + - [R] Ensure there is no formula duplicates. If necesary, move or delete the formula in file formulas.d4rt + - [R] defaultCorpus must load all formula files - [ ] Investigate starup time when there is no previous database and corpus is loaded from assets. diff --git a/assets/formulas/conversions_and_constants.d4rt b/assets/formulas/conversions_and_constants.d4rt index a3f0de0..1353e9e 100644 --- a/assets/formulas/conversions_and_constants.d4rt +++ b/assets/formulas/conversions_and_constants.d4rt @@ -1,5 +1,8 @@ [ - {"name":"Temperature converter","description":r""" + // Temperature Converter + { + "name": "Temperature converter", + "description": r""" Simple temperature converter example that returns the input value (Kelvin) as output. Formula: $$T_{out} = T_{in}$$ @@ -7,6 +10,12 @@ Formula: $$T_{out} = T_{in}$$ Inputs: `Input` in kelvin (K). Output: `Output` in kelvin (K). -![Temperature scales (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Temperature_scales.svg/800px-Temperature_scales.svg.png) -""","input":[{"name":"Input","unit":"Kelvin"}],"output":{"name":"Output","unit":"Kelvin"},"d4rtCode":"Output = Input;","tags":["converter","temperature"]} +![Temperature scales (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/Comparison_of_temperature_scales.svg/960px-Comparison_of_temperature_scales.svg.png)""", + "input": [ + {"name": "Input", "unit": "Kelvin"} + ], + "output": {"name": "Output", "unit": "Kelvin"}, + "d4rtCode": "Output = Input;", + "tags": ["converter", "temperature"] + } ] diff --git a/assets/formulas/electromagnetism.d4rt b/assets/formulas/electromagnetism.d4rt index 49c6af7..b5ba790 100644 --- a/assets/formulas/electromagnetism.d4rt +++ b/assets/formulas/electromagnetism.d4rt @@ -1,20 +1,59 @@ [ - {"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);","description":r""" - Calculates the magnitude of the electrostatic force between two point charges. - Formula: $F = k \dfrac{q_1 q_2}{r^2}$ where $k = 8.9875517923\times10^9\ \mathrm{N\,m^2/C^2}$. - Inputs: `q1`, `q2` in coulombs; `r` in meters. - Output: Force `F` in newtons (N). - ""","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;","description":r""" - Relates voltage, current and resistance for a linear resistor. - Formula: $V = I\,R$. - Inputs: current `I` in amperes (A), resistance `R` in ohms (Ω). - Output: voltage `V` in volts (V). - ""","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;","description":r""" - Calculates electrical power delivered to a load. - Formula: $P = V\,I$ (also $P = I^2 R$ or $P = V^2 / R$ when substituting Ohm's law). - Inputs: voltage `V` in volts (V), current `I` in amperes (A). - Output: power `P` in watts (W). - ""","tags":["physics","electricity","electronics"]} + // Coulomb's Law + { + "name": "Coulomb's Law", + "description": r""" +Calculates the magnitude of the electrostatic force between two point charges. + +Formula: $F = k \dfrac{q_1 q_2}{r^2}$ where $k = 8.9875517923\times10^9\ \mathrm{N\,m^2/C^2}$. + +Inputs: `q1`, `q2` in coulombs; `r` in meters. +Output: Force `F` in newtons (N).""", + "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"] + }, + + // Ohm's Law + { + "name": "Ohm's Law", + "description": r""" +Relates voltage, current and resistance for a linear resistor. + +Formula: $V = I\,R$. + +Inputs: current `I` in amperes (A), resistance `R` in ohms (Ω). +Output: voltage `V` in volts (V).""", + "input": [ + {"name": "I", "unit": "ampere"}, + {"name": "R", "unit": "ohm"} + ], + "output": {"name": "V", "unit": "volt"}, + "d4rtCode": "V = I * R;", + "tags": ["physics", "electricity", "electronics"] + }, + + // Electric Power + { + "name": "Electric Power", + "description": r""" +Calculates electrical power delivered to a load. + +Formula: $P = V\,I$ (also $P = I^2 R$ or $P = V^2 / R$ when substituting Ohm's law). + +Inputs: voltage `V` in volts (V), current `I` in amperes (A). +Output: power `P` in watts (W).""", + "input": [ + {"name": "V", "unit": "volt"}, + {"name": "I", "unit": "ampere"} + ], + "output": {"name": "P", "unit": "watt"}, + "d4rtCode": "P = V * I;", + "tags": ["physics", "electricity", "electronics"] + } ] diff --git a/assets/formulas/energy_and_power.d4rt b/assets/formulas/energy_and_power.d4rt index f4d5322..ea0e46c 100644 --- a/assets/formulas/energy_and_power.d4rt +++ b/assets/formulas/energy_and_power.d4rt @@ -1,5 +1,8 @@ [ - {"name":"Kinetic Energy","description":r""" + // Kinetic Energy + { + "name": "Kinetic Energy", + "description": r""" Energy possessed by a moving object. $$KE = \frac{1}{2}mv^2$$ @@ -8,9 +11,20 @@ Where: - $m$: Mass (kg) - $v$: Velocity (m/s) -![Kinetic energy (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Kinetic_energy.svg/1200px-Kinetic_energy.svg.png) -""","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","description":r""" +![Kinetic energy (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Kinetic_energy.svg/1200px-Kinetic_energy.svg.png)""", + "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"] + }, + + // Work + { + "name": "Work", + "description": r""" Energy transferred when a force moves an object. $$W = F d \cos(\theta)$$ @@ -21,9 +35,24 @@ Where: - $d$: Displacement (meters) - $\theta$: Angle between force and displacement -![Work (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Work.svg/800px-Work.svg.png) -""","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","description":r""" +![Work (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Work.svg/800px-Work.svg.png)""", + "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"] + }, + + // Power + { + "name": "Power", + "description": r""" Rate at which work is done or energy is transferred. $$P = \frac{W}{t}$$ @@ -33,9 +62,20 @@ Where: - $W$: Work or energy (Joules) - $t$: Time (seconds) -![Power (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Power_equation.svg/800px-Power_equation.svg.png) -""","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","description":r""" +![Power (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Power_equation.svg/800px-Power_equation.svg.png)""", + "input": [ + {"name": "W", "unit": "joule"}, + {"name": "t", "unit": "second"} + ], + "output": {"name": "P", "unit": "watt"}, + "d4rtCode": "P = W / t;", + "tags": ["physics", "energy", "mechanics"] + }, + + // Mass-Energy Equivalence + { + "name": "Mass-Energy Equivalence", + "description": r""" Einstein's mass-energy equivalence relation. $$E = mc^2$$ @@ -47,6 +87,12 @@ Where: This shows mass can be converted to energy and vice versa. -![Einstein formula (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Einstein_light_beam.svg/800px-Einstein_light_beam.svg.png) -""","input":[{"name":"m","unit":"kilogram"}],"output":{"name":"E","unit":"joule"},"d4rtCode":"E = m * pow(299792458, 2);","tags":["physics","relativity","energy"]} +![Einstein formula (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Einstein_light_beam.svg/800px-Einstein_light_beam.svg.png)""", + "input": [ + {"name": "m", "unit": "kilogram"} + ], + "output": {"name": "E", "unit": "joule"}, + "d4rtCode": "E = m * pow(299792458, 2);", + "tags": ["physics", "relativity", "energy"] + } ] diff --git a/assets/formulas/fluids_and_pressure.d4rt b/assets/formulas/fluids_and_pressure.d4rt index 5e66ef0..f35aa6d 100644 --- a/assets/formulas/fluids_and_pressure.d4rt +++ b/assets/formulas/fluids_and_pressure.d4rt @@ -1,5 +1,8 @@ [ - {"name":"Density","description":r""" + // Density + { + "name": "Density", + "description": r""" Mass per unit volume of a substance. $$\rho = \frac{m}{V}$$ @@ -11,9 +14,20 @@ Where: Density is an intrinsic property of materials. -![Density illustration (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Density_of_solids.svg/800px-Density_of_solids.svg.png) -""","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","description":r""" +![Density illustration (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Density_of_solids.svg/800px-Density_of_solids.svg.png)""", + "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"] + }, + + // Pressure + { + "name": "Pressure", + "description": r""" Force applied perpendicular to a surface per unit area. $$P = \frac{F}{A}$$ @@ -25,9 +39,20 @@ Where: Pressure is transmitted equally in all directions in fluids. -![Pressure (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Pressure_in_fluid.svg/800px-Pressure_in_fluid.svg.png) -""","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","description":r""" +![Pressure (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Pressure_in_fluid.svg/800px-Pressure_in_fluid.svg.png)""", + "input": [ + {"name": "F", "unit": "newton"}, + {"name": "A", "unit": "square meter"} + ], + "output": {"name": "P", "unit": "pascal"}, + "d4rtCode": "P = F / A;", + "tags": ["physics", "mechanics", "fluid"] + }, + + // Buoyant Force + { + "name": "Buoyant Force", + "description": r""" Upward force exerted on an object immersed in a fluid (Archimedes' principle). $$F_b = \rho g V$$ @@ -40,7 +65,14 @@ Where: An object floats when buoyant force equals its weight. -![Archimedes principle (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Archimedes-principle.svg/960px-Archimedes-principle.svg.png) - -""","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"]} +![Archimedes principle (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Archimedes-principle.svg/960px-Archimedes-principle.svg.png)""", + "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"] + } ] diff --git a/assets/formulas/formulas.d4rt b/assets/formulas/formulas.d4rt index 7b3f7de..d0b3bfe 100644 --- a/assets/formulas/formulas.d4rt +++ b/assets/formulas/formulas.d4rt @@ -1,15 +1,4 @@ [ - -{ - "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" ] -}, // Free fall distance (vertical) { "name": "Free Fall Distance", @@ -24,75 +13,57 @@ Where: ![Free Fall Diagram](https://altcalculator.com/wp-content/uploads/2023/08/Free-Fall.png)""", "input": [ - {"name": "t", "unit": "second"}, // Time in seconds - {"name": "g", "unit": "meters per second"} // Gravitational acceleration + {"name": "t", "unit": "second"}, + {"name": "g", "unit": "meters per second"} ], - "output": {"name": "h", "unit": "meter"}, // Height in meters + "output": {"name": "h", "unit": "meter"}, "d4rtCode": "h = 0.5 * g * pow(t, 2);", "tags": ["physics", "kinematics"] }, - + // Newton's Law of Universal Gravitation { "name": "Gravitational Force", - "description": r''' + "description": r""" Newton's law of universal gravitation -\(F = G\frac{m_1m_2}{r^2}\) +$$F = G\frac{m_1m_2}{r^2}$$ Where: - $G$: Gravitational constant $6.674\times 10^{-11}\ \mathrm{N\cdot m^2/kg^2}$ - $m_1, m_2$: Masses of two objects - $r$: Distance between centers of masses -![Gravitation](https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/NewtonsLawOfUniversalGravitation.svg/1200px-NewtonsLawOfUniversalGravitation.svg.png)''', +![Gravitation](https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/NewtonsLawOfUniversalGravitation.svg/1200px-NewtonsLawOfUniversalGravitation.svg.png)""", "input": [ - {"name": "m1", "unit": "kilogram"}, // Mass 1 - {"name": "m2", "unit": "kilogram"}, // Mass 2 - {"name": "r", "unit": "meter"} // Distance between masses + {"name": "m1", "unit": "kilogram"}, + {"name": "m2", "unit": "kilogram"}, + {"name": "r", "unit": "meter"} ], - "output": {"name": "F", "unit": "newton"}, // Force in newtons + "output": {"name": "F", "unit": "newton"}, "d4rtCode": "F = (6.67430e-11 * m1 * m2) / pow(r, 2);", "tags": ["physics", "astronomy", "gravity"] }, - - // Kinetic Energy - { - "name": "Kinetic Energy", - "description": r''' -Energy possessed by a moving object -$$KE = \frac{1}{2}mv^2$$ - -Where: -- $m$: Mass of object -- $v$: Velocity of object - -![Kinetic Energy](https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Kinetic_energy.svg/1200px-Kinetic_energy.svg.png)''', - "input": [ - {"name": "m", "unit": "kilogram"}, // Mass - {"name": "v", "unit": "meters per second"} // Velocity - ], - "output": {"name": "KE", "unit": "joule"}, // Energy in joules - "d4rtCode": "KE = 0.5 * m * pow(v, 2);", - "tags": ["physics", "energy", "mechanics"] - }, - // Projectile Motion Range { "name": "Projectile Range", - "description": r"""Calculates horizontal distance of projectile motion - $$R = \frac{v^2 \sin(2\theta)}{g}$$ - Where: - - $v$: Initial velocity - - $\theta$: Launch angle - - $g$: Gravitational acceleration - ![Projectile Motion](https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Projectile_motion_diagram.png/800px-Projectile_motion_diagram.png)""", + "description": r""" +Calculates horizontal distance of projectile motion + +$$R = \frac{v^2 \sin(2\theta)}{g}$$ + +Where: +- $v$: Initial velocity +- $\theta$: Launch angle +- $g$: Gravitational acceleration + +![Projectile Motion](https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Projectile_motion_diagram.png/800px-Projectile_motion_diagram.png)""", "input": [ - {"name": "v", "unit": "meters per second"}, // Initial velocity - {"name": "a", "unit": "degree"} // Launch angle + {"name": "v", "unit": "meters per second"}, + {"name": "a", "unit": "degree"} ], - "output": {"name": "R", "unit": "meter"}, // Horizontal distance + "output": {"name": "R", "unit": "meter"}, "d4rtCode": """ var radians = a * (pi / 180); R = (pow(v, 2) * sin(2 * radians)) / 9.80665; @@ -100,9 +71,10 @@ Where: "tags": ["physics", "kinematics", "projectile"] }, + // Newton's Second Law { "name": "Newton's Second Law", - "description": r''' + "description": r""" Force equals mass times acceleration $$F = m \cdot a$$ @@ -111,142 +83,20 @@ Where: - $m$: Mass of object ($\mathrm{kg}$) - $a$: Acceleration ($\mathrm{m/s^2}$) -![Newton's Second Law](https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Newtonslawsofmotion.jpg/800px-Newtonslawsofmotion.jpg)''', +![Newton's Second Law](https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Newtonslawsofmotion.jpg/800px-Newtonslawsofmotion.jpg)""", "input": [ - {"name": "m", "unit": "kilogram"}, // Mass - {"name": "a", "unit": "meters per square second"} // Acceleration + {"name": "m", "unit": "kilogram"}, + {"name": "a", "unit": "meters per square second"} ], - "output": {"name": "F", "unit": "newton"}, // Force in newtons + "output": {"name": "F", "unit": "newton"}, "d4rtCode": "F = m * a;", "tags": ["physics", "mechanics", "newton"] }, - // Apgar Score - { - "name": "Apgar Score", - "description": "Newborn health assessment scoring system\n\nScores 0-2 for:\n1. Heart rate\n2. Breathing\n3. Muscle tone\n4. Reflexes\n5. Skin color\nTotal score 0-10", - "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"] - } - , - { - "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"] - } - , - - // Einstein's Mass-Energy Equivalence - { - "name": "Mass-Energy Equivalence", - "description": r''' -Einstein's famous equation showing the relationship between mass and energy - -$$E = mc^2$$ - -Where: -- $E$: Energy (Joules) -- $m$: Mass (kilograms) -- $c$: Speed of light $299,792,458$ $\mathrm{m/s}$ - -This equation shows that mass can be converted to energy and vice versa.''', - "input": [ - {"name": "m", "unit": "kilogram"} // Mass - ], - "output": {"name": "E", "unit": "joule"}, // Energy - "d4rtCode": "E = m * pow(299792458, 2);", - "tags": ["physics", "relativity", "energy"] - }, - - // Ohm's Law - { - "name": "Ohm's Law", - "description": r''' -Relationship between voltage, current, and resistance in electrical circuits - -$$V = IR$$ - -Where: -- $V$: Voltage (Volts) -- $I$: Current (Amperes) -- $R$: Resistance (Ohms) - -This fundamental law describes how current flows through resistive materials.''', - "input": [ - {"name": "I", "unit": "ampere"}, // Current - {"name": "R", "unit": "ohm"} // Resistance - ], - "output": {"name": "V", "unit": "volt"}, // Voltage - "d4rtCode": "V = I * R;", - "tags": ["physics", "electricity", "electronics"] - }, - - // Hooke's Law - { - "name": "Hooke's Law", - "description": r''' -Force exerted by a spring is proportional to its displacement - -$$F = -kx$$ - -Where: -- $F$: Restoring force (Newtons) -- $k$: Spring constant (N/m) -- $x$: Displacement from equilibrium (meters) - -The negative sign indicates the force opposes the displacement.''', - "input": [ - {"name": "k", "unit": "newton per meter"}, // Spring constant - {"name": "x", "unit": "meter"} // Displacement - ], - "output": {"name": "F", "unit": "newton"}, // Force - "d4rtCode": "F = -k * x;", - "tags": ["physics", "elasticity", "oscillations"] - }, - // Centripetal Force { "name": "Centripetal Force", - "description": r''' + "description": r""" Force required to keep an object moving in circular motion $$F = \frac{mv^2}{r}$$ @@ -257,13 +107,13 @@ Where: - $v$: Velocity (m/s) - $r$: Radius of circular path (meters) -This force acts toward the center of the circle.''', +This force acts toward the center of the circle.""", "input": [ - {"name": "m", "unit": "kilogram"}, // Mass - {"name": "v", "unit": "meters per second"}, // Velocity - {"name": "r", "unit": "meter"} // Radius + {"name": "m", "unit": "kilogram"}, + {"name": "v", "unit": "meters per second"}, + {"name": "r", "unit": "meter"} ], - "output": {"name": "F", "unit": "newton"}, // Force + "output": {"name": "F", "unit": "newton"}, "d4rtCode": "F = (m * pow(v, 2)) / r;", "tags": ["physics", "circular motion", "centripetal"] }, @@ -271,7 +121,7 @@ This force acts toward the center of the circle.''', // Wave Equation { "name": "Wave Equation", - "description": r''' + "description": r""" Relationship between wave speed, frequency, and wavelength $$v = f\lambda$$ @@ -281,12 +131,12 @@ Where: - $f$: Frequency (Hertz) - $\lambda$: Wavelength (meters) -This applies to all types of waves including sound and light.''', +This applies to all types of waves including sound and light.""", "input": [ - {"name": "f", "unit": "hertz"}, // Frequency - {"name": "lambda", "unit": "meter"} // Wavelength + {"name": "f", "unit": "hertz"}, + {"name": "lambda", "unit": "meter"} ], - "output": {"name": "v", "unit": "meters per second"}, // Wave speed + "output": {"name": "v", "unit": "meters per second"}, "d4rtCode": "v = f * lambda;", "tags": ["physics", "waves", "frequency"] }, @@ -294,7 +144,7 @@ This applies to all types of waves including sound and light.''', // Pythagorean Theorem { "name": "Pythagorean Theorem", - "description": r''' + "description": r""" Fundamental relation in Euclidean geometry among the three sides of a right triangle $$a^2 + b^2 = c^2$$ @@ -303,12 +153,12 @@ Where: - $a$, $b$: Legs of the right triangle - $c$: Hypotenuse of the right triangle -The square of the hypotenuse is equal to the sum of squares of the other two sides.''', +The square of the hypotenuse is equal to the sum of squares of the other two sides.""", "input": [ - {"name": "a", "unit": "meter"}, // First leg - {"name": "b", "unit": "meter"} // Second leg + {"name": "a", "unit": "meter"}, + {"name": "b", "unit": "meter"} ], - "output": {"name": "c", "unit": "meter"}, // Hypotenuse + "output": {"name": "c", "unit": "meter"}, "d4rtCode": "c = sqrt(pow(a, 2) + pow(b, 2));", "tags": ["trigonometry", "geometry", "pythagorean"] }, @@ -316,7 +166,7 @@ The square of the hypotenuse is equal to the sum of squares of the other two sid // Sine Rule { "name": "Sine Rule", - "description": r''' + "description": r""" Relationship between the sides and angles of any triangle $$\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C}$$ @@ -325,13 +175,13 @@ Where: - $a$, $b$, $c$: Sides of the triangle - $A$, $B$, $C$: Angles opposite to sides $a$, $b$, $c$ respectively -This rule is useful for solving triangles when certain combinations of angles and sides are known.''', +This rule is useful for solving triangles when certain combinations of angles and sides are known.""", "input": [ - {"name": "a", "unit": "meter"}, // Side a - {"name": "A", "unit": "degree"}, // Angle A in degrees - {"name": "B", "unit": "degree"} // Angle B in degrees + {"name": "a", "unit": "meter"}, + {"name": "A", "unit": "degree"}, + {"name": "B", "unit": "degree"} ], - "output": {"name": "b", "unit": "meter"}, // Side b + "output": {"name": "b", "unit": "meter"}, "d4rtCode": """ var angleARad = A * (pi / 180); var angleBRad = B * (pi / 180); @@ -343,7 +193,7 @@ This rule is useful for solving triangles when certain combinations of angles an // Cosine Rule { "name": "Cosine Rule", - "description": r''' + "description": r""" Generalization of the Pythagorean theorem for any triangle $$c^2 = a^2 + b^2 - 2ab\cos(C)$$ @@ -352,13 +202,13 @@ Where: - $a$, $b$, $c$: Sides of the triangle - $C$: Angle opposite to side $c$ -This rule relates all three sides of a triangle to one of its angles.''', +This rule relates all three sides of a triangle to one of its angles.""", "input": [ - {"name": "a", "unit": "meter"}, // Side a - {"name": "b", "unit": "meter"}, // Side b - {"name": "C", "unit": "degree"} // Angle C in degrees + {"name": "a", "unit": "meter"}, + {"name": "b", "unit": "meter"}, + {"name": "C", "unit": "degree"} ], - "output": {"name": "c", "unit": "meter"}, // Side c + "output": {"name": "c", "unit": "meter"}, "d4rtCode": """ var angleCRad = C * (pi / 180); c = sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cos(angleCRad)); @@ -369,7 +219,7 @@ This rule relates all three sides of a triangle to one of its angles.''', // Trigonometric Identity { "name": "Trigonometric Identity", - "description": r''' + "description": r""" Fundamental Pythagorean identity in trigonometry $$\sin^2(\theta) + \cos^2(\theta) = 1$$ @@ -377,11 +227,11 @@ $$\sin^2(\theta) + \cos^2(\theta) = 1$$ Where: - $\theta$: Any angle in radians or degrees -This identity is derived from the Pythagorean theorem applied to the unit circle.''', +This identity is derived from the Pythagorean theorem applied to the unit circle.""", "input": [ - {"name": "theta", "unit": "degree"} // Angle in degrees + {"name": "theta", "unit": "degree"} ], - "output": {"name": "result", "unit": "scalar"}, // Result (should be 1) + "output": {"name": "result", "unit": "scalar"}, "d4rtCode": """ var thetaRad = theta * (pi / 180); result = pow(sin(thetaRad), 2) + pow(cos(thetaRad), 2); @@ -392,7 +242,7 @@ This identity is derived from the Pythagorean theorem applied to the unit circle // Gravitational Potential Energy { "name": "Gravitational Potential Energy", - "description": r''' + "description": r""" Energy possessed by an object due to its position in a gravitational field $$PE = mgh$$ @@ -402,13 +252,13 @@ Where: - $g$: Gravitational acceleration ($9.81\ \mathrm{m/s^2}$ on Earth) - $h$: Height above reference point (meters) -This energy increases with height and can be converted to kinetic energy.''', +This energy increases with height and can be converted to kinetic energy.""", "input": [ - {"name": "m", "unit": "kilogram"}, // Mass - {"name": "h", "unit": "meter"}, // Height - {"name": "g", "unit": "meters per square second"} // Gravitational acceleration + {"name": "m", "unit": "kilogram"}, + {"name": "h", "unit": "meter"}, + {"name": "g", "unit": "meters per square second"} ], - "output": {"name": "PE", "unit": "joule"}, // Potential energy + "output": {"name": "PE", "unit": "joule"}, "d4rtCode": "PE = m * g * h;", "tags": ["physics", "energy", "mechanics", "gravity"] }, @@ -416,7 +266,7 @@ This energy increases with height and can be converted to kinetic energy.''', // Linear Momentum { "name": "Linear Momentum", - "description": r''' + "description": r""" Quantity of motion possessed by a moving object $$p = mv$$ @@ -426,334 +276,20 @@ Where: - $m$: Mass (kilograms) - $v$: Velocity (m/s) -Momentum is conserved in isolated systems.''', +Momentum is conserved in isolated systems.""", "input": [ - {"name": "m", "unit": "kilogram"}, // Mass - {"name": "v", "unit": "meters per second"} // Velocity + {"name": "m", "unit": "kilogram"}, + {"name": "v", "unit": "meters per second"} ], - "output": {"name": "p", "unit": "kilogram meter per second"}, // Momentum + "output": {"name": "p", "unit": "kilogram meter per second"}, "d4rtCode": "p = m * v;", "tags": ["physics", "mechanics", "momentum"] }, - // Density - { - "name": "Density", - "description": r''' -Mass per unit volume of a substance - -$$\rho = \frac{m}{V}$$ - -Where: -- $\rho$: Density ($\mathrm{kg/m^3}$) -- $m$: Mass (kilograms) -- $V$: Volume (cubic meters) - -Density is an intrinsic property of materials.''', - "input": [ - {"name": "m", "unit": "kilogram"}, // Mass - {"name": "V", "unit": "cubic meter"} // Volume - ], - "output": {"name": "rho", "unit": "kilogram per cubic meter"}, // Density - "d4rtCode": "rho = m / V;", - "tags": ["physics", "mechanics", "material"] - }, - - // Pressure - { - "name": "Pressure", - "description": r''' -Force applied perpendicular to a surface per unit area - -$$P = \frac{F}{A}$$ - -Where: -- $P$: Pressure (Pascals) -- $F$: Force (Newtons) -- $A$: Area (square meters) - -Pressure is transmitted equally in all directions in fluids.''', - "input": [ - {"name": "F", "unit": "newton"}, // Force - {"name": "A", "unit": "square meter"} // Area - ], - "output": {"name": "P", "unit": "pascal"}, // Pressure - "d4rtCode": "P = F / A;", - "tags": ["physics", "mechanics", "fluid"] - }, - - // Work - { - "name": "Work", - "description": r''' -Energy transferred when a force moves an object - -$$W = Fd\cos(\theta)$$ - -Where: -- $W$: Work (Joules) -- $F$: Force (Newtons) -- $d$: Displacement (meters) -- $\theta$: Angle between force and displacement - -Maximum work occurs when force and displacement are parallel.''', - "input": [ - {"name": "F", "unit": "newton"}, // Force - {"name": "d", "unit": "meter"}, // Displacement - {"name": "theta", "unit": "degree"} // Angle - ], - "output": {"name": "W", "unit": "joule"}, // Work - "d4rtCode": """ - var thetaRad = theta * (pi / 180); - W = F * d * cos(thetaRad); - """, - "tags": ["physics", "energy", "mechanics"] - }, - - // Power - { - "name": "Power", - "description": r''' -Rate at which work is done or energy is transferred - -$$P = \frac{W}{t}$$ - -Where: -- $P$: Power (Watts) -- $W$: Work or Energy (Joules) -- $t$: Time (seconds) - -Power measures how quickly energy is used or transferred.''', - "input": [ - {"name": "W", "unit": "joule"}, // Work or Energy - {"name": "t", "unit": "second"} // Time - ], - "output": {"name": "P", "unit": "watt"}, // Power - "d4rtCode": "P = W / t;", - "tags": ["physics", "energy", "mechanics"] - }, - - // Coulomb's Law - { - "name": "Coulomb's Law", - "description": r''' -Force between two electrically charged particles - -$$F = k_e\frac{q_1q_2}{r^2}$$ - -Where: -- $F$: Electrostatic force (Newtons) -- $k_e$: Coulomb's constant $8.988\times 10^9\ \mathrm{N\cdot m^2/C^2}$ -- $q_1, q_2$: Electric charges (Coulombs) -- $r$: Distance between charges (meters) - -Like charges repel, opposite charges attract.''', - "input": [ - {"name": "q1", "unit": "coulomb"}, // Charge 1 - {"name": "q2", "unit": "coulomb"}, // Charge 2 - {"name": "r", "unit": "meter"} // Distance - ], - "output": {"name": "F", "unit": "newton"}, // Force - "d4rtCode": "F = (8.9875517923e9 * q1 * q2) / pow(r, 2);", - "tags": ["physics", "electricity", "electrostatics"] - }, - - // Electric Power - { - "name": "Electric Power", - "description": r''' -Rate at which electrical energy is transferred - -$$P = VI$$ - -Where: -- $P$: Power (Watts) -- $V$: Voltage (Volts) -- $I$: Current (Amperes) - -This formula is fundamental in electrical circuit analysis.''', - "input": [ - {"name": "V", "unit": "volt"}, // Voltage - {"name": "I", "unit": "ampere"} // Current - ], - "output": {"name": "P", "unit": "watt"}, // Power - "d4rtCode": "P = V * I;", - "tags": ["physics", "electricity", "electronics"] - }, - - // Ideal Gas Law - { - "name": "Ideal Gas Law", - "description": r''' -Equation of state for an ideal gas - -$$PV = nRT$$ - -Where: -- $P$: Pressure (Pascals) -- $V$: Volume (cubic meters) -- $n$: Amount of substance (moles) -- $R$: Universal gas constant $8.314\ \mathrm{J/(mol\cdot K)}$ -- $T$: Temperature (Kelvin) - -This law combines Boyle's, Charles's, and Avogadro's laws.''', - "input": [ - {"name": "n", "unit": "mole"}, // Amount of substance - {"name": "T", "unit": "kelvin"}, // Temperature - {"name": "V", "unit": "cubic meter"} // Volume - ], - "output": {"name": "P", "unit": "pascal"}, // Pressure - "d4rtCode": "P = (n * 8.314462618 * T) / V;", - "tags": ["physics", "thermodynamics", "gas"] - }, - - // Snell's Law - { - "name": "Snell's Law", - "description": r''' -Law describing refraction of light at interface between media - -$$n_1\sin(\theta_1) = n_2\sin(\theta_2)$$ - -Where: -- $n_1, n_2$: Refractive indices of the two media -- $\theta_1$: Angle of incidence -- $\theta_2$: Angle of refraction - -This law explains how light bends when passing between materials.''', - "input": [ - {"name": "n1", "unit": "scalar"}, // Refractive index 1 - {"name": "n2", "unit": "scalar"}, // Refractive index 2 - {"name": "theta1", "unit": "degree"} // Angle of incidence - ], - "output": {"name": "theta2", "unit": "degree"}, // Angle of refraction - "d4rtCode": """ - var theta1Rad = theta1 * (pi / 180); - var sinTheta2 = (n1 * sin(theta1Rad)) / n2; - theta2 = asin(sinTheta2) * (180 / pi); - """, - "tags": ["physics", "optics", "light"] - }, - - - // Area of Circle - { - "name": "Area of Circle", - "description": r''' -Area enclosed by a circle - -$$A = \pi r^2$$ - -Where: -- $A$: Area (square meters) -- $r$: Radius (meters) -- $\pi$: Pi ($\approx 3.14159$) - -The 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''' -Perimeter (distance around) a circle - -$$C = 2\pi r$$ - -Where: -- $C$: Circumference (meters) -- $r$: Radius (meters) -- $\pi$: Pi ($\approx 3.14159$) - -The 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''' -Area enclosed by a triangle - -$$A = \frac{1}{2}bh$$ - -Where: -- $A$: Area (square meters) -- $b$: Base length (meters) -- $h$: Height perpendicular to base (meters) - -This 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''' -Area enclosed by a rectangle - -$$A = lw$$ - -Where: -- $A$: Area (square meters) -- $l$: Length (meters) -- $w$: Width (meters) - -The 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''' -Area enclosed by a trapezoid - -$$A = \frac{1}{2}(a+b)h$$ - -Where: -- $A$: Area (square meters) -- $a, b$: Lengths of parallel sides (meters) -- $h$: Height (perpendicular distance between parallel sides, meters) - -The 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"] - }, - // Volume of Sphere { "name": "Volume of Sphere", - "description": r''' + "description": r""" Volume enclosed by a sphere $$V = \frac{4}{3}\pi r^3$$ @@ -763,11 +299,11 @@ Where: - $r$: Radius (meters) - $\pi$: Pi ($\approx 3.14159$) -The volume is proportional to the cube of the radius.''', +The volume is proportional to the cube of the radius.""", "input": [ - {"name": "r", "unit": "meter"} // Radius + {"name": "r", "unit": "meter"} ], - "output": {"name": "V", "unit": "cubic meter"}, // Volume + "output": {"name": "V", "unit": "cubic meter"}, "d4rtCode": "V = (4.0/3.0) * pi * pow(r, 3);", "tags": ["geometry", "sphere", "volume"] }, @@ -775,7 +311,7 @@ The volume is proportional to the cube of the radius.''', // Surface Area of Sphere { "name": "Surface Area of Sphere", - "description": r''' + "description": r""" Total surface area of a sphere $$A = 4\pi r^2$$ @@ -785,11 +321,11 @@ Where: - $r$: Radius (meters) - $\pi$: Pi ($\approx 3.14159$) -The surface area is four times the area of a circle with the same radius.''', +The surface area is four times the area of a circle with the same radius.""", "input": [ - {"name": "r", "unit": "meter"} // Radius + {"name": "r", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Surface area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": "A = 4 * pi * pow(r, 2);", "tags": ["geometry", "sphere", "surface area"] }, @@ -797,7 +333,7 @@ The surface area is four times the area of a circle with the same radius.''', // Volume of Cylinder { "name": "Volume of Cylinder", - "description": r''' + "description": r""" Volume enclosed by a cylinder $$V = \pi r^2 h$$ @@ -808,12 +344,12 @@ Where: - $h$: Height (meters) - $\pi$: Pi ($\approx 3.14159$) -The volume is the area of the base times the height.''', +The volume is the area of the base times the height.""", "input": [ - {"name": "r", "unit": "meter"}, // Radius - {"name": "h", "unit": "meter"} // Height + {"name": "r", "unit": "meter"}, + {"name": "h", "unit": "meter"} ], - "output": {"name": "V", "unit": "cubic meter"}, // Volume + "output": {"name": "V", "unit": "cubic meter"}, "d4rtCode": "V = pi * pow(r, 2) * h;", "tags": ["geometry", "cylinder", "volume"] }, @@ -821,7 +357,7 @@ The volume is the area of the base times the height.''', // Surface Area of Cylinder { "name": "Surface Area of Cylinder", - "description": r''' + "description": r""" Total surface area of a cylinder (including top and bottom) $$A = 2\pi r(r + h)$$ @@ -832,12 +368,12 @@ Where: - $h$: Height (meters) - $\pi$: Pi ($\approx 3.14159$) -This includes the lateral surface plus the two circular ends.''', +This includes the lateral surface plus the two circular ends.""", "input": [ - {"name": "r", "unit": "meter"}, // Radius - {"name": "h", "unit": "meter"} // Height + {"name": "r", "unit": "meter"}, + {"name": "h", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Surface area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": "A = 2 * pi * r * (r + h);", "tags": ["geometry", "cylinder", "surface area"] }, @@ -845,7 +381,7 @@ This includes the lateral surface plus the two circular ends.''', // Volume of Cone { "name": "Volume of Cone", - "description": r''' + "description": r""" Volume enclosed by a cone $$V = \frac{1}{3}\pi r^2 h$$ @@ -856,12 +392,12 @@ Where: - $h$: Height (meters) - $\pi$: Pi ($\approx 3.14159$) -The volume is one-third the volume of a cylinder with the same base and height.''', +The volume is one-third the volume of a cylinder with the same base and height.""", "input": [ - {"name": "r", "unit": "meter"}, // Radius - {"name": "h", "unit": "meter"} // Height + {"name": "r", "unit": "meter"}, + {"name": "h", "unit": "meter"} ], - "output": {"name": "V", "unit": "cubic meter"}, // Volume + "output": {"name": "V", "unit": "cubic meter"}, "d4rtCode": "V = (1.0/3.0) * pi * pow(r, 2) * h;", "tags": ["geometry", "cone", "volume"] }, @@ -869,7 +405,7 @@ The volume is one-third the volume of a cylinder with the same base and height.' // Volume of Cube { "name": "Volume of Cube", - "description": r''' + "description": r""" Volume enclosed by a cube $$V = s^3$$ @@ -878,11 +414,11 @@ Where: - $V$: Volume (cubic meters) - $s$: Side length (meters) -The volume is the cube of the side length.''', +The volume is the cube of the side length.""", "input": [ - {"name": "s", "unit": "meter"} // Side length + {"name": "s", "unit": "meter"} ], - "output": {"name": "V", "unit": "cubic meter"}, // Volume + "output": {"name": "V", "unit": "cubic meter"}, "d4rtCode": "V = pow(s, 3);", "tags": ["geometry", "cube", "volume"] }, @@ -890,7 +426,7 @@ The volume is the cube of the side length.''', // Surface Area of Cube { "name": "Surface Area of Cube", - "description": r''' + "description": r""" Total surface area of a cube $$A = 6s^2$$ @@ -899,11 +435,11 @@ Where: - $A$: Total surface area (square meters) - $s$: Side length (meters) -The surface area is six times the area of one face.''', +The surface area is six times the area of one face.""", "input": [ - {"name": "s", "unit": "meter"} // Side length + {"name": "s", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Surface area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": "A = 6 * pow(s, 2);", "tags": ["geometry", "cube", "surface area"] }, @@ -911,7 +447,7 @@ The surface area is six times the area of one face.''', // Perimeter of Rectangle { "name": "Perimeter of Rectangle", - "description": r''' + "description": r""" Total distance around a rectangle $$P = 2(l + w)$$ @@ -921,12 +457,12 @@ Where: - $l$: Length (meters) - $w$: Width (meters) -The perimeter is twice the sum of length and width.''', +The perimeter is twice the sum of length and width.""", "input": [ - {"name": "l", "unit": "meter"}, // Length - {"name": "w", "unit": "meter"} // Width + {"name": "l", "unit": "meter"}, + {"name": "w", "unit": "meter"} ], - "output": {"name": "P", "unit": "meter"}, // Perimeter + "output": {"name": "P", "unit": "meter"}, "d4rtCode": "P = 2 * (l + w);", "tags": ["geometry", "rectangle", "perimeter"] }, @@ -934,7 +470,7 @@ The perimeter is twice the sum of length and width.''', // Perimeter of Triangle { "name": "Perimeter of Triangle", - "description": r''' + "description": r""" Total distance around a triangle $$P = a + b + c$$ @@ -943,91 +479,14 @@ Where: - $P$: Perimeter (meters) - $a, b, c$: Side lengths (meters) -The perimeter is the sum of all three sides.''', +The perimeter is the sum of all three sides.""", "input": [ - {"name": "a", "unit": "meter"}, // Side 1 - {"name": "b", "unit": "meter"}, // Side 2 - {"name": "c", "unit": "meter"} // Side 3 + {"name": "a", "unit": "meter"}, + {"name": "b", "unit": "meter"}, + {"name": "c", "unit": "meter"} ], - "output": {"name": "P", "unit": "meter"}, // Perimeter + "output": {"name": "P", "unit": "meter"}, "d4rtCode": "P = a + b + c;", "tags": ["geometry", "triangle", "perimeter"] - }, - - // Area of Regular Polygon - { - "name": "Area of Regular Polygon", - "description": r''' -Area of a regular polygon with n sides - -$$A = \frac{1}{4}ns^2\cot(\frac{\pi}{n})$$ - -Where: -- $A$: Area (square meters) -- $n$: Number of sides -- $s$: Side length (meters) -- $\pi$: Pi ($\approx 3.14159$) - -This 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''' -Sum of interior angles of a polygon - -$$S = (n - 2) \times 180°$$ - -Where: -- $S$: Sum of interior angles (degrees) -- $n$: Number of sides - -This 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''' -Area of a triangle using only side lengths - -$$A = \sqrt{s(s-a)(s-b)(s-c)}$$ - -Where: -- $A$: Area (square meters) -- $a, b, c$: Side lengths (meters) -- $s$: Semi-perimeter $= \frac{a+b+c}{2}$ - -This formula is useful when height is unknown. - -**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"] } ] diff --git a/assets/formulas/geometry.d4rt b/assets/formulas/geometry.d4rt index b26d10c..4376ba4 100644 --- a/assets/formulas/geometry.d4rt +++ b/assets/formulas/geometry.d4rt @@ -1,13 +1,22 @@ [ - // 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.''', + "description": r""" +Area enclosed by a circle + +$$A = \pi r^2$$ + +Where: +- $A$: Area (square meters) +- $r$: Radius (meters) +- $\pi$: Pi ($\approx 3.14159$) + +The area is proportional to the square of the radius.""", "input": [ - {"name": "r", "unit": "meter"} // Radius + {"name": "r", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": "A = pi * pow(r, 2);", "tags": ["geometry", "circle", "area"] }, @@ -15,11 +24,21 @@ // 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.''', + "description": r""" +Perimeter (distance around) a circle + +$$C = 2\pi r$$ + +Where: +- $C$: Circumference (meters) +- $r$: Radius (meters) +- $\pi$: Pi ($\approx 3.14159$) + +The circumference is proportional to the radius.""", "input": [ - {"name": "r", "unit": "meter"} // Radius + {"name": "r", "unit": "meter"} ], - "output": {"name": "C", "unit": "meter"}, // Circumference + "output": {"name": "C", "unit": "meter"}, "d4rtCode": "C = 2 * pi * r;", "tags": ["geometry", "circle", "perimeter"] }, @@ -27,12 +46,22 @@ // 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.''', + "description": r""" +Area enclosed by a triangle + +$$A = \frac{1}{2}bh$$ + +Where: +- $A$: Area (square meters) +- $b$: Base length (meters) +- $h$: Height perpendicular to base (meters) + +This formula works for any triangle.""", "input": [ - {"name": "b", "unit": "meter"}, // Base - {"name": "h", "unit": "meter"} // Height + {"name": "b", "unit": "meter"}, + {"name": "h", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": "A = 0.5 * b * h;", "tags": ["geometry", "triangle", "area"] }, @@ -40,12 +69,22 @@ // 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.''', + "description": r""" +Area enclosed by a rectangle + +$$A = lw$$ + +Where: +- $A$: Area (square meters) +- $l$: Length (meters) +- $w$: Width (meters) + +The area is the product of length and width.""", "input": [ - {"name": "l", "unit": "meter"}, // Length - {"name": "w", "unit": "meter"} // Width + {"name": "l", "unit": "meter"}, + {"name": "w", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": "A = l * w;", "tags": ["geometry", "rectangle", "area"] }, @@ -53,13 +92,23 @@ // 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.''', + "description": r""" +Area enclosed by a trapezoid + +$$A = \frac{1}{2}(a+b)h$$ + +Where: +- $A$: Area (square meters) +- $a, b$: Lengths of parallel sides (meters) +- $h$: Height (perpendicular distance between parallel sides, meters) + +The 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 + {"name": "a", "unit": "meter"}, + {"name": "b", "unit": "meter"}, + {"name": "h", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": "A = 0.5 * (a + b) * h;", "tags": ["geometry", "trapezoid", "area"] }, @@ -67,12 +116,23 @@ // 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).''', + "description": r""" +Area of a regular polygon with n sides + +$$A = \frac{1}{4}ns^2\cot(\frac{\pi}{n})$$ + +Where: +- $A$: Area (square meters) +- $n$: Number of sides +- $s$: Side length (meters) +- $\pi$: Pi ($\approx 3.14159$) + +This formula works for any regular polygon (equal sides and angles).""", "input": [ - {"name": "n", "unit": "scalar"}, // Number of sides - {"name": "s", "unit": "meter"} // Side length + {"name": "n", "unit": "scalar"}, + {"name": "s", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": "A = 0.25 * n * pow(s, 2) * (cos(pi/n) / sin(pi/n));", "tags": ["geometry", "polygon", "area"] }, @@ -80,11 +140,20 @@ // 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.''', + "description": r""" +Sum of interior angles of a polygon + +$$S = (n - 2) \times 180°$$ + +Where: +- $S$: Sum of interior angles (degrees) +- $n$: Number of sides + +This formula works for any simple polygon.""", "input": [ - {"name": "n", "unit": "scalar"} // Number of sides + {"name": "n", "unit": "scalar"} ], - "output": {"name": "S", "unit": "degree"}, // Sum of angles + "output": {"name": "S", "unit": "degree"}, "d4rtCode": "S = (n - 2) * 180;", "tags": ["geometry", "polygon", "angles"] }, @@ -92,13 +161,25 @@ // 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.''', + "description": r""" +Area of a triangle using only side lengths + +$$A = \sqrt{s(s-a)(s-b)(s-c)}$$ + +Where: +- $A$: Area (square meters) +- $a, b, c$: Side lengths (meters) +- $s$: Semi-perimeter $= \frac{a+b+c}{2}$ + +This formula is useful when height is unknown. + +**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 + {"name": "a", "unit": "meter"}, + {"name": "b", "unit": "meter"}, + {"name": "c", "unit": "meter"} ], - "output": {"name": "A", "unit": "square meter"}, // Area + "output": {"name": "A", "unit": "square meter"}, "d4rtCode": """ if( a + b < c || a+c < b || b+c < a ){ signal( "There is not a valid triangle with those longitudes" ); diff --git a/assets/formulas/gravity.d4rt b/assets/formulas/gravity.d4rt deleted file mode 100644 index e69de29..0000000 diff --git a/assets/formulas/kinematics_and_dynamics.d4rt b/assets/formulas/kinematics_and_dynamics.d4rt deleted file mode 100644 index e69de29..0000000 diff --git a/assets/formulas/materials_elasticity.d4rt b/assets/formulas/materials_elasticity.d4rt index dc16bb3..b0e8740 100644 --- a/assets/formulas/materials_elasticity.d4rt +++ b/assets/formulas/materials_elasticity.d4rt @@ -1,6 +1,9 @@ [ - {"name":"Hooke's Law","description":r""" -Force exerted by a spring is proportional to its displacement (linear region). + // Hooke's Law + { + "name": "Hooke's Law", + "description": r""" +Force exerted by a spring is proportional to its displacement. $$F = -kx$$ @@ -9,8 +12,13 @@ Where: - $k$: Spring constant (N/m) - $x$: Displacement from equilibrium (meters) -The negative sign indicates the force opposes displacement. - -![Hooke's law (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/HookesLaw.svg/800px-HookesLaw.svg.png) -""","input":[{"name":"k","unit":"newton per meter"},{"name":"x","unit":"meter"}],"output":{"name":"F","unit":"newton"},"d4rtCode":"F = -k * x;","tags":["physics","elasticity","oscillations"]} +The negative sign indicates the force opposes the displacement.""", + "input": [ + {"name": "k", "unit": "newton per meter"}, + {"name": "x", "unit": "meter"} + ], + "output": {"name": "F", "unit": "newton"}, + "d4rtCode": "F = -k * x;", + "tags": ["physics", "elasticity", "oscillations"] + } ] diff --git a/assets/formulas/medical_and_bio.d4rt b/assets/formulas/medical_and_bio.d4rt index 5136b6c..a448a98 100644 --- a/assets/formulas/medical_and_bio.d4rt +++ b/assets/formulas/medical_and_bio.d4rt @@ -1,5 +1,8 @@ [ - {"name":"Apgar Score","description":r""" + // Apgar Score + { + "name": "Apgar Score", + "description": r""" Newborn health assessment scoring system performed at 1 and 5 minutes after birth. The Apgar score sums five categories (0–2 points each): @@ -11,6 +14,29 @@ The Apgar score sums five categories (0–2 points each): Total score ranges from 0 to 10. Higher scores indicate better newborn condition. -![Apgar score (illustration) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Apgar_scale.svg/800px-Apgar_scale.svg.png) -""","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"]} +![Apgar score (illustration) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Apgar_scale.svg/800px-Apgar_scale.svg.png)""", + "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"] + } ] diff --git a/assets/formulas/misc_math.d4rt b/assets/formulas/misc_math.d4rt index 97a8d3e..8c5c957 100644 --- a/assets/formulas/misc_math.d4rt +++ b/assets/formulas/misc_math.d4rt @@ -1,3 +1,26 @@ [ - {"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"]} + // Compare Price per Mass + { + "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"] + } ] diff --git a/assets/formulas/optics.d4rt b/assets/formulas/optics.d4rt index c41b756..aed418e 100644 --- a/assets/formulas/optics.d4rt +++ b/assets/formulas/optics.d4rt @@ -1,16 +1,29 @@ [ - {"name":"Snell's Law","description":r""" -Law describing refraction of light at an interface between two media. + // Snell's Law + { + "name": "Snell's Law", + "description": r""" +Law describing refraction of light at interface between media. -$$n_1 \sin(\theta_1) = n_2 \sin(\theta_2)$$ +$$n_1\sin(\theta_1) = n_2\sin(\theta_2)$$ Where: -- $n_1, n_2$: Refractive indices +- $n_1, n_2$: Refractive indices of the two media - $\theta_1$: Angle of incidence - $\theta_2$: Angle of refraction -This law explains how light bends when passing between materials. - -![Refraction diagram (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Refraction_en.svg/800px-Refraction_en.svg.png) -""","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"]} +This law explains how light bends when passing between materials.""", + "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"] + } ] diff --git a/assets/formulas/thermodynamics.d4rt b/assets/formulas/thermodynamics.d4rt index 94f813f..bc70f46 100644 --- a/assets/formulas/thermodynamics.d4rt +++ b/assets/formulas/thermodynamics.d4rt @@ -1,5 +1,8 @@ [ - {"name":"Ideal Gas Law","description":r""" + // Ideal Gas Law + { + "name": "Ideal Gas Law", + "description": r""" Equation of state for an ideal gas. $$PV = nRT$$ @@ -13,6 +16,14 @@ Where: This law combines Boyle's, Charles's and Avogadro's laws. -![Ideal Gas](https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Ideal_gas_sphere.svg/800px-Ideal_gas_sphere.svg.png) -""","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"]} +![Ideal Gas](https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Ideal_gas_sphere.svg/800px-Ideal_gas_sphere.svg.png)""", + "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"] + } ] diff --git a/lib/defaults/default_corpus.dart b/lib/defaults/default_corpus.dart index c0daed7..1719f04 100644 --- a/lib/defaults/default_corpus.dart +++ b/lib/defaults/default_corpus.dart @@ -52,10 +52,16 @@ Future createDefaultCorpus() async{ Future loadFormulas() async { final formulaResources = [ "assets/formulas/formulas.d4rt", + "assets/formulas/geometry.d4rt", + "assets/formulas/energy_and_power.d4rt", "assets/formulas/electromagnetism.d4rt", "assets/formulas/thermodynamics.d4rt", "assets/formulas/fluids_and_pressure.d4rt", - + "assets/formulas/optics.d4rt", + "assets/formulas/materials_elasticity.d4rt", + "assets/formulas/medical_and_bio.d4rt", + "assets/formulas/conversions_and_constants.d4rt", + "assets/formulas/misc_math.d4rt", ]; for (final formRes in formulaResources) { diff --git a/pubspec.lock b/pubspec.lock index f187fdd..5fea360 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -468,26 +468,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" url: "https://pub.dev" source: hosted - version: "11.0.2" + version: "10.0.9" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 url: "https://pub.dev" source: hosted - version: "3.0.10" + version: "3.0.9" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.1" linked_scroll_controller: dependency: transitive description: @@ -540,10 +540,10 @@ packages: dependency: transitive description: name: meta - sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.16.0" mime: dependency: transitive description: @@ -881,26 +881,26 @@ packages: dependency: "direct dev" description: name: test - sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" + sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" url: "https://pub.dev" source: hosted - version: "1.26.3" + version: "1.25.15" test_api: dependency: transitive description: name: test_api - sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.4" test_core: dependency: transitive description: name: test_core - sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" + sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" url: "https://pub.dev" source: hosted - version: "0.6.12" + version: "0.6.8" timing: dependency: transitive description: @@ -1025,10 +1025,10 @@ packages: dependency: transitive description: name: vector_math - sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.1.4" vm_service: dependency: transitive description: