Skip to content

Commit

Permalink
Merge pull request #693 from Architsharma7/add-Logarithm
Browse files Browse the repository at this point in the history
Added logarithm under algebra
  • Loading branch information
Amit366 authored Aug 30, 2022
2 parents 7f5b94f + 83f767e commit 7dcf1a0
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 0 deletions.
9 changes: 9 additions & 0 deletions funwithphysics/src/Components/Algebra/Topic/Calculator.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@
word-wrap: break-word;
}

.log_result {
width: 55%;
margin: auto;
padding: 10px 20px;
border: 1px solid gainsboro;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
word-wrap: break-word;
}

/* set-matrix modal and tables for determiant calculator */
.myModal {
width: 90vw;
Expand Down
144 changes: 144 additions & 0 deletions funwithphysics/src/Components/Algebra/Topic/Calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,43 @@ function Calculator() {
let { topic } = useParams();
// topics_data
const Topics = [
{
topic: "Logarithm",
details: [
"A logarithm is defined as the power to which a number must be raised to get some other values. It is the most convenient way to express large numbers. A logarithm has various important properties that prove multiplication and division of logarithms can also be written in the form of logarithm of addition and subtraction.",
"The logarithm of a positive real number a with respect to base b, a positive real number not equal to 1[nb 1], is the exponent by which b must be raised to yield a.",
"In most cases, we always deal with two different types of logarithms, namely: Common Logarithm and Natural Logarithm. ",
"Logarithms are expressed as, m is the Logarithm of n to the base b if b",<sub>m</sub>,"= n, which can also be written as m = log",<sub>b</sub>,"n.",
],
formula: [
"4",
<sup>3</sup>,
"= 64;",
<br></br>,
"hence 3 is the Logarithm of 64 to base 4 or",
<br></br>,
"3 = log",<sub>4</sub>,"64.",
<br></br>,
"Similarly, we know 10",<sup>3</sup>,"= 1000, then 3 = log",<sub>10</sub>,"1000",
],
process: [
" The exponent or power to which a base must be raised to yield a given number.",
<br></br>,
"The graph of log can be represented as:",
<br></br>,
<img src="https://www.mathwarehouse.com/logarithm/images/graphs/logarithm-equation-relationship-to-graph.webp"
alt="Graph for Logarithm"/>
],
example1: [
"Convert 3",<sup>2</sup> , " = 9 into logarithmic form.",
<br></br>,
"Note that 3 is the base of the exponential form, and it will also be the base of the logarithmic form.",
<br></br>,
"Also note that the exponent, 2, will become the logarithm, while the 9 will become the argument.",
<br></br>,
"Therefore the logarithmic form is log",<sub>3</sub>,"9 = 2"
],
},
{
topic: "Sets And Relations",
details: [
Expand Down Expand Up @@ -1371,6 +1408,110 @@ function Calculator() {
);
};

//logarithmic Calculator
const Logarithm = () =>{
const [explanation, setExplanation] = useState(null);
const [result, setResult] = useState(null);
const[base, setbase] = useState(null);
const[value, setvalue] = useState(null);

useEffect(() => {}, [base, value, result]);

const calcResult = () =>{
let res = 0;
var y;
if(value !== null && base !== null){
res = Math.log(value) / Math.log(base);
y = `log(base)${base}(value)${value} = ${res}`;
console.log(res)
}
else{
alert("One or any field is empty.")
}

setResult(res);
setExplanation(y);
};

function reset() {
setResult(null);
setExplanation(null);
setbase(null);
setvalue(null);
}

return(
<>
<Form>
<Form.Group className="mb-4" controlId="text">
<Form.Text className="text">
<strong>
To find the Logarithm, Enter the following values
</strong>
<br />
</Form.Text>
</Form.Group>
<Form.Group className="mb-4">
<Form.Label>Select the base value</Form.Label>
<Form.Control
onChange={(e) => {
setResult(null);
setExplanation(null);
setbase(e.target.value);
}}
type="number"
placeholder={"Enter the Base value"}
value={base === null ? "" : base}
/>
</Form.Group>
<Form.Group className="mb-4">
<Form.Label>Select the value</Form.Label>
<Form.Control
onChange={(e) => {
setResult(null);
setExplanation(null);
setvalue(e.target.value);
}}
type="number"
placeholder={"Enter the Value"}
value={value === null ? "" : value}
/>
</Form.Group>
<Form.Group className="mb-4">
<Form.Label>Result</Form.Label>
{
<div className="log_result">
{result === null ? (
<p>
<strong>Result</strong>
</p>
) :(
<p>
{result}
<br />
<strong>Explanation: {explanation}</strong>
</p>
)}
</div>
}
</Form.Group>
</Form>
<div className="button-custom-grp">
<Button variant="primary" onClick={calcResult}>
Calculate
</Button>
&nbsp;&nbsp;&nbsp;
<Button variant="dark" onClick={() => reset()} type="reset">
Reset
</Button>
</div>

</>

)

}

//Exponential Calculator
const Exponents = () => {
const [result, setResult] = useState(null);
Expand Down Expand Up @@ -3673,6 +3814,9 @@ function Calculator() {
case "Exponents":
currentCall = Exponents();
break;
case "Logarithm":
currentCall = Logarithm();
break;
case "Sets And Relations":
currentCall = SetsAndRelation();
break;
Expand Down
23 changes: 23 additions & 0 deletions funwithphysics/src/Components/Algebra/algebra.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,29 @@ export default function Algebra() {
"Using the formulae given and using the concept of Venn Diagram, we can easily find different sets out of 2 sets A and B depending on the condition.",
],
},
{
topic: "Logarithm",
details: [
"A logarithm is defined as the power to which a number must be raised to get some other values. It is the most convenient way to express large numbers. A logarithm has various important properties that prove multiplication and division of logarithms can also be written in the form of logarithm of addition and subtraction.",
"The logarithm of a positive real number a with respect to base b, a positive real number not equal to 1[nb 1], is the exponent by which b must be raised to yield a.",
"In most cases, we always deal with two different types of logarithms, namely: Common Logarithm and Natural Logarithm",
"Logarithms are expressed as, m is the Logarithm of n to the base b if b",<sub>m</sub>,"= n, which can also be written as m = log",<sub>b</sub>,"n.",
],
formula: [
"4",
<sup>3</sup>,
"= 64;",
<br></br>,
"hence 3 is the Logarithm of 64 to base 4 or",
<br></br>,
"3 = log",<sub>4</sub>,"64.",
<br></br>,
"Similarly, we know 10",<sup>3</sup>,"= 1000, then 3 = log",<sub>10</sub>,"1000",
],
process: [
" The exponent or power to which a base must be raised to yield a given number.",
],
},
];

return (
Expand Down
30 changes: 30 additions & 0 deletions funwithphysics/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3291,6 +3291,13 @@
"resolved" "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz"
"version" "2.2.0"

"bindings@^1.5.0":
"integrity" "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ=="
"resolved" "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz"
"version" "1.5.0"
dependencies:
"file-uri-to-path" "1.0.0"

"bluebird@^2.9.33":
"integrity" "sha512-UfFSr22dmHPQqPP9XWHRhq+gWnHCYguQGkXQlbyPtW5qTnhFWA8/iXg765tH0cAjy7l/zPJ1aBTO0g5XgA7kvQ=="
"resolved" "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz"
Expand Down Expand Up @@ -5874,6 +5881,11 @@
"loader-utils" "^1.0.2"
"schema-utils" "^1.0.0"

"file-uri-to-path@1.0.0":
"integrity" "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
"resolved" "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz"
"version" "1.0.0"

"filename-regex@^2.0.0":
"integrity" "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY="
"resolved" "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz"
Expand Down Expand Up @@ -6166,6 +6178,19 @@
"resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
"version" "1.0.0"

"fsevents@^1.2.7":
"integrity" "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw=="
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz"
"version" "1.2.13"
dependencies:
"bindings" "^1.5.0"
"nan" "^2.12.1"

"fsevents@~2.3.2":
"integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
"version" "2.3.2"

"function-bind@^1.1.1":
"integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
"resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
Expand Down Expand Up @@ -9102,6 +9127,11 @@
"resolved" "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz"
"version" "0.0.7"

"nan@^2.12.1":
"integrity" "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
"resolved" "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz"
"version" "2.15.0"

"nanomatch@^1.2.9":
"integrity" "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA=="
"resolved" "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz"
Expand Down

0 comments on commit 7dcf1a0

Please sign in to comment.