Calculators and Converters

Page 1 of 2 1, 2  Next

View previous topic View next topic Go down

Calculators and Converters

Post by Nevyn on Tue May 09, 2017 8:33 pm

I have created a calculator for angular velocity. There are 3 calculators on the page where each one takes two parameters and calculates the third.

http://www.nevyns-lab.com/mathis/math/calculator.php?type=angular_velocity

The best part is that it is all driven from a database. This allows me to easily create new calculators and they will all share a common style.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Tue May 09, 2017 8:52 pm

I have added a list of calculators page:

http://www.nevyns-lab.com/mathis/math/calculators.php
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by LongtimeAirman on Tue May 09, 2017 10:07 pm

.
Angular Velocity Calculator
These calculators can be used to convert between radius, tangential velocity and angular velocity

Good, why it seems like only yesterday I said your science site needed an Angular Velocity converter.

One can build a calculator in no time, given the right code and front-end. Did you use Java? Do I have permission to look? And if so, Where exactly would I look?  It is a bit spartan. I would want a diagram or illustration or two. A library would take a great deal more time.

My only complaint - I don't know if it's intentional or not - this effort only involves calculations to solve for: 1) Radius; 2) 300000000; and 3) Angular velocity (referred to as omega). In all 3 cases, the tangential velocity is 300 000 000. There is no angle velocity involved. Easily made easily fixed.
.

LongtimeAirman
Admin

Posts : 617
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Tue May 09, 2017 11:28 pm

Yes, you did spark me into it. I had forgotten our previous discussion about converters and decided to see what I could do last night. As I thought about it, I realised that I might be able to use the database and make life easier in the future. It worked out pretty well.

No Java, just Javascript. I already had those equations written in Javascript, I also have them in Java but I have not used Java for my site at all. At least, not in running the site. I have used Java to generate content but no Java at runtime. You can look at it by using the developer tools in your browser. The code might be a bit messy because generated code usually is. I do try to make it format correctly but you can't always get it right and sometimes I just get lazy.

I already have thoughts on how to incorporate a graph. The user can specify the min, max and step values and the graph will run values though the equation and visualize it. That should work really well. I'm not sure if I want to put it onto the same page as the calculator or create a whole new page for it.

Another reason I used a database was because I had some tentative thoughts on generating a library from the database. Once I get a few more equations in there I can start to play with that and see where it goes. I did add some columns to my database tables to specify the programming language which allows many different languages to use the same database to generate the code for the equations. I have only put Javascript versions in there so far, but it can be done.

I am currently working on the angle velocity calculator. I made them separate because combining them is a bit of a problem when using a common script to generate every page. It can be done, but it takes more work and I just want to get the basics working first. At this stage, all I need to do to get another page up and running is to break the equation down so that it fits in my database structure. Once it is in the database, the site will find it and generate the page.

The angular velocity calculator is more generic than just thinking about stacked spins and photons, etc. It can be used for any radius and velocity combination. I could create a spin velocity version that sets the velocity to c and the user specifies the spin level number which I use to find the radius of the spin level and it will calculate the angular velocity. That's not a bad idea at all.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Wed May 10, 2017 1:05 am

The angle velocity calculator is now available at http://www.nevyns-lab.com/mathis/math/calculator.php?type=angle_velocity

A new spin level calculator is available at http://www.nevyns-lab.com/mathis/math/calculator.php?type=spin_level_velocity

You can find the list of all calculators at http://www.nevyns-lab.com/mathis/math/calculators.php

I have implemented limits on the argument values so that I can stop the radius from going below 0 and I limit the spin levels between 0 and 130. It can also use a step value which will set how much is added to the value if you use the spinner controls (up/down buttons).
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Wed May 10, 2017 7:58 am

I have created a new Graphing Calculator section that takes the same equations as the normal calculators and creates a graph per variable in the equation. This allows you to choose which variable you want to vary. I think it works well.

Each calculator has a link to the corresponding graph and each graph links back to its calculator.

You can reach all graphing calculators from http://www.nevyns-lab.com/mathis/math/graphs.php
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Thu May 11, 2017 8:32 am

Lots of little changes for the Calculators and Graphs.

Updated header that provides links to the parent lists.
General spacing between areas has been improved (i.e. actually looked at).
A reset button has been provided that will change the controls back to their original values.
The graphs now generate data when the page is loaded so they are all showing data from the start.
I have added a way to specify a format for the X and Y labels on a graph. This has been used on the Spin Level Velocity graphs.

The most notable change is the introduction of a code generation system. Each calculator now has a button that will generate the code for that equation. There is also a button at the top of each page that will generate all of the equations in a library. It currently supports Javascript and will need to be changed to support multiple languages, but that is the long term goal. If you want to convert some of these functions to R then I can figure out how to fit that into the system.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Fri May 12, 2017 8:37 am

I started this evening with a half baked code generation system and a full bottle of Makers Mark. You may not realise it, but evidence suggests that these two things are inversely proportional. As the bottle empties, the code gets better! I know, it goes against all expectations but you just can't argue with the results.

The code generated from my equation database is now beautiful, well structured, documented code that includes functions to generate data for graphs. There are multiple ways to get the code. Each calculator or graph contains a button to access the code specific to that calculator. Each page provides a button to get the code for all equations in that page. The list pages also provide a button to access the code for all equations in one complete library.

The next step is to make the calculators use the code generated from the database. They are currently generating their own versions but now I can just import them in. When this is done it will create a self testing system since the generated code will actually be used by the calculators.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Reviewing Angular and Angle graphs

Post by LongtimeAirman on Sat May 13, 2017 12:41 am

