Code Definition and 908 Threads

  1. L

    Is it ethical to ask for somebody else's research code?

    Hi all, This is my first post here. I had a hard time determining the correct subforum to ask this question, as this is not a technical issue, and is closer to academic problem. Having read the subforum guidelines, this post doesn't seem to suit the subforum's purpose, but let alone other...
  2. T

    What is the mathematical approach to solving letter/digit code puzzles?

    Homework Statement I was flicking through the newspaper the other day and noticed there is a type of puzzle where words are added together to form a sum. Each letter represents one of the digits 0-9, for example: FUN +JOKE =HAHA and the aim of the puzzle is to find which...
  3. G

    U.S. Tax Code probability homework

    Hello All, I am new to these forums and hope someone may help me out. I am doing an assignment and am stuck on one of the questions. There is a sample of 1000 people of different age groups. 18-24, 25-34, 35-44, 45-54, 55-64, 65 or older People were asked if they thought the new tax...
  4. S

    C/C++ Is there an efficient way to find divisors of large numbers using C++?

    As I saw in wolfram website and in pari , if given divisors(x) , it will give all the divisors of x in a row. ex: divisors (34567) = { 1, 13, 2659, 34567 } So I we know some x = 2^5 * 5^15 * 21^5 * 119 , Here we even know the prime factors Then, Is there any program in c language (or) any...
  5. P

    MATLAB Access Variable in MATLAB Structure Using User Input

    Hi I am trying to use MATLAB for some data analysis. I start by getting user input for a variable called exptno, Then I want to access a location in a structure, but to do this I need to append the variable exptno to the name of the structure. Ill try and give an example to hopefully make it...
  6. X

    Some help with MIPS assembly code

    Hey guys. I'm trying to practice some basic MIPS, but I can't seem to get this right. You just plug in the number and then you follow the code and you'll get obviously the end result. I can't get the result for these here. Does anybody know? I'd really appreciate help. Thank you! 1. $t0 =...
  7. S

    Silvaco Software code or script

    Hi all, I am doing a project that needs me to design a PMOS transistor with a channel length of 65 nanometers using Silvaco TCAD tools. As you may know, there are examples provided in the software that I am using to customize in order to get the required channel length. So, I have to modify...
  8. J

    Can execution time of this C code be reduced?

    Hi. I've been working on a finite-difference problem in differential equations. I was wondering if this code can be further optimized, perhaps eliminate some if statements or assignment statements. That is, what is the most efficient way to code this or is it already written in the most...
  9. D

    Python Why won't this python code work?

    lists = [(2 * i + 1) for i in range(100)] i = 0 while (i < 100): if(lists[i] == 3): lists.remove(lists[i]) i = i + 1 print lists It is giving me an error about the index being out of range. I am new to python and I am not understanding this error. Edit: Fixed it. This is by...
  10. C

    MATLAB Transfer fourier series into matlab code.

    Hey guys, i need to transfer Fourier series equation into MATLAB code. Anyone can help me in transfering?
  11. E

    PIC Code Uncertainty: Why Does Placement Matter?

    Hi, I have just managed to make a PIC light blink. My question has to do with the syntax. In my code, I use a Delay subroutine that is called in between turning the LED on and turning it off. I tried two codes. The first had my Delay subroutine being placed before my main code. The second had...
  12. F

    Romberg integration fortran code

    how to code it?...sequence? logic?..
  13. B

    LaTeX LaTeX Code Distorsion in Forum Edit Mode

    Hi. When I write my LaTeX code in this forum, it appears completely distorsionated when I click "Preview Changes" in edit mode. For example: n^2(\rho) = n^2_0\left(1-\alpha^2\rho^2)\right) is shown as a "z" if previously I wrote z. In fact, I don't know if this post will be shown well...
  14. C

    C/C++ Solving Prime Number Code Error in C++

    I was writing a program to find if a given number is prime or not. I can't figure out what the error is. /* To check if a number is prime*/ #include <iostream> #include <cmath> using namespace std; int main() { float a; int p,i,f=0; p=sqrt(a); if(a %...
  15. S

    Requesting permission to post the code

    I have written a C code program for factorization of a given number into two divisors, when the two divisors are having approximately the same number of digits . It cannot check for prime numbers. With my code limit I can check it only upto 14 digits using long long int. It is working...
  16. G

    Packaged software for alloys, pwscf code (quantum espresso)

    Hello all, i need a packaged software for electronic band structure of alloys (semiconductors alloys) using pwscf code, quantum espresso. thanks
  17. P

    Fortran Code for Solving Linear System w/ Least Square Method

    Dear all: For a standard linear system, y(n*1)=A(n*n)x(n*1) If y is exact and A is well-conditioned, it is easy to calculate x. However, if y has some disturbances or some errors, at the same time, A matrix is ill-conditioned. It is difficult to accurately obtain vector x...
  18. T

    Finite Difference Approximation, Mathematica code

    Homework Statement I have to program a three component decay chain using finite difference approximation. I understand finite difference and have written my code, but I have an error I can not find which is giving me an erroneous answer. The curve is correct, but the magnitude of the...
  19. P

    Fortran Debugging Strange Fortran Code: A Simple Delta Function

    Hi guys, I just wrote a simple code for delta function and print it out. Here it is. program main implicit none integer i real*8 del real*8,parameter:: ep=1D-2 real*8,parameter:: pi=3.1415926 do i=-10,10,1 write(*,*)...
  20. N

    MATLAB code to Geometric Random Variable

    Homework Statement Generate Geometric RV with Porbabilty of succcess 0.1 using only rand() Homework Equations rand() geometric rv P=(1-p)^(k-1) * p where p=0.1, k is number of trial in which we get 1st success The Attempt at a Solution rand(n)
  21. D

    LaTeX How to post this Latex code on forum?

    Hello! I just finished typing up my first Latex document for a proof I worked on. Now, I'm having trouble posting it on these forums. Here is the source code... \begin{document} $f : \mathbb{R} \Rightarrow \mathbb{R}$ is odd $\;\Longleftrightarrow \;f(-x) = -f(x) \;\forall x$. Show that...
  22. A

    MATLAB [matlab] something wrong with my code

    Hi all I'm new to matlab/scilab. I want to draw a 3D surface using z = cos(x+y)*cos(3x-y)+cos(x-y)*sin(x+3y)+5e^(x2+y2)/8 I typed "Z=cos(x+y)*cos(3*x-y)+cos(x-y)*sin(x+3*y)+5*exp(-(x.^2+y.^2)/8);" into matlab, but is says "Inconsistent multiplication". I would appreciate anyone who...
  23. A

    Scilab Help: Create 3D Surface Code | Due Tuesday

    Hi all I'm new to scilab. I was given an assignment to use scilab to draw a 3D surface. It needs to be creative and clearly noted what the codes mean. I'm totally freaking out with my assignment because it is due Tuesday next week. I would apprecriate anyone who could help me. Thanks for...
  24. N

    MATLAB code to Generate Raleigh Random Variable

    What is the Matlab code for generating 100,000 Raleigh Random Variable with sigma^2=2 using rand command only. Generate histogram and normalize it by dividing 1,00,000 times the bin width
  25. R

    MATLAB Analyzing Falling Object w/ Linear Friction: Troubleshooting Code

    It's an object that's falling from rest. The equation takes into account linear friction. in any case, this is is my code or program of whatever it is called: m=80;%Mass of ignorance g=9.8;%Gravity beta=1.6*10^-4;%Given coefficient for air at STP D=.4;%Diameter of Palin, assuming she's a...
  26. J

    Fortran Fortran Code for Calculating Second-Order Derivative | Get Help Now!

    I'm looking for a fortran code to calculate second-order derivative from a dataset. Please help me!
  27. Orion1

    LaTeX Practice test latex source code

    Does this forum have a source code 'sandbox' to practice test latex source code for publishing on Physics Forums? I remember a sandbox a long time ago when latex was first introduced on Physics Forums, was it removed? [/Color]
  28. M

    Writing a code in matlab for n variables.

    Hi, I am very new to matlab, this is actually the first time I am using it. I have to write a code for finding averages, right now I have "function av=average(x1,x2,x3,x4,x5) % average(x1,x2,x3,x4,x5) returns the average of (x1,x2,x3,x4,x5) av=(x1+x2+x3+x4+x5)/5; return;" This works just fine...
  29. G

    Matlab, code to eval Jacobian Matrix numerically

    Homework Statement The question is in 5 parts all mainly to do with Newton's Method, I've done parts a,b,d and e, but am struggling with the understanding of part c. They have given us the code but unsure as to how to modify my own code to suit the question. Another problem is I don't...
  30. T

    MATLAB Matlab Help -- code to randomly select a file and a sentence in that file

    clc for ii=1:1:3 % start looping rand_id= rand(1,1) *3; % Randomly generte a number between 1 to 3.if (rand_id<1) rand_id=1; % 0 is ommitted. else rand_id=floor(rand_id); end % rand_id will be used to open a previously saved file randomly. if (rand_id==1)...
  31. L

    Matlab Code Help for x[n]=x(n2Ts)

    Homework Statement x(t)=4sin(0.5t).3u(t) x[n]=x(n2Ts) The 1st equation, x(t)=4sin(0.5t).2u(t) Code : >> A=2; >> wo=0.5; >> t=5:0.25:50; >> x=A*sin(wo*t).3*(t>=0); >> plot(t,x), grid on >> xlabel('t (s)'); ylabel('Amplitude(unit)') But the second one,x[n]=x(n2Ts), I don't know...
  32. P

    How Challenging Is It to Create a Non-Symbolic MATLAB Laplace Transform Solver?

    Hi all How hard is it to write a symbolic laplace solver ? (I am aware that there are many available out there, but I wanted to write one in MATLAB which doesn't use symbolic toolbox). Where can I start to get a good reference for the code ? Thank you Prabhakar
  33. W

    What Type of Code is This for PIC Microcontrollers?

    Hi! May I know what type of this source code it is?It looks like assembly code, but I'm not sure. LIST p=16f648a include "P16f648a.inc" __config h'3f18' PC equ h'02' cblock h'20' endc org h'0000'...
  34. A

    MATLAB Help Needed: MATLAB Code for Semiconductor Laser Rate Equation

    Can anyone help me by giving MATLAB code to simulate semiconductor laser rate equation by finite difference methord. i wrote a code but that was not working. so i need it badly. please help me.
  35. J

    Code Requirements for finger-safe Conductor Rail

    Code Requirements for "finger-safe" Conductor Rail I'm planning to install conductor rails about 7ft above the floor in an astronomical observatory. The rails are IP2 "finger safe" rated. Where should I look to determine if this is sufficient enough for conductor rails which will be within...
  36. M

    Troubleshooting Code: Counting A Wins Over B

    can someone tell me what is wrong with my code? i am trying to make a code that has 1000000 randomly choosing A or B 1000 times. if A is bigger than B, i want to increment the variable called 'aWins'... when i try to get it to print the screen is blank. i left out the int main and #include parts...
  37. T

    Java Can someone look at this Java code for me?

    im starting a project from an Ebook that seems to be missing a line or two or something. Can someone suggest what should be here? I added the ending parsing since it was one of the more obvious missing things. import com.sun.j3d.loaders.*; import...
  38. P

    How Does Simple Encryption Work in Java Programming?

    Hello, My professor wants us to code a program that encrypts a massage and decrypt it , I know that to encrypt something you need a message and a key, and you assign a number to each letter or the message, and you do the same with the key, and then you add the two numbers together to get...
  39. A

    Where can I find source code for scientific programs?

    :rolleyes: ... not sure if this is the right place to post this. Hi, I'm looking for something like GSL but with programs instead of routines. For example, there is a method that was developed in the 80's for solving the time-dependent Schrödinger Equation (M. D. Feit, J. A. Fleck Jr. and...
  40. Z

    Why does the function file_object.readlines() return code and not text?

    Okay, I just began a bit of a python phase, and I want some help. You'll probably be hearing from me quite a bit in the next few weeks. Anyway, my question is about I/O functions. Specifically when it comes to opening and closing text documents. I have successfully opened a file (which I...
  41. C

    How to Calculate C Parameter in FMn Card for MCNP Code

    Hi there I have a question about FMn card in mcnp code. there is a parameter (is named C) in front of FMn card, I can not understand to calculate the value of that parameter. please help me. thanks alot.
  42. M

    Calculating Hypotenuse with C++ Code

    i am trying to write a code that calculates the hypotenuse of a triangle... when i try to run it, i get a run time error. I'm not exactly sure what the problem is. #include <iostream> #include <cmath> using namespace std; void hypotenuse(double side1, double side2...
  43. M

    Is My MATLAB Code for Heat Transfer Correct?

    Hi so i have a heat transfer project to determine the material (aka the thermal conductivity) and length of a 2d wall. It has to have between -1 and 1 net rate of heat loss from the southern side and above 145 rate of heat transfer from the eastern side. The wall is 20 cm high na the boundry...
  44. B

    PHP WEBSITE HIJACKED - Php code infected - HELP?

    WEBSITE HIJACKED - Php code infected! - HELP!? Hey All, I've got a major *$%#@ problem. I'm freaking out here. Check this out. On my website, I have a way to allow visitors... to become distributors and sell my product as well. When they become a distributor, it creates a subdomain for...
  45. F

    Optimization of C code: smoothing an image.

    Homework Statement I need to optimize this given code: /* A struct used to compute averaged pixel value */ typedef struct { int red; int green; int blue; int num; } pixel_sum; /* Compute min and max of two integers, respectively */ static int min(int a, int b) { return (a < b ...
  46. S

    Need help forgot my alarm code.

    Hi Guys sorry to be a pain We had a power cut in the area, and it messed my alarm up i put my code into turn it off but instead reprogrammed it with a new code. the buttons i used were 12349 but can't remember the order i put them in, could someone pm me a list of combinations to try. it is...
  47. H

    C# Can anyone explain what this c# code does or give a C equalivent?

    C# vs c ! Hello every body! can anyone explain what this c# code does or give a C equalivent? public static void Replace(ref byte b, int pos, byte value) { b = (byte) (value == 1 ? b | (1 << pos) : b & ~(1 << pos)); } public static byte...
  48. F

    Optimization of C Code Loop Unrolling

    Homework Statement I need to optimize this given code that rotates an image 90 degrees so it runs at least three times faster: void naive_rotate(int dim, pixel *src, pixel *dst) { int i, j; for (i = 0; i < dim; i++) for (j = 0; j < dim; j++) dst[RIDX(dim-1-j, i, dim)] =...
  49. K

    MATLAB How to Create a Routine in Matlab for Summing Every 10 Steps of a Matrix?

    hello every one. I want to create a routine in matlab Let A be a (40,1) matrix. I want to create a routine that every 10 steps of A will take the sum and place it in a new matrix. ty
  50. M

    Numerical integration - optimisation of code

    Hello I have a function which is very similar in shape to a Gaussian, except it is not a distribution and it is not analytic, so I can at best calculate a single point on the curve at a time. (In general it is a convolution of different distributions but this is not important). I need to find...
Back
Top