[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Need an advice on how to approach the following NP-hard problem:

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 8
Thread images: 1

File: ftw_too_smart.jpg (47KB, 645x968px) Image search: [Google]
ftw_too_smart.jpg
47KB, 645x968px
Need an advice on how to approach the following NP-hard problem:

Given a sequence tan(1),tan(2),...,tan(n) insert '+', '-', '*' to minimize the absolute value of difference of n and value of resulting expression. (5 ≤ n ≤ 365).

I know very little about approximation algorithms for NP-hard problems and I'd be happy if anon could give me a general idea how to approach this problem or what this problem can be reduced to or whether it is a generalization of some well-known NP-problem so I can google more efficiently.
>>
>>9162277
I'd build a dynamic programming table from n=5 to n=365, tracking which operator gives the lowest absolute value up to that n.
>>
>>9162292
Also this seems related to knapsack problems, but I don't know how I'd spell out the reduction mapping to which variant.
>>
OP: Can you specify the problem statement in a bit more detail, please?
>>
>>9162277
There's a few rules here.
The smallest possible value is 0.
Tangent ranges between -inf and +inf
Your domain can be converted to about
2 pi to 100 pi.

You can't use derivatives.
Based on this, you can use the periodic nature of tangent.
You want to add all the values in the first quadrant with those in the 4th. There's an offset of n. Whatever is left over from symmetry needs to be minimized.

From 5 to 365, most of the terms cancel so you are left with a much simpler problem.
>>
>>9162292
>>9162293
Thanks, I'll give it a try.

>>9162302
I think I'll just give an example for the toy case of [math]n = 3[/math] (although I said [math]n \ge 5[/math]). For the sequence [math]tan(1),\
tan(2), \ tan(3)[/math] the desired result is [math]tan(1) - tan(2) + tan(3) = 0.599901 [/math]. In this case [math]0.599901[/math] is the closest you can get to [math]3[/math].
>>
>>9162310
I assume these are radians.

What about tan(1) + tan(2) * tan(3) = 1.86887760364 ?
>>
>>9162319
I was lost in thoughts, I meant [math]|n - (tan(1)-tan(2)+tan(3))| = 0.599901[/math]. Your case gives [math]|n - x| = 1.131[/math] while the task is to minimize this difference.

>>9162305
Thanks for your response. This sounds like a good idea
Thread posts: 8
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.