.
http://www.nevyns-lab.com/mathis/math/graphs.php
Reviewing Angular and Angle Velocity graphs, just the defaults. I made my own plots to try and duplicate yours, indicating where we don't agree. Please double check where we are different.

1. Graph of omega vs radius
ω = √[2r√[v2+r2]-2r2]
Angular Velocity with changing radius
COMMENT. Agreed

2. Graph of omega vs velocity
ω = √[2r√[v2+r2]-2r2]
Angular Velocity with changing velocity
COMMENT. Agreed

3. Graph of velocity vs radius
v = √[(ω4/4r2)+ω2]
Velocity with changing radius  
COMMENT. Unable to recreate your numbers. My list starts at 1.118 then diverges from yours.
1.118, 1.414, 1.803, 2.236, 2.693, 3.162, 3.640, 4.123, 4.610, 5.099.
My formula: = SQRT((R31*R31*R31*R31/4*D31*D31)+R31*R31)
Where R31= 1 (constant 1), and D31= 1 (incremental radius – start  at 1)

4. Graph of velocity vs omega
v = √[(ω4/4r2)+ω2]
Velocity with changing omega
COMMENT. Agreed

5. Graph of radius vs velocity
r = √[ω4/(4v2-4ω2)]
Radius with changing velocity
COMMENT. Agreed. The first two numbers are illegal. Sqrt of a neg #? #NUM! then a #DIV/0!

6. Graph of radius vs omega
r = √[ω4/(4v2-4ω2)]
Radius with changing omega
COMMENT. Agreed. Poor graph. The first number is zero, then a #DIV/0!, then the rest of the numbers are  all #NUM!

7. Graph of angle vs radius
θ = πg√[2r√[v2+r2]-2r2]/πkr
Angle Velocity with changing radius
COMMENT. Only ou first number agrees: -, 0.7148535, 1.5264002, 2.3249634, 3.1176964, 3.9076916, 4.6962222, 5.4838859, 6.2709966, 7.0577337.
My formula: =  PI()*SQRT(2*D31*SQRT(F31*F31+D31*D31)-2*D31*D31)/4*D31
Where D31= 0(rad incremental – start  at 0), and F31= 1  (constant vel = 1 ).

8. Graph of angle vs velocity
θ = πg√[2r√[v2+r2]-2r2]/πkr
Angle Velocity with changing velocity
COMMENT. Agreed.

9. Graph of velocity vs radius
v = θπkr√[θ2πk2+4πg2]/2πg2
Velocity with changing radius
COMMENT.  Unable to recreate your numbers. -, 147, 294, 441, 588, 735, 882, 1,029, 1,176, 1,323  
My formula: =  J31*4*D31*SQRT(J31*J31*4*4+4*PI()*PI())/2*PI()*PI()
Where D31= 0(radius incremental – start  at 0), and J31= 1  (constant angle = 1 ).

10. Graph of velocity vs angle
v = θπkr√[θ2πk2+4πg2]/2πg2
Velocity with changing angle
COMMENT.  Unable to recreate your numbers. -, 147.03, 401.59, 802.13, 1,357.23, 2,069.04, 2,938.24, 3,965.10, 5,149.73, 6,492.18,
My formula: =  K31*4*C31*SQRT(K31*K31*4*4+4*PI()*PI())/2*PI()*PI()
Where K31= 0 (angle incremental – start  at 0), and C31= 1 (constant, radius = 1 ).

11. Graph of radius vs velocity
r = 2πgv/√[θ4πk4+4θ2πk2πg2]
Radius with changing velocity
COMMENT.  Unable to recreate your numbers. -, 0.2108909, 0.4217818, 0.6326727, 0.8435636, 1.2653454, 1.4762363, 1.6871272, 1.8980181,
My formula: =  2*PI()*G31/SQRT(J31*J31*J31*J31*4*4*4*4 + 4*J31*J31*4*4*PI()*PI())
Where G31= 0 (vel incremental – start  at 0), and J31= 1 (constant, angle = 1 ).

12. Graph of radius vs angle
r = 2πgv/√[θ4πk4+4θ2πk2πg2]
Radius with changing angle
COMMENT. Unable to recreate your numbers. #DIV/0!, 0.2108909, 0.0772085, 0.0386550, 0.0228453, 0.0149858, 0.0105527, 0.0078198, 0.0060210, 0.0047759, …
My formula: =  2*PI()*F31/SQRT(K31*K31*K31*K31*4*4*4*4 + 4*K31*K31*4*4*PI()*PI())
Where K31= 0 (angle incremental – start  at 0), and F31= 1 (constant, vel = 1 ).
.

LongtimeAirman
Admin

Posts : 617
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Sat May 13, 2017 5:52 am

I have added another language so all equations can be generated in Javascript or Java code. These are created such that the code, when used, looks and acts the same way, as much as that is possible. For example, suppose we were using the angular velocity equation to calculate omega:

Javascript:
Code:
var omega = Equations.AngularVelocity.calcOmega( radius, velocity );

Java:
Code:
double omega = Equations.AngularVelocity.calcOmega( radius, velocity );

It is the exact same code, bar the variable assignment, so you could copy from one language straight into another. This makes porting to a different language much easier. It is not always possible to keep them the same though, so some functions do differ. All of the basic ones match and it is the graphing functions that are different.

I added a licence to the code which just retains copyright, absolves me of any liability and lets anyone use it for what-ever purpose they want. Now I can't get sued when someone loses a space ship or blows up a power station. I should sleep a little easier tonight.

In order to support multiple languages I had to come up with some way to let the user choose which language they wanted to download. I came up with a dropdown button that I think works quite well.

