Extending Math Functions

Jul 23, 2005

Javascript has a very small math function list. However there is no
reason that this list can not be extended greatly. Speed is not an
issue, unless you nest complicated calculations several levels deep. In
that case you need much more ram than a PC has to store functions
calculated in loops so that you do not have to recalculate every time
you cycle through the nest of loops. Using a HD for storage to extend
ram is much too slow for many applications.

Some functions such as hyperbolic ones are easy to add, since they are
just simple combinations of the built in javascript math functions. I
have found a few examples on the web such as Bessel functions. I found
far fewer javascript math functions than I expected on Google searches.
Thus I have had to write several functions of my own.

See http://www.cwdjr.net/math/I0L0andI1L1.html for an example of two
"functions from hell" that are very difficult to evaluate. Fortunately
there are Fortran programs that can be used as a starting point. I was
able to modify the Fortran programs to work on javascript. I have used
these functions for technical applications in the past.

The page is set up to reject the NN 4 series, because it will not
support some of the script needed such as .toExponential(n) and
to.Fixed(n)for writing output in exponential or fixed format. I was
amazed that even the old MSNTV(former WebTV) set-top box, that no
longer is being made, will even support these output formats. I wonder
about IE4. If it will not support these output formats, I can easly
block it by checking for document.getElementById.

The code works properly on the latest versions of IE6, MSN9, Firefox,
Mozilla, Netscape, and Opera. I am not selling anything, so for a
special interest page such as this, I see no need to support older
browsers.

The advantage of doing math with javascript is that it is so portable.
You can do it anywhere you can use a computer, or you can do it on your
own local computer offline. There are several math programs for PCs
that will do very much more than you can hope to do with javascript.
Unfortunately the program I would like costs about US$ 1800. Also there
are versions you can install on a server, but these also are expensive.

View 17 Replies


ADVERTISEMENT

Need Help With Split And Math Functions

Nov 7, 2006

Code:
function finalSize(){
var size = document.getElementById('size').value;
var margin = document.getElementById('margins').value;
var mirrors = document.getElemntById('mirrorsRadio').value;

var size_array = size.split('x');
var h = size_array[0];
var w = size_array[1];

var finalH = ''
var finalW = ''

if(margin > 1){
finalH = h * margin;
finalW = w * margin;
document.getElementById('finalSize').value = finalH+'x'+finalW;
}else{
newH = h * margin;
newF = w * margin;
finalH = newH + h;
finalW = newW + w;
document.getElementById('finalSize').value = finalH+'x'+finalW;
}

}
I see it's ok, but it gives me this error:

Object doesn't support this property or method.

I don't know what I'm doing wrong. All I know is PHP, but from what little I learned on Javascript, my brain is telling me I'm right, but my experience is telling me I'm wrong. XD

View 1 Replies View Related

User Inputed Math Functions?

Jan 8, 2012

