• Electricity
    • Waterfall >
      • Pumped Storage >
        • Hydro Electricity
        • Pumped Storage Online Research
    • Virtual Laboratory
    • Electricity Lecture
  • Analog DC Circuits
    • Simple Ohms Law Demo
    • Ammeter Troubleshooting >
      • GLM P36 & P37 >
        • GLM P38 & P39
        • GLM P40 & P41
        • GLM P42 & P43
        • GLM P44 & P45
    • Bridge Circuit
    • Power and the Wattmeter >
      • DC Online Free Tutorials
      • GLM Page 29
      • GLM Page 30
      • GLM Page 31
    • Series Circuit Simulation #1 >
      • Series Circuit Sim #2
      • Series Circuit Sim #3
      • Series Circuit Sim #4
    • HVDC Power Transmission
    • DC LECTURE
  • Analog AC Circuits
    • Simple AC Circuits Demonstrations
    • AC Filter Troubleshooting
    • Transformer
    • AC Lecture
    • AC Online Free Tutorials
  • Digital Electronics
    • Four Bit Adder >
      • GLM P232 & 233 >
        • GLMP234 & 235
        • GLM P236 & 237
        • GLM P239 & 240
        • Slider Test Page #1
    • Four Bit Comparator >
      • Comparator Failure 1
      • Comparator Failure 2
    • Digital Online Tutorials and eBooks
    • Digital Electronics Lecture
  • Transistor Circuits
    • Transistor Operation
    • Voltage Regulator
    • Amplifier 3 Stage >
      • Transistor Amp Fault 1 Slideshow
    • Transistor Online Tutorials and eBooks
    • Transistor Lecture
  • Computers
    • Instruction Set, Microprocessor Specifications, and Schematic
    • Control Panel
    • Step by Step Tutorial
    • Programmable Memory
    • Computers Online Tutorials and eBooks
  • Computer Interface
    • Interface schematic
    • Drawing Notes
    • InterfaceFault1
    • InterfaceFault2
    • InterfaceFault3
    • InterfaceFault4
    • InterfaceFault5
    • Cyber Attack
  • Physics
    • About Newton's Laws >
      • Physics (Newton's Laws) >
        • Flatspace >
          • Flat space source code (script)
          • Flat-space with Target >
            • Flat-space with Target - Source Code
            • Target Closing Velocity #1
            • Target Closing Velocity #2
        • Gravity >
          • Earth Gravity
          • Gravity Source Code
        • Gravity + Track
        • Orbit Earth Equator
        • Earth Orbit Easy
        • Pluto Orbit >
          • Pluto Source Code
    • Deep Space North >
      • Escape Velocity
      • Radar Display
      • Intercept #1
      • Intercept #2
      • Intercept #3
      • Intercept #4
    • Physics (Heat Engine) >
      • Heat Engine
      • Heat Engine JavaScript
    • Physics Online Resources
    • Free College Links
  • JavaScript (JS)
    • The Math Object >
      • Resistors in Parallel
    • Simple Form Gui >
      • Button Form
    • Series Circuit (JS)
    • JavaSource Downloads >
      • Bouncing Ball
    • JaveScript Lessons >
      • Lesson #1
      • Lesson #2
      • Lesson #3
      • Lesson #4
  • Site Map
    • Site Map Level 2 >
      • Site Map Level 3
  • Our Product
    • Text Files Online
  • WEB Development
    • Google Drive
    • Dreamweaver
    • Internet Security
  • About
    • Electronics Course >
      • FREE TEXT EBOOKS >
        • Free Online Colleges
      • Already got a book?
    • Universal Software Development Platform
    • Best Tutorial per hour of study.
    • Shortcut to a Career Path
  • Teachers Only
    • Circuit Troubleshooting
    • JS for Technical Students
    • Physics and Math
Electronics Circuit Simulator and Physics Virtual Laboratory.









JavaScript Math Object

JavaScript with its Math Object provides a universal platform for anyone wishing to program relatively complex scientific calculations.  Input values for X and N in program that raises X to N power and then view script at bottom of page.

JaVASCRIPT(JS)
The Math object provides additional and more complex mathematical operations than the basic ones (+, -, *, /).  We also show how to input data using Prompt method (View bottom of page!).  After completion of this page you should be able to program your own special purpose calculator for most analog scientific calculations. 

Syntax                    Output

Math.abs(value)            Absolute value
Math.acos(value)          Arc Cosine in radians
Math.asin(value)           Arc sine in radians
Math.atan(value)           Arc Cosine in radians
Math.atan2(x,y)              Angle of polar coordinates of x, y
Math.ceil(value)              Next Integer greater or equal to value
Math.cos(value)              Cosine of value. Value input in radians
Math.floor(value)              Next Integer less than or equal to value
Math.log(value)               Natural Log (base e) of value
Math.max(val1, val 2)     The greater of value 1 or value 2
Math.min(val1, val 2)      The lessor of value 1 or value 2
Math.pow(val1, val 2)     value 1 to the value 2 power
Math.random()                Random number between 0 and 1
Math.round(value)           rounds to closest integer (n.5000 rounds up).
Math.sin(value)                Sin of value (value input in radians)
Math.sqrt(value)              Square Root of value 
Math.tan(value)                 Tangent of value (value input in radians)

Prompt method of inputing information:
     var text = prompt ("Enter Integer for var N ","") 
     n = parseInt (text)

Note that the parseInt() statement tells the program to interpret text entered in box as a Integer.

    var text = prompt ("Enter decimal number for var x ","") 
    var x = parseFloat(text)  

Note the the parseFloat() statement tells the program to interpret text entered in box as a decimal (floating point) number.

Program below uses both the Math Object and inputs two variables. Copy program to Notepad and then run using Internet Explorer  as we did on previous page.

The following program raises a decimal varible x  to the to the powe of Integer N.

y1  = x^N

<HTML>
<head>
<TITLE>Simple Script 2</TITLE>
</head>
<Body>
<SCRIPT LANGUAGE = JavaScript>
alert("The MATH OBJECT script has started.")
var text = prompt ("Enter Integer for var N ","") 
var n = parseInt(text)
var text = prompt ("Enter decimal number for var x ","") 
var x = parseFloat(text)

y1 = Math.pow(x, n)
alert("y1 = " + y1)

</SCRIPT>
</Body>
</HTML>
    

Simple Script 2
Web Hosting by Networks