Airman, I've made a start on some of those issues. Mainly around getting the right initial values. I have a much more flexible system to manage that now and I just need to get them all right. There could be problems in my math when the number are integers. It could restrict it to integer math so I will make some changes to ensure that it uses floating point math. I suspect that is why some of our values are different but I'll have a closer look shortly.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Sun May 14, 2017 8:32 pm

I probably should mention that the generated code has not been tested. The actual code for the equations has been used in the calculators but the download code has not been checked beyond visually. I have been more focused on the generation than the generated, but I will test it soon.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Mon May 15, 2017 6:28 pm

I didn't have much time to spend on this last night, but I had a quick look at the Java code and found a few errors. Surprisingly, there were errors in the actual equation code, which is currently in use in all of the calculators and graphs. Javascript is a lot more lenient than Java. Java will not allow any errors in syntax but Javascript will allow minor ones so it worked fine in the browser but not in Java code. It all came down to a missing ';' on the last statement in a few of the functions. Since it was the last statement, it did not create an ambiguous situation for the code parser and it worked fine.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Tue May 16, 2017 7:42 pm

Made a few changes last night. I got the coding errors ironed out. The Java code compiles now and there were also a couple of bugs in the Javascript code. I think the Javascript code is good, but the validators I found on the net kept complaining about stuff that didn't matter. Like using spaces instead of tabs or having a space after a '*', even though it is part of a comment and not code. There seems to be some push to get everyone coding in the same style. Code style is important, but it is a personal thing, or at best, a team thing when you are working in a project with other developers.

I added four more equations to the system. I added a calculator for acceleration, even though it will be exactly the same as velocity, just with different variable names. These easy equations barely require a calculator but they are there for completeness. I also added momentum, force and work equations. The work equation is interesting as it has four variables and one of them is an angle which created a bit of a mess in the graphs until I worked out the right values to set them to. They go from -2PI to 2Pi but they only really need to go from -PI to PI. The first graph works better with 2PI so I left it at that. The other graphs where you can vary the angle are a bit weird.

Having eight equations created the need for some sort of grouping, so I added a higher level to group equations into subjects. I then had to update the code generators to support subjects, but that was pretty easy. While doing that I did find a few more errors in the code which only showed up in certain situations. Most variables are floating point values and everything worked fine if they all were, but the Spin Level calculators have one variable that is an integer and this caused some issues because I was using the wrong data type for the return value of the graphing functions. That was only a problem in the Java code because Javascript doesn't have data types, at least, not that the developer specifies.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Wed May 17, 2017 7:26 pm

LongtimeAirman wrote:
http://www.nevyns-lab.com/mathis/math/graphs.php
Reviewing Angular and Angle Velocity graphs, just the defaults. I made my own plots to try and duplicate yours, indicating where we don't agree. Please double check where we are different.

3. Graph of velocity vs radius
v = √[(ω4/4r2)+ω2]
Velocity with changing radius  
COMMENT. Unable to recreate your numbers. My list starts at 1.118 then diverges from yours.
1.118, 1.414, 1.803, 2.236, 2.693, 3.162, 3.640, 4.123, 4.610, 5.099.
My formula: = SQRT((R31*R31*R31*R31/4*D31*D31)+R31*R31)
Where R31= 1 (constant 1), and D31= 1 (incremental radius – start  at 1)

Your equation is not quite correct. Excel seems to have a strict operator precedence system so you need to use parentheses more than you would think. Change your formula to:

Corrected formula: = SQRT((R31*R31*R31*R31/(4*D31*D31))+R31*R31)

I have put brackets around 4*D31*D31 so that it is calculated before the division. Otherwise it will perform R31*R31*R31*R31/4 first, and then multiply that by D31*D31 which is not what the equation means.

LongtimeAirman wrote:
5. Graph of radius vs velocity
r = √[ω4/(4v2-4ω2)]
Radius with changing velocity
COMMENT. Agreed. The first two numbers are illegal. Sqrt of a neg #? #NUM! then a #DIV/0!

6. Graph of radius vs omega
r = √[ω4/(4v2-4ω2)]
Radius with changing omega
COMMENT. Agreed. Poor graph. The first number is zero, then a #DIV/0!, then the rest of the numbers are  all #NUM!

Fixed the initial values.

LongtimeAirman wrote:
7. Graph of angle vs radius
θ = πg√[2r√[v2+r2]-2r2]/πkr
Angle Velocity with changing radius
COMMENT. Only ou first number agrees: -, 0.7148535, 1.5264002, 2.3249634, 3.1176964, 3.9076916, 4.6962222, 5.4838859, 6.2709966, 7.0577337.
My formula: =  PI()*SQRT(2*D31*SQRT(F31*F31+D31*D31)-2*D31*D31)/4*D31
Where D31= 0(rad incremental – start  at 0), and F31= 1  (constant vel = 1 ).

Same thing here, put parentheses around 4*D31.

Corrected formula: =  PI()*SQRT(2*D31*SQRT(F31*F31+D31*D31)-2*D31*D31)/(4*D31)

LongtimeAirman wrote:
9. Graph of velocity vs radius
v = θπkr√[θ2πk2+4πg2]/2πg2
Velocity with changing radius
COMMENT.  Unable to recreate your numbers. -, 147, 294, 441, 588, 735, 882, 1,029, 1,176, 1,323  
My formula: =  J31*4*D31*SQRT(J31*J31*4*4+4*PI()*PI())/2*PI()*PI()
Where D31= 0(radius incremental – start  at 0), and J31= 1  (constant angle = 1 ).

10. Graph of velocity vs angle
v = θπkr√[θ2πk2+4πg2]/2πg2
Velocity with changing angle
COMMENT.  Unable to recreate your numbers. -, 147.03, 401.59, 802.13, 1,357.23, 2,069.04, 2,938.24, 3,965.10, 5,149.73, 6,492.18,
My formula: =  K31*4*C31*SQRT(K31*K31*4*4+4*PI()*PI())/2*PI()*PI()
Where K31= 0 (angle incremental – start  at 0), and C31= 1 (constant, radius = 1 ).

Put parentheses around 2*PI()*PI().

Corrected formula: =  K31*4*C31*SQRT(K31*K31*4*4+4*PI()*PI())/(2*PI()*PI())

LongtimeAirman wrote:
11. Graph of radius vs velocity
r = 2πgv/√[θ4πk4+4θ2πk2πg2]
Radius with changing velocity
COMMENT.  Unable to recreate your numbers. -, 0.2108909, 0.4217818, 0.6326727, 0.8435636, 1.2653454, 1.4762363, 1.6871272, 1.8980181,
My formula: =  2*PI()*G31/SQRT(J31*J31*J31*J31*4*4*4*4 + 4*J31*J31*4*4*PI()*PI())
Where G31= 0 (vel incremental – start  at 0), and J31= 1 (constant, angle = 1 ).

12. Graph of radius vs angle
r = 2πgv/√[θ4πk4+4θ2πk2πg2]
Radius with changing angle
COMMENT. Unable to recreate your numbers. #DIV/0!, 0.2108909, 0.0772085, 0.0386550, 0.0228453, 0.0149858, 0.0105527, 0.0078198, 0.0060210, 0.0047759, …
My formula: =  2*PI()*F31/SQRT(K31*K31*K31*K31*4*4*4*4 + 4*K31*K31*4*4*PI()*PI())
Where K31= 0 (angle incremental – start  at 0), and F31= 1 (constant, vel = 1 ).

I either have a bug in the code for the equation or the displayed equation is wrong. The code is using 2*PI^2*v but the equation shown is 2*PI*v. I'll have to figure out which one is right.

Also, you can use the '^' operator to raise some value to a power. For example, to raise 2 to the power of 3 you can use the excel equation: 2^3. This works for cells as well as literals.

Not sure if this is a problem for you, but you may need to make use of absolute cell references by using the '$' operator. Whatever the $ is in front of will remain that value when you drag an equation over multiple cells. You can keep the row and/or column absolute so it might be $A1 to keep the A but increment the 1, or $A$1 to keep it referenced to A1, or it could be A$1 to keep the 1 but change the A.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Wed May 17, 2017 8:07 pm

I think a few of my equation rearrangements are wrong. I found a site to do the rearranging for me as some of these equations are beyond my math skills to rearrange. I just put one of them through it again and got a different answer. So I must have put in the wrong equation the first time. I will go over them again and make sure they are correct.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

R code to calculate and plot Angular(w) and Angle(a) Velocity Functions

Post by LongtimeAirman on Wed May 17, 2017 9:44 pm

.
Nevyn, I updated my excel file with your corrections and obtained your numbers. Thanks. Two graphs: 11. radius vs velocity (changing velocity) and 12. radius vs angle(a) (changing angle) are as yet unconfirmed.

Here is a draft R code that plots all your Angular and Angle graphs. Ensure the variables are properly identified in the active code below. After running the top code, one would then run just the appropriate function to obtain a calculated variable list and basic plot.  

Code:

###########################################
#                              
#   Angular(w) and Angle(a) Velocity Functions
#           in  R code
#
###########################################
#
# In order to use this R code,
# One would need to enter known values in  
# the un-commented code section below. Run
# the corresponding function to obtain the
# desired plot with calculated values.
#
###########################################
# Angular(w) and Angle(a) Functions Defined
###########################################
# w=sqrt(2rsqrt(v^2+r^2)-2r^2)
###########################################
# 1. Function wvsradius. omega(w) vs. radius(r).
# Given: Constant velocity and changing radius.
# Calculate w.
# Define function. Plot(r1,w1). List w1.
#
wvsradius <- function(){
  w1 <- 0:10
  r1 <- 1:10
  v1 <- c(10,10,10,10,10,10,10,10,10,10)
  for(i in r1){
    w1<- sqrt(2*r1*sqrt((v1*v1)+(r1*r1))-2*r1*r1)
  }
  plot(r1,w1,main = "omega(w) vs. radius(r)\nw = sqrt(2rsqrt(v^2+r^2)-2r^2)")
  w1
}
###########################################
# 2. Function wvsvelocity. omega(w) vs. velocity(v).
# Given: Constant radius and changing velocity.
# Calculate w.
# Define wvsvelocity. plot(v2,w2). List w2.
wvsvelocity <- function(){
w2 <- 0:10
r2 <- c(1,1,1,1,1,1,1,1,1,1)
v2 <- 1:10
for(i in v2){
  w2<- sqrt(2*r2*sqrt((v2*v2)+(r2*r2))-2*r2*r2)
}
plot(v2,w2,main = "omega(w) vs. velocity(v)\nw = sqrt(2rsqrt(v^2+r^2)-2r^2)")
w2
}
###########################################
# v = sqrt[(w^4/4r^2)+w^2]
###########################################
# 3. Function vvsradiusw. velocity(v) vs. radius(r).
# Given: Constant omega(w) and changing radius.
# Calculate v.
# Define vvsradiusw. Plot(r3,v3). List v3.
vvsradiusw <- function(){
w3 <- c(10,10,10,10,10,10,10,10,10,10)
r3 <- 1:10
v3 <- 1:10
for(i in r3){
  v3 <- sqrt((w3*w3*w3*w3/(4*r3*r3))+w3*w3)
}
plot(r3,v3,main = "velocity(v) vs. radius(r)\nv = sqrt[(w^4/4r^2)+w^2]")
v3
}
###########################################
# 4. Function vvsomega. velocity(v) vs. omega(w).
# Given: Constant radius(r) and changing omega.
# Calculate v.
# Define vvsomega. Plot(w4,v4). List v4.
# Define function vvsomega. plot(w4,v4). List v4.
vvsomega <- function(){
w4 <- 1:10
r4 <- c(1,1,1,1,1,1,1,1,1,1)
v4 <- c(1,1,1,1,1,1,1,1,1,1)
for(i in w4){
  v4<- sqrt((w4*w4*w4*w4/(4*r4*r4))+w4*w4)
}
plot(w4,v4,main = "velocity(v) vs. omega(w)\nv = sqrt[(w^4/4r^2)+w^2]")
v4
}
###########################################
# r = sqrt[w^4/(4v^2-4w^2)]
###########################################
# 5. Function rvsvelocityw. radius(r) vs. velocity(v).
# Given: Constant omega(w) and changing velocity.
# Calculate r.
# Define function rvsvelocityw. plot(v5,r5). List r5.
rvsvelocityw <- function(){
w5 <- c(1,1,1,1,1,1,1,1,1,1,1)
r5 <- c(1,1,1,1,1,1,1,1,1,1,1)
v5 <- seq(from=100,to=200,by=10)
for(i in v5){
  r5 <- sqrt(w5*w5*w5*w5/(4*v5*v5-4*w5*w5))
}
plot(v5,r5,main = "radius(r) vs. velocity(v)\nr = sqrt[w^4/(4v^2-4w^2)]")
r5
}
###########################################
# 6. Function rvsomega. radius(r) vs. omega(w).
# Given: Constant velocity(v) and changing omega.
# Calculate r.
# Define function rvsomega. plot(w6,r6). List r6.
rvsomega <- function(){
w6 <- 1:10
r6 <- c(1,1,1,1,1,1,1,1,1,1,1)
v6 <- c(100,100,100,100,100,100,100,100,100,100)
for(i in w6){
  r6 <- sqrt(w6*w6*w6*w6/(4*v6*v6-4*w6*w6))
}
plot(w6,r6,main = "radius(r) vs. omega(w)\nr = sqrt[w^4/(4v^2-4w^2)]")
r6
}
###########################################
# Angular Velocity Functions and Plots
###########################################
# a = 3.14sqrt[2rsqrt[v^2+r^2]-2r^2]/4r
###########################################
# 7. Function avsradius. angle(a) vs. radius(r).
# Given: Constant velocity(v) and changing radius.
# Calculate a.
# Define function avsradius. plot(r7,a7). List a7.
avsradius <- function(){
a7 <- c(1,1,1,1,1,1,1,1,1,1)
r7 <- 1:10
v7 <- c(1,1,1,1,1,1,1,1,1,1)
for(i in r7){
  a7<- pi*sqrt(2*r7*sqrt(v7*v7+r7*r7)-2*r7*r7)/(4*r7)
}
plot(r7,a7,main = "angle(a) vs. radius(r)\na = 3.14sqrt[2rsqrt[v^2+r^2]-2r^2]/4r")
a7
}
###########################################
# 8. Function avsvelocity. angle(a) vs. velocity(v).
# Given: Constant radius(r) and changing Velocity.
# Calculate a.
# Define function avsvelocity. plot(v8,a8). List a8.
avsvelocity <- function(){
a8 <- c(1,1,1,1,1,1,1,1,1,1,1)
r8 <- c(1,1,1,1,1,1,1,1,1,1,1)
v8 <- 0:10
for(i in v8){
  a8<- pi*sqrt(2*r8*sqrt(v8*v8+r8*r8)-2*r8*r8)/4*r8
}
plot(v8,a8,main = "angle(a) vs. velocity(v)\na = 3.14sqrt[2rsqrt[v^2+r^2]-2r^2]/4r")
a8
}
###########################################
# v = 4arsqrt[(a^2)(4^2)+4pi^2]/2pi^2
###########################################
# 9. Function vvsradiusa. velocity(v) vs. radius(r).
# Given: Constant angle(a) and changing radius.
# Calculate v.
# Define function vvsradiusa. plot(r9,v9). List v9.
vvsradiusa <- function(){
a9 <- c(1,1,1,1,1,1,1,1,1,1,1)
r9 <- 0:10
v9 <- c(1,1,1,1,1,1,1,1,1,1,1)
for(i in r9){
  v9 <- a9*4*r9*sqrt(a9*a9*4*4+4*pi*pi)/(2*pi*pi)
}
plot(r9,v9,main = "velocity(v) vs. radius(r)\nv = 4arsqrt[(a^2)(4^2)+4pi^2]/2pi^2")
v9
}
###########################################
# 10. Function vvsangle. velocity(v) vs. angle(a).
# Given: Constant radius(r) and changing angle.
# Calculate v.
# Define function vvsangle. plot(a10,v10). List v10
vvsangle <- function(){
a10 <- 0:10
r10 <- c(1,1,1,1,1,1,1,1,1,1,1)
v10 <- c(1,1,1,1,1,1,1,1,1,1,1)
for(i in a10){
  v10 <- a10*4*r10*sqrt(a10*a10*4*4+4*pi*pi)/(2*pi*pi)
}
plot(a10,v10,main = "velocity(v) vs. angle(a)\nv = 4arsqrt[(a^2)(4^2)+4pi^2]/2pi^2")
v10
}
###########################################
# r = 2vpi/sqrt[(a^4)(4^4)+4(a^2)(4^2)(pi^2)]
###########################################
# 11. Function rvsvelocitya. radius(r) vs. velocity(v)
# Given: Constant angle(a) and changing velocity.
# Calculate r.
# Define function rvsvelocitya. plot(v11,r11). List r11.
rvsvelocitya <- function(){
a11 <- c(1,1,1,1,1,1,1,1,1,1,1)
r11 <- c(1,1,1,1,1,1,1,1,1,1,1)
v11 <- 0:10
for(i in v11){
  r11 <- 2*pi*v11/sqrt(a11*a11*a11*a11*4*4*4*4
                         +4*a11*a11*4*4*pi*pi)
}
plot(v11,r11,main = "radius(r) vs. velocity(v)\nr = 2vpi/sqrt[(a^4)(4^4)+4(a^2)(4^2)(pi^2)]")
r11
}
###########################################
# 12. Function rvsangle. radius(r) vs. angle(a).
# Given: Constant velocity(v) and changing angle.
# Calculate: r.
# Define function rvsangle. plot(a12,r12). List r12.
rvsangle <- function(){
a12 <- 1:10
r12 <- c(1,1,1,1,1,1,1,1,1,1)
v12 <- c(1,1,1,1,1,1,1,1,1,1)
for(i in a12){
  r12 <- 2*pi*v12/sqrt(a12*a12*a12*a12*4*4*4*4
                       +4*a12*a12*4*4*pi*pi)
}
plot(a12,r12,main = "radius(r) vs. angle(a)\nr = 2vpi/sqrt[(a^4)(4^4)+4(a^2)(4^2)(pi^2)]")
r12
}
###########################################
#
# Function List
#

wvsradius()
wvsvelocity()
vvsradiusw()
vvsomega()
rvsvelocityw()
rvsomega()

avsradius()
avsvelocity()
vvsradiusa()
vvsangle()
rvsvelocitya()
rvsangle()


Anyone, please feel free to comment. I'm not sure how this code will eventually be included in an MM R Library, but that's the intent.
.


Last edited by LongtimeAirman on Wed May 31, 2017 6:03 pm; edited 1 time in total (Reason for editing : Made several corrections to the initial draft code)

LongtimeAirman
Admin

Posts : 617
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Wed May 17, 2017 11:02 pm

Thanks for that R code Airman. I'll see if I can figure out how to generate it so that I can apply it to all equations.

I did a quick search on R libraries and it turns out they are called packages, not libraries. In R, a library is where R finds packages on your file system. There is a lot of content needed in a package, so I don't think it is feasible to generate one. I will probably just generate the functions and let people do what they want with them. Much like you have supplied, Airman.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Thu May 18, 2017 1:53 am

I just checked the angle velocity equations to see if the rearrangements were wrong or right. The angle velocity equations are correct, but the radius version is displayed incorrectly. It should have a PIg2 on the front but it is showing as just PIg.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Cr6 on Sun May 21, 2017 9:13 pm

Cool LTAM.

This is what is coming up for me:




Cr6
Admin

Posts : 689
Join date : 2014-08-09

View user profile http://milesmathis.the-talk.net

Back to top Go down

Re: Calculators and Converters

Post by LongtimeAirman on Sun May 21, 2017 9:27 pm

.
Hi Cr6, I guess if you "run" the entire code, the final function performed would be rvsangle(), giving you the plot shown.

Of course you can run each function separately, individually, to obtain the plot you desire,
given the variables you know and the variable you are trying to calculate.
.

LongtimeAirman
Admin

Posts : 617
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Calculators and Converters

Post by Cr6 on Sun May 21, 2017 9:31 pm

Got it. I just hit the back button and saw them flip through.

Cr6
Admin

Posts : 689
Join date : 2014-08-09

View user profile http://milesmathis.the-talk.net

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Tue May 23, 2017 10:44 pm

Want to see an horrendous equation?

I have been adding a few more equations to my calculators and also some changes to the layout and a pretty big redesign of the back end database to make adding new equations a lot easier. I have added the concept of a constant now too, as the equations I will be adding use a lot of them.

The latest equation I have looked at is based on Miles' paper The Moon Gives Up a Secret and is used to calculate gravity given the density and radius. It sounds so simple, doesn't it?

This equation starts out complex, but not too bad: v = G*r/R + (E*d^2*r^3)/(D^2*R^3)

Where the upper case variables are Earth based constants for solo Gravity, Radius, E/M field and Density.

I then had to rearrange that in terms of the density and got this equation: d = sqrt(-D^2*R^2*(G*r-R*v)) / (r^(3/2) * sqrt(E))

Getting bad, but still workable. Then I had to rearrange in terms of the radius and everything went to hell. It was so bad that I had to break it down into 2 parts. It took me some time to realise that part of it is repeated as it is so easy to get lost in all of these numbers, variables and operators.

N = cubert( 9*E^2*d^4*D^2*R^3*v + sqrt(3)*E^(3/2)*sqrt( 27*E*d^8*D^4*R^6*v^2 + 4*d^6*D^6*G^3*R^6 ) )
r = N/(cubert(2)*3^(2/3)*E*d^2) - cubert(2/3)*D^2*G*R^2/N

Here it is in is full glory:

cubert( 9*E^2*d^4*D^2*R^3*v + sqrt(3)*E^(3/2)*sqrt( 27*E*d^8*D^4*R^6*v^2 + 4*d^6*D^6*G^3*R^6 ) )/(cubert(2)*3^(2/3)*E*d^2) - cubert(2/3)*D^2*G*R^2/cubert( 9*E^2*d^4*D^2*R^3*v + sqrt(3)*E^(3/2)*sqrt( 27*E*d^8*D^4*R^6*v^2 + 4*d^6*D^6*G^3*R^6 ) )

Where cubert is the cube root.

In nice formatting:

N = ∛[ 9Ee2d4Ed2Er3F + √[3]Ee3/2√[27Eed8Ed4Er6v2 + 4d6Ed6Eg3Er6] ]
r = N/(∛[2]32/3Eed2) - ∛[2/3]Ed2EgEr2/N

r = ∛[ 9Ee2d4Ed2Er3F + √[3]Ee3/2√[27Eed8Ed4Er6v2 + 4d6Ed6Eg3Er6] ]/(∛[2]32/3Eed2) - ∛[2/3]Ed2EgEr2/∛[ 9Ee2d4Ed2Er3F + √[3]Ee3/2√[27Eed8Ed4Er6v2 + 4d6Ed6Eg3Er6] ]
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Reviewing 150 Graphing Calculators and One Particularly Horrendous Equation

Post by LongtimeAirman on Wed May 24, 2017 11:18 pm

.
Nevyn, Golly, Something completely new, 150 graphing calculators; a playground for people who like to play with numbers. As usual, Great Job. I could have spent many happy hours here had I the opportunity years ago. Makes subject learning easier.

QUOTE. Want to see an horrendous equation?
COMMENT. Agreed, that is one Particularly Horrendous equation.

LOCATION. Nevyn's Lab - Graphing Calculators – Acceleration.
Graph of velocity vs acceleration and Graph of velocity vs time both show v = d/t.
COMMENT. Change "d = vt" to "v = at".

LOCATION. Nevyn's Lab - Graphing Calculators - Spin Level Velocity and other locations in the Angular Motion section.
QUOTE. The definition of Angular Velocity used by these calculators is that of Miles Mathis. Please read that paper to understand the difference.
COMMENT. Please consider changing (the first hyperlink is changed and another hyperlink is added) these two sentences to: The definition of Angular Velocity used by these calculators can be found in Angular Velocity and Angular Momentum by Miles Mathis. That paper corrects the historical misuse of these terms.

OBSERVATION. On all calculator pages, just below the title. A brief description is included. The longest and best description (in my opinion), including a hyperlink, is given for the Spin Level Velocity Graphs. Under Momentum Graphs, we have – “These calculators can be used to generate data using mass, velocity and momentum”. The description for Expanded Gravity Graphs is – “These calculators can be used to generate data using density, volume, radius and force” even though this section contains 30 individual graph/calculators – many I haven’t figured out or properly reviewed. The same is also true for - Charge Expanded Graphs – 30 calculators with little description.
COMMENT. Please consider adding additional comments, pertinent links, or additional information to all your descriptions. Maybe include a diagram or two.

OBSERVATION. All calculators. At the top of each calculator: Left side – calculate a given b; Center – the variable calculation; Right side – the variables used.
COMMENT. Add units to the lists of variables used. For example, change “d = distance” to “d = distance (m)”; or change from “θ = angle; the angle of incidence” to “θ = angle; the angle of incidence, +/-2pi radians”.

OBSERVATION. Graph of force vs angle F = W/dcos(θ) is surprising. Any comment?

OBSERVATION. Energy Graphs: Graph of energy vs mass and Graph of mass vs energy, vertical axii numeric decimals includes 15 or more zeros.
COMMENT. Please reformat in order to eliminate the zeros (if possible), such as you’ve formatted the mass and force vertical axii values in the Newtonian Gravity Graphs.

COMMENT. How far do your plans go? Do you want R code for all the calculators?
.

LongtimeAirman
Admin

Posts : 617
Join date : 2014-08-10

View user profile

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Thu May 25, 2017 1:10 am

LongtimeAirman wrote:
LOCATION. Nevyn's Lab - Graphing Calculators – Acceleration.
Graph of velocity vs acceleration and Graph of velocity vs time both show v = d/t.
COMMENT. Change "d = vt" to "v = at".

Ah, a copy/paste error. I try to catch them but miss the odd one or two.

LongtimeAirman wrote:
LOCATION. Nevyn's Lab - Graphing Calculators - Spin Level Velocity and other locations in the Angular Motion section.
QUOTE. The definition of Angular Velocity used by these calculators is that of Miles Mathis. Please read that paper to understand the difference.
COMMENT. Please consider changing (the first hyperlink is changed and another hyperlink is added) these two sentences to: The definition of Angular Velocity used by these calculators can be found in Angular Velocity and Angular Momentum by Miles Mathis. That paper corrects the historical misuse of these terms.

That's a much better description.

LongtimeAirman wrote:
OBSERVATION. On all calculator pages, just below the title. A brief description is included. The longest and best description (in my opinion), including a hyperlink, is given for the Spin Level Velocity Graphs. Under Momentum Graphs, we have – “These calculators can be used to generate data using mass, velocity and momentum”. The description for Expanded Gravity Graphs is – “These calculators can be used to generate data using density, volume, radius and force” even though this section contains 30 individual graph/calculators – many I haven’t figured out or properly reviewed. The same is also true for - Charge Expanded Graphs – 30 calculators with little description.
COMMENT. Please consider adding additional comments, pertinent links, or additional information to all your descriptions. Maybe include a diagram or two.

I know. I know. I, generally, go through two phases as I develop. I start out building things to make it all work as I want. Then I start to add content to it. This usually causes more building work as I realise that I need things to work a different way for a certain part. Then I add more content. Rinse and repeat. When I am in the adding content phase, I am not thinking too closely about things like descriptions. I do look at them, but only enough to change what is already there (where I copied it from another equation) so that it makes sense for the new equation. Sometimes I do identify equations that need more detail, but it is the wrong time to look into it because I am focused on other things. I haven't put much effort into the third phase which is polishing. Writing nice descriptions, formatting values, etc.

LongtimeAirman wrote:
OBSERVATION. All calculators. At the top of each calculator: Left side – calculate a given b; Center – the variable calculation; Right side – the variables used.
COMMENT. Add units to the lists of variables used. For example, change “d = distance” to “d = distance (m)”; or change from “θ = angle; the angle of incidence” to “θ = angle; the angle of incidence, +/-2pi radians”.

I have not included units except where it is impossible not to, such as constants. The reason is that equations express relationships, not units. You should be able to use an equation with whatever units you want, as long as they relate to how the variable is used in the equation. You can't replace a meter with a second, but you can replace a meter with a kilometer as long as any other variable that uses distance is also specified in km or km/s or whatever applies to that variable. The equations themselves should be unit-agnostic, or maybe I should say they are unit-scale-agnostic. If there is a constant in the equation, then the units do get set by that constant. I will see if I can handle that when applicable while leaving the equations without units when not. I could also specify the units in a scale-agnostic manner, such as a suggestion like: r = radius (m, km , etc). There isn't much space to add this though, so I will need to find what can be done with the little space available.

LongtimeAirman wrote:
OBSERVATION. Graph of force vs angle F = W/dcos(θ) is surprising. Any comment?

I want to add a description to that equation to help explain what that angle is. It really needs a picture to go with it but I haven't found a good one yet, and haven't put any time into making one myself.

The angle expresses the relationship between the force and the distance. When θ is 0, then there is no difference and the force points in the same direction as the distance (cos(0)=1). When θ = 90°, then the force is at 90° to the distance so if the distance was along the surface of the earth, then this force would be coming straight down (like gravity) (cos(90)=0). That produces no work because the force and distance are not in the same dimension and no component of either is in the same dimension. When θ is 180° then the force and distance are opposite each other so we get negative work. When θ is 270°, the force is pointing up (like the Earth's charge field) but the distance is still along the surface so we get no work (cos(270)=0).

So that graph is just telling us that as we change the angle of the applied force, the amount of work done creates a wave between full force, no force, opposite full force, no force.

I was pretty surprised when I saw it too, but after I looked at the equation and thought about what that angle was doing, I realised that it made perfect sense.

LongtimeAirman wrote:
OBSERVATION. Energy Graphs: Graph of energy vs mass and Graph of mass vs energy, vertical axii numeric decimals includes 15 or more zeros.
COMMENT. Please reformat in order to eliminate the zeros (if possible), such as you’ve formatted the mass and force vertical axii values in the Newtonian Gravity Graphs.

Yes, I need to set a lot of these formatters. It is easy to do but what I don't like is that the default values are usually just integers. So if I make them all into scientific notation, then they look horrible. However, if the user puts in their own values, then they are not likely to be integers anymore, so I think I just need to make everything into scientific notation.

I did try to write a smart formatter that would look at the specific value and choose how to format it. It didn't work out quite as well as I wanted but I should put some more effort into it.

LongtimeAirman wrote:
COMMENT. How far do your plans go? Do you want R code for all the calculators?
.

I'll add in any equation that I think deserves to be there. After I added in the Motion, Angular Motion and Force subjects, I thought I was done. My mind wasn't quite ready to let it go, though. So I kept working on the style of the page and the code generators, etc. Then something, I think it might have been Lloyd's recent list of Mathis concepts, reminded me about gravity, so I added in those equations and the expanded versions that Miles' has described. Then I remembered Miles' gravity work in the Moon Gives Up a Secret paper and I had provided some code relating to that on this forum a while ago. So I found the thread and looked over the code and am working on adding that in at the moment. I have added the complete equation that gives you the gravity, and its rearrangements, as well as parts of that equation to calculate the gravity from just a radius and density and also the charge field given the radius and density.

After that, I don't know. I have looked over a few of Miles' papers to try to find equations to add but haven't found many. This doesn't just apply to Miles' equations though, so I am open to any physics equations that are helpful. I was thinking about putting in some electrical equations but the most useful ones have an arbitrary number of sections which makes it difficult to deal with. For example, to work out the capacitance of many capacitors in series, you use the equation 1/C = 1/C1 + 1/C2 + ... + 1/Cn. I thought about just picking a number, say 3 or 5, but it didn't seem worth it. Maybe I need a different type of calculator to handle that type of equation.

No, I don't expect anyone to convert all of these equations into R. What I need is the surrounding code, not the equations themselves. Each equation has custom code to implement it, but the surrounding code is common to all equations. I can figure out the custom R code for each equation but I don't know enough about R to write the common code just yet. If you look at the generated Javascript code, ignoring some of the funky things I have done such as using closures, you'll find that each section contains the same structure and even some of the functions (specifically the graphing functions) are very much the same, they just call a different function to calculate the data. R seems to be a little different because the language is aimed at plotting graphs, so I actually think the common code will be easier in R than in Javascript or Java. I just haven't put any time into it, though. Your R code helped me to see what I needed so I just need to spend a bit of time working with R to get a feel for the syntax and how it wants me to setup the data.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Re: Calculators and Converters

Post by Nevyn on Thu May 25, 2017 1:51 am

It may not be obvious, but certain parts of these calculator pages disappear if you are on a small device. This is done to make the page work better when there isn't much resolution. Things like the code generator buttons and the variable lists will be hidden when the width is less than 768 pixels. The input fields also stack rather than being shown in columns. I've spent a fair bit of time making sure that the pages work at various resolutions.

I have also found that the calculators don't allow the user to enter a value on my phone, even though the graphing calculators do. I think this is related to the page structure but I only found it the other day and haven't tracked down the problem yet.
avatar
Nevyn
Admin

Posts : 821
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Page 1 of 2 1, 2  Next

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum