My Math Forum  

Go Back   My Math Forum > Math Forums > Math

Math General Math Forum - For general math related discussion and news


Reply
 
LinkBack Thread Tools Display Modes
August 26th, 2016, 07:16 AM   #1
Newbie
 
Joined: Aug 2016
From: india

Posts: 1
Thanks: 0

Question Can you find some relation

hey everyone , I am writing a computer program but I am stuck somewhere
If you can find any logic or relation between the following data so I can handle of them in one single statement ?

i j

1 2
2 5
3 3
4 1
5 4
dhairya bhardwaj is offline  
 
August 26th, 2016, 08:34 AM   #2
Senior Member
 
romsek's Avatar
 
Joined: Sep 2015
From: USA

Posts: 2,305
Thanks: 1221

Even if there is some arcane input output relationship between these two arrays it's fairly poor programming to try and force some sort of mathematical formula to describe it. With hardware resources being a mostly insignificant concern these days clarity is a more important property of good code.

how about this statement... (in C)

j = switch {
case 1 : 2;
case 2 : 5;
case 3 : 3;
case 4 : 1;
case 5 : 4;
default : printf(stderr, "Undefined input\n");
}

or a more typical way of doing this is with an array.

int f = {2,5,3,1,4};

j = f[i+1];

Last edited by romsek; August 26th, 2016 at 08:47 AM.
romsek is offline  
August 26th, 2016, 08:37 AM   #3
Senior Member
 
fysmat's Avatar
 
Joined: Dec 2013
From: some subspace

Posts: 212
Thanks: 72

Math Focus: real analysis, vector analysis, numerical analysis, discrete mathematics
If one really wish to write a formula for it, maybe $\displaystyle j = \frac{5}{6}i^3 - 7\tfrac{1}{2}i^2 + 19\tfrac{2}{3}i - 11$ works.
fysmat is offline  
September 8th, 2016, 05:59 AM   #4
Senior Member
 
Joined: Aug 2016
From: morocco

Posts: 273
Thanks: 32

2+3*(i-1)-5/20*(i-1)(i-2)+5/6*(i-1)(i-2)(i-3).
we use finite differences of Newton method of polynomial interpolation.
abdallahhammam is offline  
Reply

  My Math Forum > Math Forums > Math

Tags
find, relation



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Recurrence Relation study7 Number Theory 0 November 12th, 2014 04:54 AM
Recurrence Relation and Closed Form Relation uniquegel Algebra 4 September 8th, 2014 05:18 PM
Relation gaussrelatz Applied Math 3 August 31st, 2012 07:51 AM
find binary relation finalight Applied Math 13 October 14th, 2011 10:16 AM
find recurrence relation robocop_911 Applied Math 0 June 4th, 2008 12:40 PM





Copyright © 2019 My Math Forum. All rights reserved.