1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4834],{4834:(e,t,l)=>{l.r(t),l.d(t,{Graphable_Calculate_LinearApproximation:()=>x});var a=l(95155),r=l(12115),s=l(80357),i=l(19332),n=l(49080),o=l(40344),u=l(96778),c=l(55773),h=l(71024),d=l(34027);class x{constructor(e,t,l){this.generateCalculationTable=()=>{if(!this.calculate_results)return[null,null];let e="Linear Approximation Calculator, L(x)",t=(0,u.w)(this.calculate_results.intercept),l=(0,u.w)(this.calculate_results.slope),r=t>l?t:l,{slope:s,intercept:i}=this.calculate_results,o={rows:[(0,a.jsx)(n.m,{equation:{forward:e=>(0,c.e)(s*e+i,r),reverse:e=>(0,c.e)((e-i)/s,r)},title:"Linear approximation"},e)],title:e,config:{allowCopy:!0}};return[e,o]},this.generateLx=(e,t)=>{let l=t<0?(0,a.jsxs)(r.Fragment,{children:["â ",-1*t]}):(0,a.jsxs)(r.Fragment,{children:["+ ",t]});return(0,a.jsxs)(r.Fragment,{children:[" y = ",e,(0,a.jsx)(s.default,{sx:{fontStyle:"italic"},component:"span",children:"x"})," ",l]})},this.resultsTableAdditional=()=>{if(!this.calculate_results)return[null,null];let e=this.generateLx(this.calculate_results.slope,this.calculate_results.intercept),t="Approximation Steps",l={rows:[["Parameter","Value"],["Taylor's theorem, n = 1",(0,a.jsx)(r.Fragment,{children:"L(x) â f(a) + f'(a)(x - a)"},0)],["Original Equation, F(a)","y = ".concat(this.calculate_results.original)],["Derivative Equation, F'(a)","y = ".concat(this.calculate_results.derivative)],["f(a), a = ".concat(this.calculate_results.x0),this.calculate_results.x0_fn],["f(a), a = ".concat(this.calculate_results.x0),this.calculate_results.x0_fnp],["f'(a) * a, a = ".concat(this.calculate_results.x0),this.calculate_results.intercept],["Linear Approximation, L(x)",e]],title:t};return[t,l]},this.resultsTable=()=>{if(!this.calculate_results)return[null,null];let e=this.generateLx(this.calculate_results.slope,this.calculate_results.intercept),t="Linear Approximation";return[t,{rows:[["Parameter","Value"],["Linear Approximation, L(x)",e]],title:t}]},this.renderResults=()=>{if(!this.calculate_results)return;this.output=new d.B;let[e,t]=this.resultsTable();e&&t&&this.output.addTable(t);let[l,a]=this.resultsTableAdditional();l&&a&&this.output.addTable(a);let[r,s]=this.generateCalculationTable();r&&s&&this.output.addTable(s)},this.calculate=async()=>{try{let e=i.e.convertToApi(this.inputs_options),t=new o.ApiWrapper("/api/tools/linear-approximation"),l=await t.post({labels:[],sets:[],options:e});if(!l||!l.results)throw Error("Calculation failed");this.calculate_results=l.results,this.renderResults()}catch(e){h.i.generic();return}},this.inputs_data=e,this.inputs_options=t,this.url=l}}},34027:(e,t,l)=>{l.d(t,{B:()=>a});class a{get order(){return this.orderInternal}get entries(){return this.entriesInternal}addEntry(e,t){let l="".concat(e,"_").concat(this.orderInternal.length+1);this.orderInternal.push(l),this.entriesInternal[l]=t}constructor(){this.orderInternal=[],this.entriesInternal={},this.addPlot=e=>{this.addEntry("plot",{type:"plot",data:e})},this.addTable=e=>{this.addEntry("table",{type:"table",data:e})}}}},49080:(e,t,l)=>{l.d(t,{m:()=>S});var a=l(95155),r=l(54463),s=l(31512),i=l(96869),n=l(50645);let o=(0,n.A)((0,a.jsx)("path",{d:"M19 7H9c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2m0 2v2H9V9zm-6 6v-2h2v2zm2 2v2h-2v-2zm-4-2H9v-2h2zm6-2h2v2h-2zm-8 4h2v2H9zm8 2v-2h2v2zM6 17H5c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2v1h-2V5H5v10h1z"}),"TableView");var u=l(75265),c=l(2021),h=l(56919),d=l(41477),x=l(1123),p=l(40670),f=l(66370),m=l(12115),b=l(15636),j=l(20999);let g=(0,m.createContext)(void 0),v=e=>{let{children:t}=e,[l,r]=(0,m.useState)([{x:"",y:""}]);return(0,a.jsx)(g.Provider,{value:{rows:l,_rows:r},children:t})},y=()=>{let e=(0,m.useContext)(g);if(void 0===e)throw Error("useContext must be used within a valid context provider");return e},_=e=>{let{calcBulk:t,open:l,_open:r}=e,[s,n]=(0,m.useState)("x"),[o,b]=(0,m.useState)(""),g=(0,m.useCallback)(()=>{t(s,o.trim().split("\n").map(e=>e.trim())),r(!1)},[s,o,t,r]);return(0,a.jsxs)(u.A,{open:l,onClose:()=>{r(!1)},children:[(0,a.jsx)(c.A,{children:"Paste in multiple X or Y values, one per line"}),(0,a.jsxs)(i.default,{gap:2,px:4,alignItems:"center",children:[(0,a.jsxs)(h.A,{row:!0,onChange:e=>{n("x"===e.target.value?"x":"y")},value:s,children:[(0,a.jsx)(d.A,{value:"x",control:(0,a.jsx)(x.A,{}),label:"X"}),(0,a.jsx)(d.A,{value:"y",control:(0,a.jsx)(x.A,{}),label:"Y"})]}),(0,a.jsx)(p.A,{type:"text",multiline:!0,rows:6,placeholder:"Paste one value per line",value:o,onChange:e=>{b(e.target.value)},fullWidth:!0}),(0,a.jsx)(f.A,{children:(0,a.jsx)(j.I,{onClick:g,children:"Calculate"})})]})]})},C=e=>{let{equation:t}=e,{_rows:l}=y(),[r,s]=(0,m.useState)(!1),i=(0,m.useCallback)((e,a)=>{if(!t||!a.length)return;let r=[];for(let l of a){let a={x:"",y:""};switch(e){case"x":{a.x=l;let e=Number(l);if(isNaN(e))a.y="";else{let l=t.forward(e);a.y="number"!=typeof l||isNaN(l)?"":l.toString()}break}case"y":{a.y=l;let e=Number(l);if(isNaN(e))a.x="";else{let l=t.reverse(e);a.x=Array.isArray(l)?l:isNaN(l)?"":l.toString()}}}r.push(a)}l(e=>{let t=[...e];for(let e of r)t.push(e);return t.push({x:"",y:""}),t})},[t,l]);return(0,a.jsxs)(b.V,{children:[(0,a.jsx)(j.I,{variant:"text",color:"aat_gray_dark",onClick:()=>{s(!0)},size:"small",startIcon:(0,a.jsx)(o,{}),children:"Bulk Calculate"}),(0,a.jsx)(_,{calcBulk:i,open:r,_open:s})]})},w={"& .MuiOutlinedInput-root":{"& fieldset":{border:0}
1,"&.Mui-focused fieldset":{border:"2px solid",borderColor:"aat_blue_light.main"}}},A=e=>{let{equation:t,row:l,index:i,rowCount:n}=e,{_rows:o}=y(),u=(0,m.useCallback)(e=>{let l,{target:a}=e,{value:r}=a,s=Number(r);if(isNaN(s))l="";else{let e=t.forward(s);l="number"!=typeof e||isNaN(e)?"":e.toString()}o(e=>{let t=[...e];return t[i]={x:r,y:l},t})},[t,o,i]),c=(0,m.useCallback)(e=>{let l,{target:a}=e,{value:r}=a,s=Number(r);if(isNaN(s))l="";else{let e=t.reverse(s);l=Array.isArray(e)?e:isNaN(e)?"":e.toString()}o(e=>{let t=[...e];return t[i]={x:l,y:r},t})},[t,o,i]),h=(0,m.useCallback)(()=>{o(e=>{let t=[...e];return t.push({x:"",y:""}),t})},[o]),d=(0,m.useCallback)(()=>{i+1===n&&h()},[n,i,h]);return t&&"function"==typeof t.forward&&"function"==typeof t.reverse&&n?(0,a.jsxs)(r.default,{children:[(0,a.jsx)(s.default,{children:(0,a.jsx)(p.A,{size:"small",fullWidth:!0,type:Array.isArray(l.x)?"text":"number",onChange:u,value:Array.isArray(l.x)?l.x.join("; "):l.x,placeholder:"Enter X to calculate Y",onClick:d,sx:w})}),(0,a.jsx)(s.default,{children:(0,a.jsx)(p.A,{size:"small",fullWidth:!0,type:"number",onChange:c,value:l.y,placeholder:"Enter Y to calculate X",onClick:d,sx:w})})]}):null},k=(0,n.A)((0,a.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}),"ContentCopy");var N=l(25367),T=l(4615);let z=()=>{let{rows:e}=y(),[t,l]=(0,m.useState)(!1),r=(0,m.useCallback)(async()=>{if(!e.length)return;l(!0);let t=e.map(e=>[e.x,e.y].join(" ")).join("\n");await navigator.clipboard.writeText("X Y\n"+t)},[e]),s=(0,m.useCallback)(()=>{l(!1)},[]);return(0,a.jsxs)(b.V,{children:[(0,a.jsx)(j.I,{variant:"text",startIcon:(0,a.jsx)(k,{}),color:"aat_gray_dark",onClick:r,size:"small",children:"Copy Table"}),(0,a.jsx)(N.A,{open:t,autoHideDuration:3e3,onClose:s,message:"Table copied to clipboard",color:"success",anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,a.jsx)(T.default,{onClose:s,severity:"success",variant:"filled",children:"Table copied to clipboard"})})]})},I=e=>{let{title:t,equation:l}=e;return(0,a.jsx)(r.default,{sx:{backgroundColor:"aat_green_light.main"},children:(0,a.jsx)(s.default,{colSpan:2,sx:{fontWeight:"semi"},children:(0,a.jsxs)(i.default,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[t,(0,a.jsxs)(i.default,{direction:"row",gap:2,children:[(0,a.jsx)(C,{equation:l}),(0,a.jsx)(z,{})]})]})})})},L=e=>{let{title:t}=e;return(0,a.jsxs)(r.default,{sx:{backgroundColor:t?"aat_gray_lighter.main":void 0},children:[(0,a.jsx)(s.default,{children:"X"}),(0,a.jsx)(s.default,{children:"Y"})]})},M=e=>{let{equation:t}=e,{rows:l}=y();return(0,a.jsx)(a.Fragment,{children:l.map((e,r)=>(0,a.jsx)(A,{equation:t,row:e,index:r,rowCount:l.length},r))})},S=e=>{let{equation:t,title:l}=e;return(0,a.jsxs)(v,{children:[(0,a.jsx)(I,{title:l,equation:t}),(0,a.jsx)(L,{title:l}),(0,a.jsx)(M,{equation:t})]})}},55773:(e,t,l)=>{l.d(t,{e:()=>a});let a=(e,t)=>{let l=t;if(0===l)return Math.round(e);let a=e<=0?-1:1,r=e*a;l>=100&&(l=100);let s=r;if(s>1)s=parseFloat((s=Math.round(s*Math.pow(10,l))/Math.pow(10,l)).toFixed(l));else if(0!==s){let e=Math.floor(Math.log10(r))-l;e<=-100&&(e=-100);let t=1/Math.pow(10,-1*e);s=parseFloat((s=Math.round(s/t)*t).toFixed(-1*e))}return s*a}},71024:(e,t,l)=>{l.d(t,{i:()=>a});class a{}a.generic=e=>{if(e)return void alert(e);alert("An error has occured and the requested calculation could not be completed. For assistance, please contact [email protected].")}},96778:(e,t,l)=>{l.d(t,{w:()=>a});let a=e=>{let t=e.toString().split(".");return 2===t.length?t[1].length:0}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.