Initiate function function count(form){Initiate vars

var answer=0;
var lower_limit;
var upper_limit;
var func;
should it not be parseInt? Maybe thats why.
parseInt(form.user_input.value)

[Code]...

As you can see by what im doing here, I'm trying to make it so that a person can enter a math expression in a form text box and based on what the user entered, javascript will compute the summation of the function.

What I'm truly asking here is, how do I make Javascript correctly compute the sum, based on what the unser inputed? Because when I enter for example, 1/x, a lower limit, and a upper limit, it just returns an answer of NaN. I'm one step away from building a Javascript function to compute the sum of any user inputed function. It's just the text parsing thats got me knocked down.

View 3 Replies View Related

How To Loop The Math.min And Math.max

Feb 20, 2010

the program that i want to create will first let the user input how many execution he want to perform and will determine the highest and lowest number that he inputted.

for example.

prompt: how many execution you want to perform?
i type: 5
prompt:input number:10
prompt:input number:8
prompt:input number:5

[Code]....

but it only allows for the up to inputs[6] and the code is very long. i think i can use looping in it. but i dont know to use looping in math.min and math.max.

View 4 Replies View Related

Extending The Objects In IE6-8?

Jan 22, 2011

I have the following code:

var img = new Image();
img.myProperty = 'something';

I've tried Image.prototype.myProperty and a few other things. It seems IE just doesn't want me extending the Image object.

View 3 Replies View Related

Extending Form

Mar 18, 2004

I'm looking for a way to add more field depending on the user's input,. e.g. the user inputs ཆ' in the option, and 10 more sets of fields are displayed below on the same page. How do I go about accomplishing this?

View 1 Replies View Related

DOM + Extending Forms

Sep 26, 2005

I'm embarking on a rather interesting wine cellaring project where I need to enable a user to add form fields (a complete table row with several fields) on demand.

If they start filling out the form and need another row for another bottle, I need them to be able to click a button that adds a new row to the table with the same fields.

I also need perhaps another button that will create the row and duplicate the form field values of that row. The winery, wine namen and variety may be the same but the year may change and I dont wan thte user to have to do any double entry. I've been researching DOM and have been looking at sites like Quirksmode.

Am I heading in the right direction? I'm just about to go an buy a book on DOM and start really getting into it.

View 2 Replies View Related

Extending HTML Forms?

Feb 1, 2007

I am trying to create an HTML form in which user will enter different items (he wants to purchase) in text fields. One text field is used for one item. Now it is not known in advance how much items the user will purchase so we cannot decide the total text fields required in advance. Is is possible to increase the number of text fields (using JavaScript) one by one if the user requires more fields

View 4 Replies View Related

DOM - Extending A Form And Table

Jan 9, 2007

How do I extend both the table and the input form? Ultimately, I want it to look like this:
_____________________________
|header |header |header |header |
| INPUT | INPUT | INPUT | INPUT |
Add Row of Inputs Link
_____________________________
|header |header |header |header |
| INPUT | INPUT | INPUT | INPUT |
| INPUT | INPUT | INPUT | INPUT |
Add Row of Inputs Link

I know how to make the html row by using getElementById() or so and I know how to make an input field by createElement() but how do I create and append(?) them together, specifically the multiple input fields inside of the html row?

View 1 Replies View Related

JS Menu Extending Out Of Frame

Nov 24, 2007

My website has demo music tracks and a Flash player. I've put the site in a frameset so that music continues to play while the user is browsing around.

The Flash player and menu are in a thin horizontal bar along the top of the page (top frame). I just realised that my nice JS drop-down menus are not displaying because of the frame... is there any way of getting them to extend beyond the frame they're contained in ?? Code:

View 3 Replies View Related

OOP - Extending A Class And Overriding A Method?

Jul 14, 2009

I have this class, (just the signature)

javascript Code:

var parent_child = function(po, ps, co, cs){
var url = 'http://xyz.com/abc/';
var pars = [], childs = {}, tmp;
this.p_added = function(urlFrag){

[Code]....

What i want to do is to create a new class with the above one as the super class, pass in one more variable to the constructor and override the p_added function. I thought of doing something like xpc = new parent_child(); and override the function with xpc.prototype.p_added = function(){}

how to pass in another variable to the constructor and make it private to the new class.

I believe there is a nice and concise way to achieve what i want to, but i can't find it. And the fact that OOP in javascript can be implemented in several different ways doesn't help my cause.

View 1 Replies View Related

JQuery :: Extending Or Replacing Core Function?

May 17, 2010

A client is using an analytics tracking script that needs to be updated each time the DOM is modified (ie, an element is added or removed). Basically this script allows the client to track user actions on the site (clicks, mouseovers, etc.) and, if the user is having issues, replay the entire session to help them with their problem. The issue we're running into is that this tracking script takes a cache of the DOM tree on page load, and when the DOM is updated it needs to specifically be notified that there has been a change... or else the script won't be able to see the nodes that have been added/removed.

Assuming all DOM manipulation is done using jQuery functions, is there a way to run some function every time the DOM is manipulated? I've noticed that all the DOM manipulation functions seem to run through the internal $.fn.domManip function, so I was wondering if it's possible to extend or replace this function from another JS file (assuming of course that all the manipulation functions DO in fact run through $.fn.domManip)?

Example (don't take this code seriously, it's more meant to illustrate what I'm trying to do):
var oldDomManip = $.fn.domManip; //Copy the function (I know this isn't right)
$.fn.domManip = function() {
oldDomManip(arguments);
//update the analytics program by calling it's update function here...
}

View 2 Replies View Related

JQuery :: Plugin For Extending .keypress To Two Keypresses?

Sep 26, 2009

I'm writing a plugin for jQuery for catching 2 succesive keypresses. I'll paste the plugin I wrote below It doesn't work on Opera . The Developer tools of Opera gave no errors and I can't find any problems, it just doesn't work.(I've used Opera 10.0). o it only works on Firefox (tested on 3.0.14). I'm curious if there is a way to find out why it's not working on Opera and to fix it.

[Code]...

View 1 Replies View Related

Sites Dedicated To Extending Native Objects?

Nov 24, 2009

I was wondering if there are any sites dedicated to ending javascript objects using the prototype property to give them features like trimming string, removing elements of arrays by name, removing duplicates in arrays, etc. Granted I have functions to do this but there's probably a ton of other good ones out there. Most things I've seen are frameworks like JQuery (which is awesome) but it doesn't extend these objects.

View 2 Replies View Related

Extending An Object Whose Constructor Takes Arguments?

Jan 2, 2011

I'm sure this question has been asked many times before, but I can't seem to get the correct terms to find the answer in Google.I understand basic JavaScript inheritance. However, everything I've read makes the inheritance work something like this:

Code JavaScript:
var ChildClass = new Function();
ChildClass.prototype = new ParentClass();
ChildClass.constructor = ChildClass;

That's fine, but what happens when ParentClass's constructor needs parameters?As an example, look at the following code:

Code JavaScript:
function Furniture(color){
this.color = color;[code)....

How could I "copy" Furniture's constructor into the Chair object? Better yet, how could I copy Furniture's constructor and then add some functionality to it?

View 9 Replies View Related

Prototypes - Extending An Image Object To Make A Snowflake?

Jan 1, 2011

In the spirit of the season, I wanted to make it snow on my website. So I began digging. Eventually I ended up with a script that moved an image element down the page in a snowflake-like manner. The problem with it was it was dependant on an img element for every flake - simply no poor programming when using an Object Oriented programming language.So I decided I wanted to extend (in Java-speak; most of my programming background is in Java) the in-built Image object. The new object's src variable will lead to an image of the type of flake it is. (I want to be able to have more variance in images than a simple dot.) The new object will have a function that will allow it to move.A separate,unrelated function will control when each flakes move.

I did some more research and read about prototyping on JavaScript Kit and here (http://mckoss.com/jscript/object.htm), but I still cant seem to get this to work. JS Lint says it's bug-free, but Firefox says "move()" is an invalid function. I am presuming the problem lies in my inability to fully grasp how to extend objects in JavaScript.

<html>
<head>
<script type="text/javascript">[code].....

View 6 Replies View Related

JQuery :: Extending Background Stretcher Plug In And Add Navigation?

Oct 21, 2010

I am working wiht this JQuery plug in that now one of my clients wants to turn it into a slideshow feature. I am not that familiar with JQuery plug ins so I wanted to get some input from some of you.

On the header of my html page:

Code:

$(document).bgStretcher({
images: ['1.jpg', '2.jpg', '3.jpg', '4.jpg'],
imageWidth: 1668, imageHeight: 1035, nextSlideDelay: 3000, slideShowSpeed: 4000
});

I was able to add a click handler to trigger the a function on the plugin called loadslide().

Code:

$(document).ready(function ($) {
$('.slideNo').each(function (i) {
$(this).click(function () {
loadSlide(i);

[Code].....

View 2 Replies View Related

JQuery :: Prevent Unorder List Submenu From Extending Past Viewport

Feb 10, 2011

Im trying to prevent my unorder list submenu from extending past the viewport.[code]

View 3 Replies View Related

Help With Math.abs()

May 21, 2007

Anyone any idea why the Math.abs() isn't working in this code? I
thought it was supposed to convert negative numbers to whole numbers?

var se = [-27, -27, -27];
var time = 100
if(se[0] < 0){
Math.abs(se[0]); //<-- this isn't converting it to a whole number
se[0] += 1;
se[0] = (se[0]/(time / 4));
}

The result I get is -1.04 when it should be 1.12

View 5 Replies View Related

Math.random()

Jul 20, 2005

I remember there is a programming language where you can initialize the
random number generator, so that it can - if you want - give you the exactly
same sequence of random numbers every time you initialize it with the same
parameter. Can this be done with JavaScript? I couldn't find anything in the
documentation. Basically, what I want to achieve is to obtain always the
same sequence of random numbers for the same given initialization value (but
of course different sequences for different init values).

Can this be done in JavaScript?

View 23 Replies View Related

Getting Nan Error With Simple Math

Mar 5, 2010

why I am getting Nan

<script type="text/javascript">
var num1;
var num2;
var num3;

[Code]....

View 3 Replies View Related

Firefox Math Messing Up Somehow?

Jun 18, 2010

<script type="text/javascript">
function countItDown(){
var current=parseFloat(document.getElementById("currentsecondscount").value);
var seconds=current;
document.getElementById("debug").innerHTML="S "+current;
var minutes=Math.floor(seconds/60);

[Code]...

im not sure why Firefox is doing this. it seems to work fine on Firefox 3.6.3 for Mac.

View 14 Replies View Related

Change CSS Property With Math?

Nov 23, 2010

I have this simple manual photo slide show. It shows four photos and when you click the next button and it moves one photo over and one photo back for the previous button. I have to moving by changing the CSS property of 'left' by 195 pixels each move. So for it to move next it will subtract 195 pixels from the left property and for moving back it add 195 pixels to the left property. I have the code setup so when you click it changes the property of left to either -195 or 195 pixels but I need it so it actually does the math, not just give it a set value. But I don't know how to do that.code...

View 3 Replies View Related

Allow Math To Be Eval'ed - But Not Malicious ?

Feb 10, 2011

I have a website that allows users to enter complex mathematical formulas into a text field and evaluates them.

I am currently using eval() because it not only can handle all the standard mathematical functions, but also gives them access to the Math object. That way the users can use functions such as Math.max() and everything else.

I realize, though, that using eval is evil, I assume because a malicious user might throw in some more damaging javascript that would be run without checking it. (That's why eval is evil, right?)

Is there a way that I can allow my users to construct complex mathematical formulas and use the Math object (or an equivalent) without potentially opening my site up to harm?

View 3 Replies View Related

Still Can't Fix Math.round / Make It Possible?

Nov 8, 2011

Just started to learn java & came up with the following, but can't get the math.round to work. Anyone able to tell me where I'm going wrong please ? code...

View 9 Replies View Related

Math Base 2 Logarithm?

Nov 10, 2005

If I have the following

2^n=a

javascript:Math.pow(2,n)=a;

and I now a how do I then find n with javascript?.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved