Created
April 17, 2017 07:09
-
-
Save Jjunior130/3c67005090855f85e7c32e2c05c3977b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns formulas.constants "Collection of physical constants and their formulas composed of physical quantities." | |
(:require [clojure.math.numeric-tower :as math])) | |
(def pi | |
{:value 3.14159265359 | |
:formulas | |
{[:frequency :angular-frequency] (fn [& {:keys [frequency angular-frequency]}] | |
(/ angular-frequency | |
(* 2 frequency)))}}) | |
(def planks-constant | |
{:value 6.626070043e-34 | |
:formulas | |
{[:frequency :energy] (fn [& {:keys [frequency energy]}] | |
(/ energy frequency)) | |
[:frequency :wavelength] (fn [& {:keys [frequency wavelength]}] | |
(* frequency wavelength)) | |
[:energy :wavelength] (fn [& {:keys [energy wavelength]}] | |
(/ (* wavelength energy) | |
(:value speed-of-light))) | |
[:wavelength :momentum] (fn [& {:keys [wavelength momentum]}] | |
(* wavelength momentum))}}) | |
(def reduced-planks-constant | |
{:value (/ 6.626070043e-34 (* 2 (:value pi))) | |
:formulas | |
{[:angular-frequency :energy] (fn [& {:keys [frequency energy]}] | |
(/ energy angular-frequency)) | |
[:wavenumber :momentum] (fn [& {:keys [wavelength momentum]}] | |
(/ momentum wavenumber))}}) | |
(def speed-of-light | |
{:value 299792458 | |
:formulas | |
{[:energy :mass :momentum] (fn [& {:keys [energy mass momentum]}] | |
(math/sqrt (/ (+ (- (math/expt momentum 2)) | |
(math/sqrt (+ (math/expt momentum 4) | |
(* 4 (math/expt mass 2) | |
(math/expt energy 2))))) | |
(* 2 (math/expt mass 2))))) | |
[:frequency :wavelength] (fn [& {:keys [frequency wavelength]}] | |
(* frequency wavelength)) | |
[:energy :wavelength] (fn [& {:keys [energy wavelength]}] | |
(/ (* wavelength energy) | |
(:value planks-constant)))}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns formulas.physical-quantities "Collection of physical quantities and their formulas composed of other physical quantities." | |
(:require [clojure.math.numeric-tower :as math])) | |
(def mass | |
{:value (atom nil) | |
:formulas | |
{[:momentum :velocity] (fn [& {:keys [momentum velocity]}] | |
(/ momentum | |
velocity))}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment