sin

sine之舞(递归)

只谈情不闲聊 提交于 2019-12-03 05:39:41
Description   最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数基本功。所以他准备和奶牛们做一个“Sine之舞”的游戏,寓教于乐,提高奶牛们的计算能力。 不妨设 An=sin(1–sin(2+sin(3–sin(4+...sin(n))...) Sn=(...(A1+n)A2+n-1)A3+...+2)An+1 FJ想让奶牛们计算Sn的值,请你帮助FJ打印出Sn的完整表达式,以方便奶牛们做题。 Input   仅有一个数:N<201。 Output   请输出相应的表达式Sn,以一个换行符结束。输出中不得含有多余的空格或换行、回车符。 Sample Input 3 Sample Output ((sin(1)+3)sin(1–sin(2))+2)sin(1–sin(2+sin(3)))+1 就一道简单递归,写两个递归函数AN,SN就行了 不过改了一晚上,被这个减号坑惨了,"-"和"—"都不是题中的这个符号"–" 无语。。。。。。。 以后遇到符号一律复制,绝不手打 1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <string> 5 #include <math.h> 6 #include <algorithm> 7 #include

c++ Sin and Cos

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am sure this is a really stupid question, but when I pass an angle of 180 degrees into c/c++'s cos() and sin() functions I appear to receive an incorrect value. I know that it should be: sin of 0.0547 and cos of 0.99 but I get sin of 3.5897934739308216e-009 and cos of -1.00000 My code is: double radians = DegreesToRadians( angle ); double cosValue = cos( radians ); double sinValue = sin( radians ); DegreesToRadians() is: double DegreesToRadians( double degrees ) { return degrees * PI / 180; } Thank you :) 回答1: C/C++ provides sin(a) , cos(a

Why would this Lua optimization hack improve performance?

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm looking over a document that describes various techniques to improve performance of Lua script code, and I'm shocked that such tricks would be required. (Although I'm quoting Lua, I've seen similar hacks in Javascript). Why would this optimization be required: For instance, the code for i = 1, 1000000 do local x = math.sin(i) end runs 30% slower than this one: local sin = math.sin for i = 1, 1000000 do local x = sin(i) end They're re-declaring sin function locally. Why would this be helpful? It's the job of the compiler to do that anyway

Calling multiple HTTP requests in a single HTTP request in Node.js

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to call multiple URL in a single URL call and push it's json response in an array and send that array in response to the end user. My code look like this: var express = require ( 'express' ); var main_router = express . Router (); var http = require ( 'http' ); urls = [ "http://localhost:3010/alm/build_tool" , "http://localhost:3010/alm/development_tool" , "http://localhost:3010/alm/project_architecture" ]; var responses = []; main_router . route ( '/' ) . get ( function ( req , res ) { var completed_requests = 0 ; for

Calculating distance between two points (Latitude, Longitude)

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to calculate the distance between two positions on a map. I have stored in my data: Longitude, Latitude, X POS, Y POS. I have been previously using the below snippet. DECLARE @orig_lat DECIMAL DECLARE @orig_lng DECIMAL SET @orig_lat=53.381538 set @orig_lng=-1.463526 SELECT *, 3956 * 2 * ASIN( SQRT( POWER(SIN((@orig_lat - abs(dest.Latitude)) * pi()/180 / 2), 2) + COS(@orig_lng * pi()/180 ) * COS(abs(dest.Latitude) * pi()/180) * POWER(SIN((@orig_lng - dest.Longitude) * pi()/180 / 2), 2) )) AS distance --INTO #includeDistances FROM

TFRecords: Write list of tensors to single Example

匿名 (未验证) 提交于 2019-12-03 02:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm extracting features from images using a convolutional neural network. The network in question has three outputs (three output tensors), which differ in size. I want to store the extracted features in TFRecords, one Example for each image: Example: image_id: 1 features/fc8: [output1.1, output1.2, output1.3] Example: image_id: 2 features/fc8: [output2.1, output2.2, output2.3] .... How can I achieve this structure using TFRecords? 回答1: EDIT: Elegant way is to use tf.SequenceExample. Convert the data using tf.SequenceExample() format def

How to find nearest location using latitude and longitude from sql database?

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to find a nearest location from following database table I have fetched this all data from google maps. Here i have to find nearest location from a place. Suppose i am at place Surkhet its latitude is 28.6 and longitude is 81.6, how can i find nearest place from the place Surkhet. 回答1: Finding locations nearby with MySQL Here's the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target

Image rotation by Matlab without using imrotate

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to rotate an image with Matlab without using imrotate function. I actually made it by using transformation matrix.But it is not good enough.The problem is, the rotated image is "sliding".Let me tell you with pictures. This is my image which I want to rotate: But when I rotate it ,for example 45 degrees, it becomes this: I am asking why this is happening.Here is my code,is there any mathematical or programming mistakes about it? image = torso ; % image padding [ Rows , Cols ] = size ( image ); Diagonal = sqrt ( Rows ^ 2

Fast Haversine Approximation (Python/Pandas)

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Each row in a Pandas dataframe contains lat/lng coordinates of 2 points. Using the Python code below, calculating the distances between these 2 points for many (millions) of rows takes a very long time! Considering that the 2 points are under 50 miles apart and accuracy is not very important, is it possible to make the calculation faster? from math import radians, cos, sin, asin, sqrt def haversine(lon1, lat1, lon2, lat2): """ Calculate the great circle distance between two points on the earth (specified in decimal degrees) """ # convert

Calculating distance between two points (Latitude, Longitude)

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to calculate the distance between two positions on a map. I have stored in my data: Longitude, Latitude, X POS, Y POS. I have been previously using the below snippet. DECLARE @orig_lat DECIMAL DECLARE @orig_lng DECIMAL SET @orig_lat=53.381538 set @orig_lng=-1.463526 SELECT *, 3956 * 2 * ASIN( SQRT( POWER(SIN((@orig_lat - abs(dest.Latitude)) * pi()/180 / 2), 2) + COS(@orig_lng * pi()/180 ) * COS(abs(dest.Latitude) * pi()/180) * POWER(SIN((@orig_lng - dest.Longitude) * pi()/180 / 2), 2) )) AS distance --INTO #includeDistances FROM