PageSourceSearch

https://calcuworld.com/wp-content/cache/autoptimize/1/js/autoptimi…_single_9fc4716aba8ab142075963b0be217bcb.js

js calcuworld.com collected 2026-10-02 10:18:53 UTC 5,527 bytes, 26 lines download raw bytes

1var Finance=function(){};Finance.prototype.PV=function(rate,cf1,numOfPeriod){numOfPeriod=typeof numOfPeriod!=='undefined'?numOfPeriod:1;var rate=rate/100,pv;pv=cf1/Math.pow((1+rate),numOfPeriod);return Math.round(pv*100)/100;};Finance.prototype.FV=function(rate,cf0,numOfPeriod){var rate=rate/100,fv;fv=cf0*Math.pow((1+rate),numOfPeriod);return Math.round(fv*100)/100;};Finance.prototype.NPV=function(rate){var rate=rate/100,npv=arguments[1];for(var i=2;i<arguments.length;i++){npv+=(arguments[i]/Math.pow((1+rate),i-1));}
2return Math.round(npv*100)/100;};function seekZero(fn){var x=1;while(fn(x)>0){x+=1;}
3while(fn(x)<0){x-=0.01}
4return x+0.01;}
5Finance.prototype.IRR=function(cfs){var depth=cfs.depth;var args=cfs.cashFlow;var numberOfTries=1;var positive,negative;Array.prototype.slice.call(args).forEach(function(value){if(value>0)positive=true;if(value<0)negative=true;})
6if(!positive||!negative)throw new Error('IRR requires at least one positive value and one negative value');function npv(rate){numberOfTries++;if(numberOfTries>depth){throw new Error('IRR can\'t find a result');}
7var rrate=(1+rate/100);var npv=args[0];for(var i=1;i<args.length;i++){npv+=(args[i]/Math.pow(rrate,i));}
8return npv;}
9return Math.round(seekZero(npv)*100)/100;};Finance.prototype.PP=function(numOfPeriods,cfs){if(numOfPeriods===0){return Math.abs(arguments[1])/arguments[2];}
10var cumulativeCashFlow=arguments[1];var yearsCounter=1;for(i=2;i<arguments.length;i++){cumulativeCashFlow+=arguments[i];if(cumulativeCashFlow>0){yearsCounter+=(cumulativeCashFlow-arguments[i])/arguments[i];return yearsCounter;}else{yearsCounter++;}}};Finance.prototype.ROI=function(cf0,earnings){var roi=(earnings-Math.abs(cf0))/Math.abs(cf0)*100;return Math.round(roi*100)/100;};Finance.prototype.AM=function(principal,rate,period,yearOrMonth,payAtBeginning){var numerator,denominator,am;var ratePerPeriod=rate/12/100;if(!yearOrMonth){numerator=buildNumerator(period*12);denominator=Math.pow((1+ratePerPeriod),period*12)-1;}else if(yearOrMonth===1){numerator=buildNumerator(period)
11denominator=Math.pow((1+ratePerPeriod),period)-1;}else{console.log('not defined');}
12am=principal*(numerator/denominator);return Math.round(am*100)/100;function buildNumerator(numInterestAccruals){if(payAtBeginning){numInterestAccruals-=1;}
13return ratePerPeriod*Math.pow((1+ratePerPeriod),numInterestAccruals);}};Finance.prototype.PI=function(rate,cfs){var totalOfPVs=0,PI;for(var i=2;i<arguments.length;i++){var discountFactor;discountFactor=1/Math.pow((1+rate/100),(i-1));totalOfPVs+=arguments[i]*discountFactor;}
14PI=totalOfPVs/Math.abs(arguments[1]);return Math.round(PI*100)/100;};Finance.prototype.DF=function(rate,numOfPeriods){var dfs=[],discountFactor;for(var i=1;i<numOfPeriods;i++){discountFactor=1/Math.pow((1+rate/100),(i-1));roundedDiscountFactor=Math.ceil(discountFactor*1000)/1000;dfs.push(roundedDiscountFactor);}
15return dfs;};Finance.prototype.CI=function(rate,numOfCompoundings,principal,numOfPeriods){var CI=principal*Math.pow((1+((rate/100)/numOfCompoundings)),numOfCompoundings*numOfPeriods);return Math.round(CI*100)/100;};Finance.prototype.CAGR=function(beginningValue,endingValue,numOfPeriods){var CAGR=Math.pow((endingValue/beginningValue),1/numOfPeriods)-1;return Math.round(CAGR*10000)/100;};Finance.prototype.LR=function(totalLiabilities,totalDebts,totalIncome){return(totalLiabilities+totalDebts)/totalIncome;};Finance.prototype.R72=function(rate){return 72/rate;};Finance.prototype.WACC=function(marketValueOfEquity,marketValueOfDebt,costOfEquity,costOfDebt,taxRate){var E=marketValueOfEquity;var D=marketValueOfDebt;var V=marketValueOfEquity+marketValueOfDebt;var Re=costOfEquity;var Rd=costOfDebt;var T=taxRate;var WACC=((E/V)*Re/100)+(((D/V)*Rd/100)*(1-T/100));return Math.round(WACC*1000)/10;};Finance.prototype.PMT=function(rate,numOfPayments,principal){var rate=rate/100,pmt;pmt=-(principal*rate)/(1-Math.pow(1+rate,-numOfPayments))
16return Math.round(pmt*100)/100;};Finance.prototype.IAR=function(investmentReturn,inflationRate){return 100*(((1+investmentReturn)/(1+inflationRate))-1);}
17Finance.prototype.XIRR=function(cfs,dts,guess){if(cfs.length!=dts.length)throw new Error('Number of cash flows and dates should match');var positive,negative;
17Array.prototype.slice.call(cfs).forEach(function(value){if(value>0)positive=true;if(value<0)negative=true;});if(!positive||!negative)throw new Error('XIRR requires at least one positive value and one negative value');guess=!!guess?guess:0;var limit=100;var guess_last;var durs=[];durs.push(0);for(var i=1;i<dts.length;i++){durs.push(durYear(dts[0],dts[i]));}
18do{guess_last=guess;guess=guess_last-sumEq(cfs,durs,guess_last);limit--;}while(guess_last.toFixed(5)!=guess.toFixed(5)&&limit>0);var xirr=guess_last.toFixed(5)!=guess.toFixed(5)?null:guess*100;return Math.round(xirr*100)/100;}
19Finance.prototype.CAPM=function(rf,beta,emr,err){var ans=rf/100+beta*(emr/100-rf/100);return ans;}
20Finance.prototype.stockPV=function(g,ke,D0){var valueOfStock=(D0*(1+g/100))/((ke/100)-(g/100))
21return Math.round(valueOfStock)}
22function sumEq(cfs,durs,guess){var sum_fx=0;var sum_fdx=0;for(var i=0;i<cfs.length;i++){sum_fx=sum_fx+(cfs[i]/Math.pow(1+guess,durs[i]));}
23for(i=0;i<cfs.length;i++){sum_fdx=sum_fdx+(-cfs[i]*durs[i]*Math.pow(1+guess,-1-durs[i]));}
24return sum_fx/sum_fdx;}
25function durYear(first,last){return(Math.abs(last.getTime()-first.getTime())/(1000*3600*24*365));}
26if(typeof exports!=='undefined'&&typeof module!=='undefined'&&module.exports){module.exports=Finance;module.exports.Finance=Finance;}

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.